File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ it('shows the right lines on desktop and mobile', () => {
3535```
3636
3737## Mock intersection observer
38- Mocks intersection observer
38+ Provides a way of triggering intersection observer events
3939
4040Example, using `React Testing Library`:
4141
@@ -55,3 +55,17 @@ it('loads the image when the component is in the viewport', () => {
5555 expect(getByAltText('alt text')).toBeInTheDocument()
5656})
5757```
58+
59+ ### API
60+
61+ `mockIntersectionObserver` returns an object, that has several useful methods:
62+
63+ #### .enterNode(node, desc) and .leaveNode(node, desc)
64+ Triggers the intersection observer callback with only one node
65+ and `isIntersected` set to `true` (for `enterNode`) or `false` (for `leaveNode`).
66+ Other `IntersectionObserverEntry` params can be passed as `desc` argument
67+
68+ #### .enterAll(desc) and .leaveAll(desc)
69+ Triggers the intersection observer callback for all of the observed nodes
70+ and `isIntersected` set to `true` (for `enterAll`) or `false` (for `leaveAll`).
71+ Other `IntersectionObserverEntry` params can be passed as `desc` argument
You can’t perform that action at this time.
0 commit comments