This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
mock.js
65 lines (57 loc) · 1.61 KB
/
mock.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
jest.mock('react-native-reanimated', () => {
const React = require('react');
const View = require('react-native/Libraries/Components/View/View');
const mock = require('react-native-reanimated/mock');
mock.default.Value = function() {
return {
setValue: function() {},
};
};
function MockView(props) {
React.useEffect(() => {
props.onLayout &&
props.onLayout({
nativeEvent: { layout: { width: 100, height: 100 } },
});
}, []);
return React.createElement(View, props, props.children);
}
mock.default.View = MockView;
mock.default.useCode = function() {};
return mock;
});
jest.mock('react-native-gesture-handler', () => {
const View = require('react-native/Libraries/Components/View/View');
const TouchableOpacity = require('react-native/Libraries/Components/Touchable/TouchableOpacity');
return {
Swipeable: View,
DrawerLayout: View,
State: {},
ScrollView: View,
Slider: View,
Switch: View,
TextInput: View,
ToolbarAndroid: View,
ViewPagerAndroid: View,
DrawerLayoutAndroid: View,
WebView: View,
NativeViewGestureHandler: View,
TapGestureHandler: View,
FlingGestureHandler: View,
ForceTouchGestureHandler: View,
LongPressGestureHandler: View,
PanGestureHandler: View,
PinchGestureHandler: View,
RotationGestureHandler: View,
/* Buttons */
RawButton: View,
BaseButton: View,
RectButton: View,
BorderlessButton: View,
TouchableOpacity: TouchableOpacity,
/* Other */
FlatList: View,
gestureHandlerRootHOC: jest.fn(),
Directions: {},
};
});