/** * Mock implementation of IntersectionObserver for jsdom testing environment. * * jsdom does not implement IntersectionObserver, so this mock allows testing * components that rely on intersection detection (e.g., lazy loading, view tracking). * * @example * ```typescript * import { * setupIntersectionObserverMock, * teardownIntersectionObserverMock, * resetIntersectionObserverMock, * triggerIntersection, * triggerAllIntersections, * } from '../test-utils/IntersectionObserverMock'; * * describe('MyComponent', () => { * beforeAll(() => { * setupIntersectionObserverMock(); * }); * * afterAll(() => { * teardownIntersectionObserverMock(); * }); * * beforeEach(() => { * resetIntersectionObserverMock(); * }); * * it('tracks element visibility', async () => { * render(); * const element = screen.getByTestId('tracked-element'); * * triggerIntersection(element); * * expect(onVisibleSpy).toHaveBeenCalled(); * }); * }); * ``` */ declare class MockIntersectionObserverInstance implements IntersectionObserver { root: Element | Document | null; rootMargin: string; thresholds: readonly number[]; private callback; private observedElements; constructor(callback: IntersectionObserverCallback); observe(target: Element): void; unobserve(target: Element): void; disconnect(): void; takeRecords(): IntersectionObserverEntry[]; /** * Test helper: trigger intersection for a specific element on this observer. * Calls the observer callback with isIntersecting: true for the given element. */ triggerIntersection(element: Element): void; /** * Test helper: trigger intersection for all observed elements on this observer. */ triggerAllIntersections(): void; } /** * Trigger intersection for a specific element across all observer instances. * Use this when you know which element you want to mark as visible. */ export declare const triggerIntersection: (element: Element) => void; /** * Trigger intersection for all observed elements across all observer instances. * Use this to simulate all tracked elements becoming visible at once. */ export declare const triggerAllIntersections: () => void; /** * Set up the IntersectionObserver mock on the global object. * Call this in beforeAll() before your tests run. */ export declare const setupIntersectionObserverMock: () => void; /** * Tear down the IntersectionObserver mock from the global object. * Call this in afterAll() after your tests complete. */ export declare const teardownIntersectionObserverMock: () => void; /** * Reset all observer instances between tests. * Call this in beforeEach() to ensure test isolation. */ export declare const resetIntersectionObserverMock: () => void; /** * Get all currently active observer instances. * Useful for debugging or advanced test scenarios. */ export declare const getObserverInstances: () => Set; export {}; //# sourceMappingURL=IntersectionObserverMock.d.ts.map