-
Notifications
You must be signed in to change notification settings - Fork 7
/
jest-setup.ts
42 lines (37 loc) · 1.46 KB
/
jest-setup.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
34
35
36
37
38
39
40
41
42
// @ts-ignore
// eslint-disable-next-line import/no-extraneous-dependencies
import mockClipboard from '@react-native-clipboard/clipboard/jest/clipboard-mock';
// @ts-ignore
// eslint-disable-next-line import/no-extraneous-dependencies
import mockDeviceInfo from 'react-native-device-info/jest/react-native-device-info-mock';
jest.mock('@react-native-clipboard/clipboard', () => mockClipboard);
jest.mock('react-native-device-info', () => mockDeviceInfo);
jest.mock(
'react-native-localization',
() =>
class RNLocalization {
language = 'en';
props: any;
constructor(props: any) {
this.props = props;
this.setLanguage(this.language);
this.getLanguage();
}
setLanguage(interfaceLanguage: string) {
this.language = interfaceLanguage;
if (this.props[interfaceLanguage]) {
const localizedStrings = this.props[this.language];
Object.keys(localizedStrings).forEach((key: string) => {
// eslint-disable-next-line no-prototype-builtins
if (localizedStrings.hasOwnProperty(key)) {
// @ts-ignore
this[key] = localizedStrings[key];
}
});
}
}
getLanguage() {
return this.language;
}
},
);