-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetupJest.ts
More file actions
65 lines (58 loc) · 1.97 KB
/
Copy pathsetupJest.ts
File metadata and controls
65 lines (58 loc) · 1.97 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
56
57
58
59
60
61
62
63
64
65
// setupJest.ts
jest.mock('react-native', () => {
const RN = jest.requireActual('react-native'); // use original implementation, which comes with mocks out of the box
RN.Platform.OS = 'ios';
// Imperative session control. TurboModuleRegistry.get falls back to
// NativeModules when there is no turbo module proxy, which is the case under
// Jest, so mocking here covers both lookup paths.
RN.NativeModules.RNObjectCaptureSession = {
resumeSession: jest.fn(),
pauseSession: jest.fn(),
startDetection: jest.fn(),
resetDetection: jest.fn(),
startCapturing: jest.fn(),
beginNewScanAfterFlip: jest.fn(),
beginNewScan: jest.fn(),
finishSession: jest.fn(),
cancelSession: jest.fn(),
getTrackingState: jest.fn(),
getFeedbackState: jest.fn(),
getNumberOfShotsTaken: jest.fn(),
getNumberOfScanPassUpdates: jest.fn(),
getUserCompletedScanState: jest.fn(),
isDeviceSupported: jest.fn(),
getSessionState: jest.fn(),
};
RN.NativeModules.RNPhotogrammetrySession = {
startReconstruction: jest.fn(),
cancelReconstruction: jest.fn(),
listDirectoryContents: jest.fn(),
addErrorListener: jest.fn(),
addRequestCompleteListener: jest.fn(),
addInputCompleteListener: jest.fn(),
addInvalidSampleListener: jest.fn(),
addSkippedSampleListener: jest.fn(),
addAutomaticDownsamplingListener: jest.fn(),
addProcessingCancelledListener: jest.fn(),
addUnknownOutputListener: jest.fn(),
addListener: jest.fn(),
};
RN.NativeModules.RNObjectCapture = {
constants: {
SessionState: {
initializing: 'initializing',
ready: 'ready',
capturing: 'capturing',
processing: 'processing',
completed: 'completed',
failed: 'failed',
},
},
};
// mock modules created through UIManager
RN.NativeEventEmitter.addListener = jest
.fn()
.mockReturnValue({ remove: jest.fn() });
RN.NativeEventEmitter.removeAllListeners = jest.fn();
return RN;
});