-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjestSetup.js
68 lines (52 loc) · 1.72 KB
/
jestSetup.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import {NativeModules} from 'react-native';
NativeModules.ReactLocalization = {
language: 'en',
};
jest.mock('react-native-reanimated', () => {});
import mockAsyncStorage from '@react-native-community/async-storage/jest/async-storage-mock';
jest.mock('@react-native-community/async-storage', () => mockAsyncStorage);
// import mockLocalization from '__mocks__/react-native-localize';
// jest.mock('react-native-localization', () => mockLocalization);
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');
jest.mock('@react-native-community/google-signin', () => {
const mockGoogleSignin = require.requireActual(
'@react-native-community/google-signin',
);
mockGoogleSignin.GoogleSignin.hasPlayServices = () => Promise.resolve(true);
mockGoogleSignin.GoogleSignin.configure = () => Promise.resolve();
mockGoogleSignin.GoogleSignin.currentUserAsync = () => {
return Promise.resolve({
name: 'name',
email: '[email protected]',
// .... other user data
});
};
// ... and other functions you want to mock
return mockGoogleSignin;
});
NativeModules.RNGoogleSignin = {
BUTTON_SIZE_ICON: 0,
BUTTON_SIZE_STANDARD: 0,
BUTTON_SIZE_WIDE: 0,
BUTTON_COLOR_AUTO: 0,
BUTTON_COLOR_LIGHT: 0,
BUTTON_COLOR_DARK: 0,
SIGN_IN_CANCELLED: '0',
IN_PROGRESS: '1',
PLAY_SERVICES_NOT_AVAILABLE: '2',
SIGN_IN_REQUIRED: '3',
configure: jest.fn(),
currentUserAsync: jest.fn(),
};
jest.mock('@react-native-firebase/crashlytics', () => {
return () => ({});
});
NativeModules.ImagePickerManager = {
showImagePicker: jest.fn(),
launchCamera: jest.fn(),
launchImageLibrary: jest.fn(),
};
jest.mock('react-native-track-player', () => {
return () => ({});
});
export {NativeModules};