|
1 | 1 | import React from 'react'; |
2 | | -import { Pressable, Text, TouchableHighlight, TouchableOpacity } from 'react-native'; |
| 2 | +import { Pressable, Text, TouchableHighlight, TouchableOpacity, View } from 'react-native'; |
3 | 3 |
|
4 | 4 | import { render, screen } from '../../..'; |
5 | 5 | import { createEventLogger, getEventsNames } from '../../../test-utils/events'; |
@@ -74,6 +74,22 @@ describe('userEvent.longPress with fake timers', () => { |
74 | 74 | expect(getEventsNames(events)).toEqual(['pressIn', 'longPress', 'pressOut']); |
75 | 75 | }); |
76 | 76 |
|
| 77 | + test('works with testOnly_onPress handlers', async () => { |
| 78 | + const { events, logEvent } = createEventLogger(); |
| 79 | + const user = userEvent.setup(); |
| 80 | + const testOnlyPressProps = { |
| 81 | + testOnly_onPress: logEvent('press'), |
| 82 | + testOnly_onPressIn: logEvent('pressIn'), |
| 83 | + testOnly_onPressOut: logEvent('pressOut'), |
| 84 | + testOnly_onLongPress: logEvent('longPress'), |
| 85 | + }; |
| 86 | + |
| 87 | + await render(<View testID="subject" {...testOnlyPressProps} />); |
| 88 | + |
| 89 | + await user.longPress(screen.getByTestId('subject')); |
| 90 | + expect(getEventsNames(events)).toEqual(['pressIn', 'longPress', 'pressOut']); |
| 91 | + }); |
| 92 | + |
77 | 93 | test('calls onLongPress if the delayLongPress is the default one', async () => { |
78 | 94 | const { logEvent, events } = createEventLogger(); |
79 | 95 | const user = userEvent.setup(); |
|
0 commit comments