This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 240
/
setupTest.js
67 lines (54 loc) · 1.63 KB
/
setupTest.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import 'dayjs/locale/en';
import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import dayjs from 'dayjs';
import timezonePlugin from 'dayjs/plugin/timezone';
import utcPlugin from 'dayjs/plugin/utc';
import localizedFormat from 'dayjs/plugin/localizedFormat';
import isToday from 'dayjs/plugin/isToday';
import isYesterday from 'dayjs/plugin/isYesterday';
import weekday from 'dayjs/plugin/weekday';
import isBetween from 'dayjs/plugin/isBetween';
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
import duration from 'dayjs/plugin/duration';
import ResizeObserver from 'resize-observer-polyfill';
import fetchMock from 'jest-fetch-mock';
window.ResizeObserver = ResizeObserver;
jest.setTimeout(10000);
dayjs.extend(localizedFormat);
dayjs.extend(utcPlugin);
dayjs.extend(timezonePlugin);
dayjs.extend(isToday);
dayjs.extend(isYesterday);
dayjs.extend(weekday);
dayjs.extend(isBetween);
dayjs.extend(isSameOrBefore);
dayjs.extend(duration);
class IntersectionObserver {
observe = jest.fn();
unobserve = jest.fn();
disconnect = jest.fn();
current = this;
}
Object.defineProperty(window, 'IntersectionObserver', {
configurable: true,
value: IntersectionObserver,
writable: true,
});
Object.defineProperty(global, 'IntersectionObserver', {
configurable: true,
value: IntersectionObserver,
writable: true,
});
i18n.use(initReactI18next).init({
fallbackLng: 'en',
keySeparator: false,
lng: 'en',
nsSeparator: false,
resources: {},
});
jest.mock('@centreon/ui-context', () => ({
...jest.requireActual('centreon-frontend/packages/ui-context'),
ThemeMode: 'light',
}));
fetchMock.enableMocks();