|
1 | | -describe('useIsInViewport', () => { |
2 | | - beforeEach(() => { |
3 | | - cy.visit('/') |
4 | | - cy.scrollTo(0, 0) |
5 | | - }) |
| 1 | +before(() => { |
| 2 | + cy.visit('/') |
| 3 | +}) |
6 | 4 |
|
7 | | - it('should work for element with a custom viewport', () => { |
8 | | - cy.get('[data-testid="div-viewport-parent-el"]').should( |
9 | | - 'contain', |
10 | | - 'Not intersecting with parent' |
11 | | - ) |
12 | | - cy.get('[data-testid="toggle-container-size"]').click() |
13 | | - cy.get('[data-testid="div-viewport-parent-el"]').should('contain', 'Intersecting with parent') |
14 | | - cy.get('[data-testid="toggle-container-size"]').click() |
15 | | - cy.get('[data-testid="div-viewport-parent-el"]').should( |
| 5 | +describe('useIsInViewport', () => { |
| 6 | + it('should report correctly when an element is visible in parent document', () => { |
| 7 | + cy.get('[data-testid="toggle-simple-parent-doc-test"]').should( |
16 | 8 | 'contain', |
17 | | - 'Not intersecting with parent' |
| 9 | + 'Hide simple parent doc test' |
18 | 10 | ) |
| 11 | + cy.get('[data-testid="box"]').should('contain', 'In viewport') |
| 12 | + cy.get('[data-testid="toggle-box-position"]').click() |
| 13 | + cy.get('[data-testid="box"]').should('contain', 'Out of viewport') |
| 14 | + cy.scrollTo(0, 430) |
| 15 | + cy.get('[data-testid="box"]').should('contain', 'In viewport') |
| 16 | + cy.scrollTo(0, 600) |
| 17 | + cy.get('[data-testid="box"]').should('contain', 'In viewport') |
19 | 18 | }) |
20 | 19 |
|
21 | | - it('should work for elements that intersect with their parent document', () => { |
22 | | - cy.get('[data-testid="div-viewport-window"]') |
23 | | - .should('contain', 'Hidden') |
24 | | - .scrollIntoView() |
25 | | - .should('contain', 'Visible') |
| 20 | + // it('should report correctly when ') |
26 | 21 |
|
27 | | - cy.scrollTo(0, 0) |
28 | | - cy.get('[data-testid="div-viewport-window"]').should('contain', 'Hidden') |
29 | | - }) |
| 22 | + // it('should work for element with a custom viewport', () => { |
| 23 | + // cy.get('[data-testid="div-viewport-parent-el"]').should( |
| 24 | + // 'contain', |
| 25 | + // 'Not intersecting with parent' |
| 26 | + // ) |
| 27 | + // cy.get('[data-testid="toggle-container-size"]').click() |
| 28 | + // cy.get('[data-testid="div-viewport-parent-el"]').should('contain', 'Intersecting with parent') |
| 29 | + // cy.get('[data-testid="toggle-container-size"]').click() |
| 30 | + // cy.get('[data-testid="div-viewport-parent-el"]').should( |
| 31 | + // 'contain', |
| 32 | + // 'Not intersecting with parent' |
| 33 | + // ) |
| 34 | + // }) |
| 35 | + |
| 36 | + // it('should work for elements that intersect with their parent document', () => { |
| 37 | + // cy.get('[data-testid="div-viewport-window"]') |
| 38 | + // .should('contain', 'Hidden') |
| 39 | + // .scrollIntoView() |
| 40 | + // .should('contain', 'Visible') |
| 41 | + |
| 42 | + // cy.scrollTo(0, 0) |
| 43 | + // cy.get('[data-testid="div-viewport-window"]').should('contain', 'Hidden') |
| 44 | + // }) |
30 | 45 | }) |
0 commit comments