-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjest-setup.js
51 lines (46 loc) · 1018 Bytes
/
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
require('react-native-reanimated').setUpTests();
class LocalStorageMock {
constructor() {
this.store = {};
}
clear() {
this.store = {};
}
getItem(key) {
return this.store[key] || null;
}
setItem(key, value) {
this.store[key] = String(value);
}
removeItem(key) {
delete this.store[key];
}
}
global.localStorage = new LocalStorageMock();
global.fetch = require('node-fetch');
global.WebSocket = require('isomorphic-ws');
jest.mock('react-native-zip-archive', () => ({
zip: jest.fn(),
}));
jest.mock('react-native-file-logger', () => ({
FileLogger: {
configure: jest.fn(),
write: jest.fn(),
},
LogLevel: {
Debug: 0,
Info: 1,
Warning: 2,
Error: 3,
},
}));
jest.mock('react-native-device-info', () => ({
getBuildNumber: jest.fn(),
getDeviceId: jest.fn(),
getIncrementalSync: jest.fn(),
getModel: jest.fn(),
getSystemName: jest.fn(),
getSystemVersion: jest.fn(),
getTotalMemorySync: jest.fn(),
getUsedMemorySync: jest.fn(),
}));