Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ module.exports = {
setupFilesAfterEnv: ['./jest-setup.ts'],
testPathIgnorePatterns: ['build/', 'examples/', 'experiments-app/', 'codemods/'],
testTimeout: 60000,
transformIgnorePatterns: [
'/node_modules/(?!(@react-native|react-native|react-native-gesture-handler)/).*/',
],
transformIgnorePatterns: ['/node_modules/(?!(@react-native|react-native)/).*/'],
snapshotSerializers: ['@relmify/jest-serializer-strip-ansi/always'],
clearMocks: true,
collectCoverageFrom: [
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"prettier": "^3.8.2",
"react": "19.2.3",
"react-native": "0.85.0",
"react-native-gesture-handler": "^2.31.1",
"release-it": "^19.2.4",
"test-renderer": "1.2.0",
"tsx": "^4.21.0",
Expand Down
29 changes: 29 additions & 0 deletions src/__tests__/fire-event.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,35 @@ describe('fireEvent.press', () => {
await fireEvent.press(screen.getByTestId('subject'));
expect(onPress).toHaveBeenCalled();
});

test('works with testOnly_onPress handlers', async () => {
const onPress = jest.fn();
const onPressIn = jest.fn();
const onPressOut = jest.fn();
const onLongPress = jest.fn();
const testOnlyPressProps = {
testOnly_onPress: onPress,
testOnly_onPressIn: onPressIn,
testOnly_onPressOut: onPressOut,
testOnly_onLongPress: onLongPress,
};

await render(<View testID="subject" {...testOnlyPressProps} />);

const subject = screen.getByTestId('subject');

await fireEvent.press(subject);
expect(onPress).toHaveBeenCalledTimes(1);

await fireEvent(subject, 'pressIn');
expect(onPressIn).toHaveBeenCalledTimes(1);

await fireEvent(subject, 'pressOut');
expect(onPressOut).toHaveBeenCalledTimes(1);

await fireEvent(subject, 'longPress');
expect(onLongPress).toHaveBeenCalledTimes(1);
});
});

describe('fireEvent.changeText', () => {
Expand Down
65 changes: 0 additions & 65 deletions src/__tests__/react-native-gesture-handler.test.tsx

This file was deleted.

18 changes: 17 additions & 1 deletion src/user-event/press/__tests__/longPress.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { Pressable, Text, TouchableHighlight, TouchableOpacity } from 'react-native';
import { Pressable, Text, TouchableHighlight, TouchableOpacity, View } from 'react-native';

import { render, screen } from '../../..';
import { createEventLogger, getEventsNames } from '../../../test-utils/events';
Expand Down Expand Up @@ -74,6 +74,22 @@ describe('userEvent.longPress with fake timers', () => {
expect(getEventsNames(events)).toEqual(['pressIn', 'longPress', 'pressOut']);
});

test('works with testOnly_onPress handlers', async () => {
const { events, logEvent } = createEventLogger();
const user = userEvent.setup();
const testOnlyPressProps = {
testOnly_onPress: logEvent('press'),
testOnly_onPressIn: logEvent('pressIn'),
testOnly_onPressOut: logEvent('pressOut'),
testOnly_onLongPress: logEvent('longPress'),
};

await render(<View testID="subject" {...testOnlyPressProps} />);

await user.longPress(screen.getByTestId('subject'));
expect(getEventsNames(events)).toEqual(['pressIn', 'longPress', 'pressOut']);
});

test('calls onLongPress if the delayLongPress is the default one', async () => {
const { logEvent, events } = createEventLogger();
const user = userEvent.setup();
Expand Down
16 changes: 16 additions & 0 deletions src/user-event/press/__tests__/press.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,22 @@ describe('userEvent.press with fake timers', () => {
expect(getEventsNames(events)).toEqual(['pressIn', 'pressOut']);
});

test('works with testOnly_onPress handlers', async () => {
const { events, logEvent } = createEventLogger();
const user = userEvent.setup();
const testOnlyPressProps = {
testOnly_onPress: logEvent('press'),
testOnly_onPressIn: logEvent('pressIn'),
testOnly_onPressOut: logEvent('pressOut'),
testOnly_onLongPress: logEvent('longPress'),
};

await render(<View testID="subject" {...testOnlyPressProps} />);

await user.press(screen.getByTestId('subject'));
expect(getEventsNames(events)).toEqual(['pressIn', 'pressOut', 'press']);
});

test('works on Button', async () => {
const { events, logEvent } = createEventLogger();

Expand Down
Loading
Loading