-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.setup.js
More file actions
55 lines (50 loc) · 1.36 KB
/
jest.setup.js
File metadata and controls
55 lines (50 loc) · 1.36 KB
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
/* eslint-disable no-undef */
import { NativeModules } from 'react-native';
// Mock NativeModules
NativeModules.UserpilotReactNative =
NativeModules.UserpilotReactNative ||
{
// mock any methods your plugin calls if needed
};
NativeModules.SovranReactNative = NativeModules.SovranReactNative || {};
jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter', () => {
return jest.fn().mockImplementation(() => ({
addListener: jest.fn(),
removeListener: jest.fn(),
removeAllListeners: jest.fn(),
emit: jest.fn(),
}));
});
// Mock @segment/sovran-react-native
jest.mock('@segment/sovran-react-native', () => ({
createStore: jest.fn(() => ({
select: jest.fn(),
dispatch: jest.fn(),
subscribe: jest.fn(),
})),
}));
// Mock @segment/analytics-react-native
jest.mock('@segment/analytics-react-native', () => ({
DestinationPlugin: class MockDestinationPlugin {
constructor() {
this.type = 'destination';
}
},
PluginType: {
destination: 'destination',
},
EventType: {
IdentifyEvent: 'identify',
GroupEvent: 'group',
TrackEvent: 'track',
ScreenEvent: 'screen',
},
IdentifyEventType: jest.fn(),
GroupEventType: jest.fn(),
TrackEventType: jest.fn(),
ScreenEventType: jest.fn(),
UpdateType: jest.fn(),
UserTraits: jest.fn(),
GroupTraits: jest.fn(),
SegmentAPISettings: jest.fn(),
}));