MCPcopy
hub / github.com/thebuilder/react-intersection-observer / mockIsIntersecting

Function mockIsIntersecting

src/test-utils.ts:253–268  ·  view source on GitHub ↗
(
  element: Element,
  isIntersecting: boolean | number,
)

Source from the content-addressed store, hash-verified

251 * @param isIntersecting {boolean | number}
252 */
253export function mockIsIntersecting(
254 element: Element,
255 isIntersecting: boolean | number,
256) {
257 warnOnMissingSetup();
258 const observer = intersectionMockInstance(element);
259 if (!observer) {
260 throw new Error(
261 "No IntersectionObserver instance found for element. Is it still mounted in the DOM?",
262 );
263 }
264 const item = observers.get(observer);
265 if (item) {
266 triggerIntersection([element], isIntersecting, observer, item);
267 }
268}
269
270/**
271 * Call the `intersectionMockInstance` method with an element, to get the (mocked)

Callers 2

useInView.test.tsxFile · 0.90
observe.test.tsFile · 0.90

Calls 3

warnOnMissingSetupFunction · 0.85
intersectionMockInstanceFunction · 0.85
triggerIntersectionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…