diff --git a/cypress/integration/useIntersectionObserver.test.js b/cypress/integration/useIntersectionObserver.test.js index b708d9e..7e74d53 100644 --- a/cypress/integration/useIntersectionObserver.test.js +++ b/cypress/integration/useIntersectionObserver.test.js @@ -4,6 +4,11 @@ before(() => { describe('useIsInViewport', () => { it('should report correctly when an element is visible in parent document', () => { + cy.get('[data-testid="toggle-simple-parent-doc-test"]').should( + 'contain', + 'Show simple parent doc test' + ) + cy.get('[data-testid="toggle-simple-parent-doc-test"]').click() cy.get('[data-testid="toggle-simple-parent-doc-test"]').should( 'contain', 'Hide simple parent doc test' diff --git a/examples/cra/src/index.js b/examples/cra/src/index.js index d93fab2..264f4ce 100755 --- a/examples/cra/src/index.js +++ b/examples/cra/src/index.js @@ -11,7 +11,7 @@ import { } from './viewportAnotherElement' function App() { - const [testToShow, setTestToShow] = React.useState(1) + const [testToShow, setTestToShow] = React.useState(0) const forwardedTargetRef = node => { window.forwardedTargetRef = window.forwardedTargetRef || [] window.forwardedTargetRef.push(node) diff --git a/examples/cra/src/viewportAnotherElement.js b/examples/cra/src/viewportAnotherElement.js index d9072f5..846aa84 100644 --- a/examples/cra/src/viewportAnotherElement.js +++ b/examples/cra/src/viewportAnotherElement.js @@ -23,7 +23,7 @@ export function SimpleElement() { onClick={() => toggleHide(h => !h)} data-testid="toggle-box-position" > - {hidden ? 'Show box' : 'Hide box'} + {hidden ? 'Show box (or scroll to show it)' : 'Hide box'}
toggleHide(h => !h)} data-testid="toggle-boxes-positions" > - {hidden ? 'Show boxes' : 'Hide boxes'} + {hidden ? "Show boxes (or scroll to show 'em)" : 'Hide boxes'}
toggleHide(h => !h)} data-testid="toggle-box-position" > - {hidden ? 'Show box' : 'Hide box'} + {hidden ? 'Show box (or scroll to show it)' : 'Hide box'}
toggleHide(h => !h)} data-testid="toggle-box-position" > - {hidden ? 'Show box' : 'Hide box'} + {hidden ? 'Show box (or scroll to show it)' : 'Hide box'}