• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import '@testing-library/jest-dom';
17
18Object.defineProperty(window, 'matchMedia', {
19    writable: true,
20    value: jest.fn().mockImplementation((query) => ({
21        matches: false,
22        media: query,
23        onchange: null,
24        addListener: jest.fn(),
25        removeListener: jest.fn(),
26        addEventListener: jest.fn(),
27        removeEventListener: jest.fn(),
28        dispatchEvent: jest.fn(),
29    })),
30});
31
32global.IntersectionObserver = class IntersectionObserver {
33    root: Element | null = null;
34    rootMargin: string = '';
35    thresholds: ReadonlyArray<number> = [];
36
37    constructor(callback: IntersectionObserverCallback, options?: IntersectionObserverInit) {}
38
39    observe(target: Element): void {}
40
41    unobserve(target: Element): void {}
42
43    disconnect(): void {}
44
45    takeRecords(): IntersectionObserverEntry[] {
46        return [];
47    }
48};
49