Skip to content

Commit d1548c5

Browse files
author
pierrezimmermann
committed
refactor: check on press test that longPress is not called
1 parent 2ba1987 commit d1548c5

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/user-event/press/__tests__/longPress.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ describe('userEvent.longPress with fake timers', () => {
1515
const user = userEvent.setup();
1616

1717
render(
18-
<Pressable onLongPress={logEvent('longPress')}>
18+
<Pressable
19+
onPress={logEvent('press')}
20+
onLongPress={logEvent('longPress')}
21+
>
1922
<Text>press me</Text>
2023
</Pressable>
2124
);

src/user-event/press/__tests__/press.real-timers.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ describe('userEvent.press with real timers', () => {
3030
onPress={logEvent('press')}
3131
onPressIn={logEvent('pressIn')}
3232
onPressOut={logEvent('pressOut')}
33+
onLongPress={logEvent('longPress')}
3334
testID="pressable"
3435
/>
3536
);
@@ -48,6 +49,7 @@ describe('userEvent.press with real timers', () => {
4849
onPress={logEvent('press')}
4950
onPressIn={logEvent('pressIn')}
5051
onPressOut={logEvent('pressOut')}
52+
onLongPress={logEvent('longPress')}
5153
testID="pressable"
5254
/>
5355
);
@@ -65,6 +67,7 @@ describe('userEvent.press with real timers', () => {
6567
onPress={logEvent('press')}
6668
onPressIn={logEvent('pressIn')}
6769
onPressOut={logEvent('pressOut')}
70+
onLongPress={logEvent('longPress')}
6871
testID="pressable"
6972
pointerEvents="none"
7073
/>
@@ -83,6 +86,7 @@ describe('userEvent.press with real timers', () => {
8386
onPress={logEvent('press')}
8487
onPressIn={logEvent('pressIn')}
8588
onPressOut={logEvent('pressOut')}
89+
onLongPress={logEvent('longPress')}
8690
testID="pressable"
8791
pointerEvents="box-none"
8892
/>
@@ -102,6 +106,7 @@ describe('userEvent.press with real timers', () => {
102106
onPress={logEvent('press')}
103107
onPressIn={logEvent('pressIn')}
104108
onPressOut={logEvent('pressOut')}
109+
onLongPress={logEvent('longPress')}
105110
testID="pressable"
106111
/>
107112
</View>
@@ -120,6 +125,7 @@ describe('userEvent.press with real timers', () => {
120125
onPress={logEvent('press')}
121126
onPressIn={logEvent('pressIn')}
122127
onPressOut={logEvent('pressOut')}
128+
onLongPress={logEvent('longPress')}
123129
testID="pressable"
124130
pointerEvents="box-only"
125131
/>
@@ -189,6 +195,7 @@ describe('userEvent.press with real timers', () => {
189195
onPress={logEvent('press')}
190196
onPressIn={logEvent('pressIn')}
191197
onPressOut={logEvent('pressOut')}
198+
onLongPress={logEvent('longPress')}
192199
>
193200
press me
194201
</Text>
@@ -206,6 +213,7 @@ describe('userEvent.press with real timers', () => {
206213
onPress={logEvent('press')}
207214
onPressIn={logEvent('pressIn')}
208215
onPressOut={logEvent('pressOut')}
216+
onLongPress={logEvent('longPress')}
209217
disabled
210218
>
211219
press me
@@ -225,6 +233,7 @@ describe('userEvent.press with real timers', () => {
225233
onPress={logEvent('press')}
226234
onPressIn={logEvent('pressIn')}
227235
onPressOut={logEvent('pressOut')}
236+
onLongPress={logEvent('longPress')}
228237
>
229238
press me
230239
</Text>

src/user-event/press/__tests__/press.test.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ describe('userEvent.press with fake timers', () => {
2626
onPress={logEvent('press')}
2727
onPressIn={logEvent('pressIn')}
2828
onPressOut={logEvent('pressOut')}
29+
onLongPress={logEvent('longPress')}
2930
testID="pressable"
3031
/>
3132
);
@@ -165,6 +166,7 @@ describe('userEvent.press with fake timers', () => {
165166
onPress={logEvent('press')}
166167
onPressIn={logEvent('pressIn')}
167168
onPressOut={logEvent('pressOut')}
169+
onLongPress={logEvent('longPress')}
168170
testID="pressable"
169171
/>
170172
);
@@ -182,6 +184,7 @@ describe('userEvent.press with fake timers', () => {
182184
onPress={logEvent('press')}
183185
onPressIn={logEvent('pressIn')}
184186
onPressOut={logEvent('pressOut')}
187+
onLongPress={logEvent('longPress')}
185188
testID="pressable"
186189
pointerEvents="none"
187190
/>
@@ -200,6 +203,7 @@ describe('userEvent.press with fake timers', () => {
200203
onPress={logEvent('press')}
201204
onPressIn={logEvent('pressIn')}
202205
onPressOut={logEvent('pressOut')}
206+
onLongPress={logEvent('longPress')}
203207
testID="pressable"
204208
pointerEvents="box-none"
205209
/>
@@ -219,6 +223,7 @@ describe('userEvent.press with fake timers', () => {
219223
onPress={logEvent('press')}
220224
onPressIn={logEvent('pressIn')}
221225
onPressOut={logEvent('pressOut')}
226+
onLongPress={logEvent('longPress')}
222227
testID="pressable"
223228
/>
224229
</View>
@@ -237,6 +242,7 @@ describe('userEvent.press with fake timers', () => {
237242
onPress={logEvent('press')}
238243
onPressIn={logEvent('pressIn')}
239244
onPressOut={logEvent('pressOut')}
245+
onLongPress={logEvent('longPress')}
240246
testID="pressable"
241247
pointerEvents="box-only"
242248
/>
@@ -306,6 +312,7 @@ describe('userEvent.press with fake timers', () => {
306312
onPress={logEvent('press')}
307313
onPressIn={logEvent('pressIn')}
308314
onPressOut={logEvent('pressOut')}
315+
onLongPress={logEvent('longPress')}
309316
>
310317
press me
311318
</Text>
@@ -323,6 +330,7 @@ describe('userEvent.press with fake timers', () => {
323330
onPress={logEvent('press')}
324331
onPressIn={logEvent('pressIn')}
325332
onPressOut={logEvent('pressOut')}
333+
onLongPress={logEvent('longPress')}
326334
disabled
327335
>
328336
press me
@@ -342,6 +350,7 @@ describe('userEvent.press with fake timers', () => {
342350
onPress={logEvent('press')}
343351
onPressIn={logEvent('pressIn')}
344352
onPressOut={logEvent('pressOut')}
353+
onLongPress={logEvent('longPress')}
345354
>
346355
press me
347356
</Text>

0 commit comments

Comments
 (0)