mirror of
https://github.com/logto-io/logto.git
synced 2025-02-10 21:58:23 -05:00
29 lines
881 B
TypeScript
29 lines
881 B
TypeScript
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
|
|
// eslint-disable-next-line @silverhand/fp/no-mutating-methods
|
|
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(),
|
|
})),
|
|
});
|
|
|
|
const translation = (key: string) => key;
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
jest.mock('react-i18next', () => ({
|
|
...jest.requireActual('react-i18next'),
|
|
useTranslation: () => ({
|
|
t: translation,
|
|
i18n: {
|
|
t: translation,
|
|
},
|
|
}),
|
|
}));
|