0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-03 21:48:55 -05:00
logto/packages/experience/src/jest.setup.ts
Gao Sun 2319101056
refactor: ui -> experience (part 3)
Rename `ui` to `experience`.
2023-09-15 13:46:27 +08:00

27 lines
876 B
TypeScript

// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
import i18next from 'i18next';
import { initReactI18next } from 'react-i18next';
// 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(),
})),
});
void i18next.use(initReactI18next).init({
// Simple resources for testing
resources: { en: { translation: { action: { agree: 'Agree' } } } },
lng: 'en',
react: { useSuspense: false },
});