forked from bithyve/bitcoin-keeper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-setup.js
57 lines (46 loc) · 1.88 KB
/
test-setup.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
import '@testing-library/jest-native/extend-expect';
import 'react-native-gesture-handler/jestSetup';
import { Dimensions } from 'react-native';
import mockRNDeviceInfo from 'react-native-device-info/jest/react-native-device-info-mock';
global.net = require('net'); // needed by Electrum client. For RN it is proviced in shim.js
global.tls = require('tls'); // needed by Electrum client. For RN it is proviced in shim.js
jest.mock('react-native-device-info', () => mockRNDeviceInfo);
jest.mock('react-native/Libraries/Utilities/Dimensions');
jest.spyOn(Dimensions, 'get').mockReturnValue({
width: 414,
height: 818,
});
global.crypto = {
getRandomValues: (arr) => require('crypto').randomBytes(arr.length),
};
jest.mock('react-native-reanimated', () => {
const Reanimated = require('react-native-reanimated/mock');
// The mock for `call` immediately calls the callback which is incorrect
// So we override it with a no-op
Reanimated.default.call = () => {};
return Reanimated;
});
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper');
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter');
jest.mock('@react-native-firebase/messaging', () =>
jest.fn().mockImplementation(() => ({
hasPermission: jest.fn(() => Promise.resolve(true)),
subscribeToTopic: jest.fn(),
unsubscribeFromTopic: jest.fn(),
requestPermission: jest.fn(() => Promise.resolve(true)),
getToken: jest.fn(() => Promise.resolve('myMockToken')),
}))
);
jest.mock('redux-persist', () => {
const real = jest.requireActual('redux-persist');
return {
...real,
persistReducer: jest.fn().mockImplementation((config, reducers) => reducers),
};
});
jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock'));
jest.mock('@sentry/react-native', () => ({
init: jest.fn(),
ReactNavigationInstrumentation: jest.fn(),
ReactNativeTracing: jest.fn(),
}));