MCPcopy Create free account
hub / github.com/bitmap/react-hook-inview / mockInView

Function mockInView

src/__mocks__/mockInView.ts:41–58  ·  view source on GitHub ↗
(target: Element, isIntersecting: boolean)

Source from the content-addressed store, hash-verified

39});
40
41export 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}

Callers 2

useInView.test.tsxFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected