-
Notifications
You must be signed in to change notification settings - Fork 1
/
jest.setup.js
127 lines (111 loc) · 2.8 KB
/
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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { BackHandler, Dimensions } from 'react-native';
jest.mock('react-native-reanimated', () => {
const View = require('react-native').View;
return {
Value: jest.fn(),
event: jest.fn(),
add: jest.fn(),
eq: jest.fn(),
set: jest.fn(),
cond: jest.fn(),
interpolate: jest.fn(),
View: (props) => <View {...props} />,
createAnimatedComponent: (cb) => cb,
Extrapolate: { CLAMP: jest.fn() },
Transition: {
Together: 'Together',
Out: 'Out',
In: 'In',
},
useSharedValue: jest.fn(),
useDerivedValue: (a) => ({ value: a() }),
useAnimatedScrollHandler: () => () => {},
useAnimatedGestureHandler: () => () => {},
useAnimatedStyle: (cb) => cb(),
useAnimatedRef: () => ({ current: null }),
useAnimatedReaction: (value, cb) => cb(value(), ''),
useAnimatedProps: (cb) => cb(),
withTiming: (toValue, _, cb) => {
cb && cb(true);
return toValue;
},
withSpring: (toValue, _, cb) => {
cb && cb(true);
return toValue;
},
withDecay: (_, cb) => {
cb && cb(true);
return 0;
},
withDelay: (_, animationValue) => {
return animationValue;
},
withSequence: (..._animations) => {
return 0;
},
withRepeat: (animation, _, __, cb) => {
cb();
return animation;
},
cancelAnimation: () => {},
measure: () => ({
x: 0,
y: 0,
width: 0,
height: 0,
pageX: 0,
pageY: 0,
}),
Easing: {
linear: (cb) => cb(),
ease: (cb) => cb(),
quad: (cb) => cb(),
cubic: (cb) => cb(),
poly: (cb) => cb(),
sin: (cb) => cb(),
circle: (cb) => cb(),
exp: (cb) => cb(),
elastic: (cb) => cb(),
back: (cb) => cb(),
bounce: (cb) => cb(),
bezier: () => ({ factory: (cb) => cb() }),
bezierFn: (cb) => cb(),
steps: (cb) => cb(),
in: (cb) => cb(),
out: (cb) => cb(),
inOut: (cb) => cb(),
},
Extrapolation: {
EXTEND: 'extend',
CLAMP: 'clamp',
IDENTITY: 'identity',
},
runOnJS: (fn) => fn,
runOnUI: (fn) => fn,
};
});
jest.mock('react-native-gesture-handler', () => {
const View = require('react-native').View;
const ScrollView = require('react-native').ScrollView;
return {
GestureDetector: ({gesture, children}) => (
<View
onResponderStart={gesture.onStart}
onResponderEnd={gesture.onEnd}
onResponderMove={gesture.onUpdate}
testID="gestureContainer"
>
{children}
</View>
),
ScrollView
};
});
jest.mock('./src/core/hooks', () => ({useGesture: jest.fn()}));
BackHandler.addEventListener = (_, cb) => {
setTimeout(() => {
cb();
}, 1000);
return {remove: () => {}}
}
Dimensions.get = () => ({ width: 100, height: 1000 });