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

Function intersectionMockInstance

src/test-utils.ts:277–290  ·  view source on GitHub ↗
(
  element: Element,
)

Source from the content-addressed store, hash-verified

275 * @return IntersectionObserver
276 */
277export function intersectionMockInstance(
278 element: Element,
279): IntersectionObserver {
280 warnOnMissingSetup();
281 for (const [observer, item] of observers) {
282 if (item.elements.has(element)) {
283 return observer;
284 }
285 }
286
287 throw new Error(
288 "Failed to find IntersectionObserver for element. Is it being observed?",
289 );
290}

Callers 5

useInView.test.tsxFile · 0.90
InView.test.tsxFile · 0.90
observe.test.tsFile · 0.90
mockIsIntersectingFunction · 0.85

Calls 1

warnOnMissingSetupFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…