forked from sigp/siren
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-test.ts
33 lines (29 loc) · 859 Bytes
/
setup-test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
export const mockT = jest.fn((str: string): string => str)
import { renderNodes } from './test.helpers'
import '@testing-library/jest-dom'
jest.mock('recoil', () => ({
useRecoilValue: jest.fn(),
useSetRecoilState: jest.fn(),
useRecoilState: jest.fn(() => ['mock-value', jest.fn()]),
atom: jest.fn(),
selector: jest.fn(),
}))
process.env.SESSION_PASSWORD = 'mock-password'
jest.mock('i18next', () => ({
t: mockT,
}))
jest.mock('react-i18next', () => ({
useTranslation: jest.fn(() => ({
t: mockT,
i18n: {
// eslint-disable-next-line @typescript-eslint/no-empty-function
changeLanguage: () => new Promise(() => {}),
language: 'en',
},
})),
Trans: ({ i18nKey, children }: any) => {
return Array.isArray(children)
? renderNodes([i18nKey, ...children])
: renderNodes([i18nKey, children])
},
}))