(target: Element, isIntersecting: boolean)
| 39 | }); |
| 40 | |
| 41 | export function mockInView(target: Element, isIntersecting: boolean): void { |
| 42 | const callback = currentCallback; |
| 43 | const observer = currentObserver; |
| 44 | |
| 45 | if (callback && observer) { |
| 46 | const entry: IntersectionObserverEntry = { |
| 47 | isIntersecting, |
| 48 | target, |
| 49 | intersectionRatio: isIntersecting ? 1 : 0, |
| 50 | boundingClientRect: target.getBoundingClientRect(), |
| 51 | intersectionRect: target.getBoundingClientRect(), |
| 52 | rootBounds: target.getBoundingClientRect(), |
| 53 | time: 0, |
| 54 | }; |
| 55 | |
| 56 | act(() => callback([entry], observer)); |
| 57 | } |
| 58 | } |
no outgoing calls
no test coverage detected