2022-04-12 15:03:38 +08:00
|
|
|
import { Crypto } from '@peculiar/webcrypto';
|
|
|
|
|
2021-08-02 23:45:55 +08:00
|
|
|
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
|
2021-09-07 20:24:27 +08:00
|
|
|
// eslint-disable-next-line @silverhand/fp/no-mutating-methods
|
2021-08-02 23:45:55 +08:00
|
|
|
Object.defineProperty(window, 'matchMedia', {
|
|
|
|
writable: true,
|
|
|
|
value: jest.fn().mockImplementation((query) => ({
|
|
|
|
matches: false,
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
|
|
media: query,
|
|
|
|
onchange: null,
|
|
|
|
addListener: jest.fn(), // Deprecated
|
|
|
|
removeListener: jest.fn(), // Deprecated
|
|
|
|
addEventListener: jest.fn(),
|
|
|
|
removeEventListener: jest.fn(),
|
|
|
|
dispatchEvent: jest.fn(),
|
|
|
|
})),
|
|
|
|
});
|
|
|
|
|
2022-04-12 15:03:38 +08:00
|
|
|
// eslint-disable-next-line @silverhand/fp/no-mutation
|
|
|
|
global.crypto = new Crypto();
|
|
|
|
|
2022-03-31 13:49:39 +08:00
|
|
|
const translation = (key: string) => key;
|
|
|
|
|
2022-03-28 09:40:47 +08:00
|
|
|
jest.mock('react-i18next', () => ({
|
|
|
|
useTranslation: () => ({
|
2022-03-31 13:49:39 +08:00
|
|
|
t: translation,
|
2022-03-28 09:40:47 +08:00
|
|
|
i18n: {
|
2022-03-31 13:49:39 +08:00
|
|
|
t: translation,
|
2022-03-28 09:40:47 +08:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
}));
|
|
|
|
|
2021-08-02 23:45:55 +08:00
|
|
|
export {};
|