-
-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathjest.setup.js
More file actions
105 lines (92 loc) · 2.77 KB
/
jest.setup.js
File metadata and controls
105 lines (92 loc) · 2.77 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* eslint-env jest */
// Mock the native module
jest.mock('./src/specs/NativeTrueSheetModule', () => ({
__esModule: true,
default: {
presentByRef: jest.fn(),
dismissByRef: jest.fn(),
},
}));
// Mock the native components
jest.mock('./src/fabric/TrueSheetViewNativeComponent', () => {
const React = require('react');
const { View } = require('react-native');
return {
__esModule: true,
default: React.forwardRef((props, ref) => {
return React.createElement(View, { ...props, ref });
}),
};
});
jest.mock('./src/fabric/TrueSheetContainerViewNativeComponent', () => {
const React = require('react');
const { View } = require('react-native');
return {
__esModule: true,
default: React.forwardRef((props, ref) => {
return React.createElement(View, { ...props, ref });
}),
};
});
jest.mock('./src/fabric/TrueSheetContentViewNativeComponent', () => {
const React = require('react');
const { ScrollView } = require('react-native');
return {
__esModule: true,
default: React.forwardRef((props, ref) => {
return React.createElement(ScrollView, { ...props, ref });
}),
};
});
jest.mock('./src/fabric/TrueSheetHeaderViewNativeComponent', () => {
const React = require('react');
const { View } = require('react-native');
return {
__esModule: true,
default: React.forwardRef((props, ref) => {
return React.createElement(View, { ...props, ref });
}),
};
});
jest.mock('./src/fabric/TrueSheetFooterViewNativeComponent', () => {
const React = require('react');
const { View } = require('react-native');
return {
__esModule: true,
default: React.forwardRef((props, ref) => {
return React.createElement(View, { ...props, ref });
}),
};
});
// Mock react-native-reanimated
jest.mock('react-native-reanimated', () => ({
default: {
call: () => {},
createAnimatedComponent: (component) => component,
},
useSharedValue: jest.fn((initial) => ({ value: initial })),
useAnimatedStyle: jest.fn((callback) => callback()),
withTiming: jest.fn((value) => value),
withSpring: jest.fn((value) => value),
runOnJS: jest.fn((fn) => fn),
createAnimatedComponent: (component) => component,
useEvent: jest.fn(() => jest.fn()),
useHandler: jest.fn(() => ({ context: {}, doDependenciesDiffer: false })),
Easing: {
bezier: jest.fn(() => jest.fn()),
},
}));
// Mock react-native-worklets
jest.mock('react-native-worklets-core', () => ({}), { virtual: true });
jest.mock(
'react-native-worklets',
() => ({
scheduleOnRN: jest.fn((fn) => fn),
scheduleOnJS: jest.fn((fn) => fn),
useSharedValue: jest.fn((initial) => ({ value: initial })),
useWorklet: jest.fn((fn) => fn),
runOnJS: jest.fn((fn) => fn),
runOnUI: jest.fn((fn) => fn),
}),
{ virtual: true }
);