forked from microsoft/responsible-ai-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setupTest.ts
30 lines (24 loc) · 788 Bytes
/
setupTest.ts
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
import { configure } from "enzyme";
import ReactSeventeenAdapter from "@wojtekmaj/enzyme-adapter-react-17";
import "jest-canvas-mock";
import { initializeIcons } from "@fluentui/react";
initializeIcons();
jest.setTimeout(30000);
window.Worker = jest.fn();
// mock moment timezone
const moment = jest.requireActual("moment-timezone");
jest.doMock("moment", () => {
// Use timezone other than PST and UTC to show independence
moment.tz.setDefault("Australia/Sydney");
return moment;
});
if (!window.URL.createObjectURL) {
window.URL.createObjectURL = () => "";
}
beforeEach(() => {
jest.restoreAllMocks();
jest.resetAllMocks();
const dateTimeNowSpy = jest.spyOn(Date, "now");
dateTimeNowSpy.mockReturnValue(0);
});
configure({ adapter: new ReactSeventeenAdapter() });