aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/src/setupTests.ts
blob: 2afa12e17c59c15b1a25c46876eb26f00c0bc67b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import '@testing-library/jest-dom';

// Mock IntersectionObserver
class IntersectionObserver {
    readonly root: Element | null = null;
    readonly rootMargin: string = '';
    readonly thresholds: ReadonlyArray<number> = [];

    constructor(callback: IntersectionObserverCallback, options?: IntersectionObserverInit) {
        // nothing
    }

    observe(target: Element): void {
        // nothing
    }

    unobserve(target: Element): void {
        // nothing
    }

    disconnect(): void {
        // nothing
    }

    takeRecords(): IntersectionObserverEntry[] {
        return [];
    }
}

Object.defineProperty(window, 'IntersectionObserver', {
    writable: true,
    configurable: true,
    value: IntersectionObserver,
});

Object.defineProperty(global, 'IntersectionObserver', {
    writable: true,
    configurable: true,
    value: IntersectionObserver,
});