mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
chore(ui): add patch to matchMedia
This commit is contained in:
parent
a245f5f1e6
commit
2f47ae28b7
4 changed files with 22 additions and 4 deletions
|
@ -26,6 +26,7 @@ module.exports = {
|
|||
'^.+\\.(css|less|scss)$': 'babel-jest',
|
||||
'@/(.*)': '<rootDir>/src/$1',
|
||||
};
|
||||
config.setupFilesAfterEnv = [...config.setupFilesAfterEnv, './src/jest.setup.ts'];
|
||||
|
||||
return config;
|
||||
},
|
||||
|
|
|
@ -8,7 +8,7 @@ import SignIn from './pages/SignIn';
|
|||
import Register from './pages/Register';
|
||||
import './scss/normalized.scss';
|
||||
|
||||
initI18n();
|
||||
void initI18n();
|
||||
|
||||
const App = () => {
|
||||
const theme = useTheme();
|
||||
|
|
|
@ -3,8 +3,8 @@ import LanguageDetector from 'i18next-browser-languagedetector';
|
|||
import { initReactI18next } from 'react-i18next';
|
||||
import resources from '@logto/phrases';
|
||||
|
||||
const initI18n = () => {
|
||||
void i18n
|
||||
const initI18n = async () =>
|
||||
i18n
|
||||
.use(initReactI18next)
|
||||
.use(LanguageDetector)
|
||||
.init({
|
||||
|
@ -14,6 +14,5 @@ const initI18n = () => {
|
|||
escapeValue: false,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export default initI18n;
|
||||
|
|
18
packages/ui/src/jest.setup.ts
Normal file
18
packages/ui/src/jest.setup.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
// https://jestjs.io/docs/manual-mocks#mocking-methods-which-are-not-implemented-in-jsdom
|
||||
|
||||
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(),
|
||||
})),
|
||||
});
|
||||
|
||||
export {};
|
Loading…
Reference in a new issue