-
Notifications
You must be signed in to change notification settings - Fork 1
/
jest-setup.ts
49 lines (41 loc) · 1.32 KB
/
jest-setup.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* SPDX-FileCopyrightText: 2022 Zextras <https://www.zextras.com>
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import '@testing-library/jest-dom';
import failOnConsole from 'jest-fail-on-console';
import fetchMock from 'jest-fetch-mock';
import { http } from 'msw';
import {
defaultAfterAllTests,
defaultAfterEachTest,
defaultBeforeAllTests,
defaultBeforeEachTest,
getFailOnConsoleDefaultConfig
} from './src/carbonio-ui-commons/test/jest-setup';
import { useLocalStorage } from './src/carbonio-ui-commons/test/mocks/carbonio-shell-ui';
import { registerRestHandler } from './src/carbonio-ui-commons/test/mocks/network/msw/handlers';
import { handleGetConvRequest } from './src/tests/mocks/network/msw/handle-get-conv';
import { handleGetMsgRequest } from './src/tests/mocks/network/msw/handle-get-msg';
failOnConsole({
...getFailOnConsoleDefaultConfig()
});
beforeAll(() => {
fetchMock.doMock();
const h = http.post('/service/soap/GetMsgRequest', handleGetMsgRequest);
const j = http.post('/service/soap/GetConvRequest', handleGetConvRequest);
registerRestHandler(h);
registerRestHandler(j);
defaultBeforeAllTests();
useLocalStorage.mockReturnValue([jest.fn(), jest.fn()]);
});
beforeEach(() => {
defaultBeforeEachTest();
});
afterEach(() => {
defaultAfterEachTest();
});
afterAll(() => {
defaultAfterAllTests();
});