0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-27 21:39:16 -05:00
logto/packages/ui/src/jest.setup.ts
simeng-li 7dba17b867
feat(ui): add social web login flow (#531)
* feat(ui): add social web login flow

add social web login flow

* fix(ui): cr fix

code review fix

* fix(ui): fix typo

fix typo

* refactor(ui): social api renaming

social api renaming
2022-04-12 15:03:38 +08:00

34 lines
920 B
TypeScript

import { Crypto } from '@peculiar/webcrypto';
// 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(),
})),
});
// eslint-disable-next-line @silverhand/fp/no-mutation
global.crypto = new Crypto();
const translation = (key: string) => key;
jest.mock('react-i18next', () => ({
useTranslation: () => ({
t: translation,
i18n: {
t: translation,
},
}),
}));
export {};