forked from RocketChat/Rocket.Chat.ReactNative
-
Notifications
You must be signed in to change notification settings - Fork 3
/
jest.setup.js
69 lines (57 loc) · 1.98 KB
/
jest.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
58
59
60
61
62
63
64
65
66
67
68
69
import mockClipboard from '@react-native-clipboard/clipboard/jest/clipboard-mock.js';
import mockAsyncStorage from '@react-native-async-storage/async-storage/jest/async-storage-mock';
jest.mock('@react-native-async-storage/async-storage', () => mockAsyncStorage);
global.__reanimatedWorkletInit = () => {};
jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock'));
jest.mock('@react-native-clipboard/clipboard', () => mockClipboard);
jest.mock('rn-fetch-blob', () => ({
fs: {
dirs: {
DocumentDir: '/data/com.rocket.chat/documents',
DownloadDir: '/data/com.rocket.chat/downloads'
},
exists: jest.fn(() => null)
},
fetch: jest.fn(() => null),
config: jest.fn(() => null)
}));
jest.mock('react-native-file-viewer', () => ({
open: jest.fn(() => null)
}));
jest.mock('expo-haptics', () => jest.fn(() => null));
jest.mock('./app/lib/database', () => jest.fn(() => null));
const mockedNavigate = jest.fn();
jest.mock('@react-navigation/native', () => ({
...jest.requireActual('@react-navigation/native'),
useNavigation: () => mockedNavigate
}));
jest.mock('react-native-notifications', () => ({
Notifications: {
getInitialNotification: jest.fn(() => Promise.resolve()),
registerRemoteNotifications: jest.fn(),
events: () => ({
registerRemoteNotificationsRegistered: jest.fn(),
registerRemoteNotificationsRegistrationFailed: jest.fn(),
registerNotificationReceivedForeground: jest.fn(),
registerNotificationReceivedBackground: jest.fn(),
registerNotificationOpened: jest.fn()
})
}
}));
jest.mock('@gorhom/bottom-sheet', () => {
const react = require('react-native');
return {
__esModule: true,
default: react.View,
BottomSheetScrollView: react.ScrollView
};
});
// If you need to manually mock a lib use this mock pattern and set exports.
jest.mock('react-native-math-view', () => {
const react = require('react-native');
return {
__esModule: true,
default: react.View, // Default export
MathText: react.View // {...} Named export
};
});