-
Notifications
You must be signed in to change notification settings - Fork 34
/
setupTests.js
158 lines (125 loc) · 3.99 KB
/
setupTests.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* eslint-disable no-undef */
import React from 'react';
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import moment from 'moment-timezone';
require('./node_modules/react-native-gesture-handler/jestSetup.js');
const XMLHttpRequest = {
open: jest.fn(),
abort: jest.fn(),
onerror: jest.fn(),
};
global.XMLHttpRequest = XMLHttpRequest;
configure({ adapter: new Adapter() });
jest.mock('@livepeer/react-native');
jest.mock('expo-updates', () => ({
checkForUpdateAsync: jest.fn(),
fetchUpdateAsync: jest.fn(),
reloadAsync: jest.fn(),
}));
jest.mock('expo-application', () => ({
getApplicationName: jest.fn(),
}));
// jest.mock('react-native-url-polyfill', () => ({
// URL: jest.fn(),
// URLSearchParams: jest.fn(),
// }));
jest.mock('~/config/Version', () => ({
Version: {
VERSION: '3.8.0',
BUILD: 111,
},
}));
jest.mock('@react-native-cookies/cookies', () => ({
set: jest.fn(),
clearByName: jest.fn(),
}));
jest.mock('react-native-reanimated', () => ({
...require('react-native-reanimated/mock'),
useAnimatedKeyboard: jest.fn().mockReturnValue({ height: 0 }),
}));
jest.mock('./src/newsfeed/NewsfeedService');
jest.mock('expo-font');
jest.mock('@react-native-camera-roll/camera-roll');
jest.mock('expo-image');
// jest.mock('@snowplow/react-native-tracker');
// jest.mock('mobx-react', () => require('mobx-react/custom'));
jest.mock('@react-native-community/netinfo', () => ({
configure: jest.fn(),
addEventListener: jest.fn(),
}));
jest.mock('./tenant.json');
jest.mock('./AppStores');
jest.mock('./AppMessageProvider');
jest.mock('./src/common/services/storage/storages.service');
jest.useFakeTimers();
jest.doMock('moment', () => {
moment.tz.setDefault('America/Los_Angeles');
return moment;
});
jest.doMock('moment-timezone', () => {
moment.tz.setDefault('America/Los_Angeles');
return moment;
});
// fix for snapshots and touchables
jest.mock(
'react-native/Libraries/Components/Touchable/TouchableOpacity.js',
() => {
const { View } = require('react-native');
const MockTouchable = props => {
return <View {...props} />;
};
MockTouchable.displayName = 'TouchableOpacity';
return MockTouchable;
},
);
jest.mock(
'react-native/Libraries/Components/Touchable/TouchableHighlight.js',
() => {
const { View } = require('react-native');
const MockTouchable = props => {
return <View {...props} />;
};
MockTouchable.displayName = 'TouchableHighlight';
return MockTouchable;
},
);
jest.mock('react-native-system-setting', () => {
return {
getVolume: jest.fn(() => Promise.resolve()),
};
});
jest.mock('react-native-silent-switch');
jest.mock('big.js', () => ({ Big: jest.fn() }));
jest.mock('react-native-mmkv-storage');
global.__reanimatedWorkletInit = jest.fn();
jest.mock('@stripe/stripe-react-native', () =>
require('@stripe/stripe-react-native/jest/mock.js'),
);
jest.mock('react-native-exception-handler');
import ri18n from 'utils/locales';
ri18n.init();
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');
// expo vector icons
jest.mock('@expo/vector-icons/MaterialIcons', () => 'MaterialIcons');
jest.mock(
'@expo/vector-icons/MaterialCommunityIcons',
() => 'MaterialCommunityIcons',
);
jest.mock('@expo/vector-icons/FontAwesome5', () => 'FontAwesome5');
jest.mock('@expo/vector-icons/FontAwesome', () => 'FontAwesome');
jest.mock('@expo/vector-icons/Ionicons', () => 'IonIcon');
jest.mock('@expo/vector-icons/Feather', () => 'Feather');
jest.mock('@expo/vector-icons/Fontisto', () => 'Fontisto');
jest.mock('@expo/vector-icons/Entypo', () => 'Entypo');
jest.mock('@expo/vector-icons', () => ({
FontAwesome: () => {
return 'FontAwesome';
},
}));
jest.mock('react-native-keyboard-controller', () =>
require('react-native-keyboard-controller/jest'),
);
// mocked here since mocking it locally on the api.service is not working (probably because of the circular dependency)
// jest.mock('./src/navigation/NavigationService');
// jest.mock('~/auth/AuthService');