Skip to content

Commit 060592a

Browse files
committed
fix validate
1 parent bd6b84b commit 060592a

3 files changed

Lines changed: 23 additions & 41 deletions

File tree

src/__tests__/fire-event.test.tsx

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,20 +158,14 @@ describe('fireEvent.press', () => {
158158
const onPressIn = jest.fn();
159159
const onPressOut = jest.fn();
160160
const onLongPress = jest.fn();
161-
162-
await render(
163-
<View
164-
testID="subject"
165-
// @ts-expect-error Intentionally passing test-only event props.
166-
testOnly_onPress={onPress}
167-
// @ts-expect-error Intentionally passing test-only event props.
168-
testOnly_onPressIn={onPressIn}
169-
// @ts-expect-error Intentionally passing test-only event props.
170-
testOnly_onPressOut={onPressOut}
171-
// @ts-expect-error Intentionally passing test-only event props.
172-
testOnly_onLongPress={onLongPress}
173-
/>,
174-
);
161+
const testOnlyPressProps = {
162+
testOnly_onPress: onPress,
163+
testOnly_onPressIn: onPressIn,
164+
testOnly_onPressOut: onPressOut,
165+
testOnly_onLongPress: onLongPress,
166+
};
167+
168+
await render(<View testID="subject" {...testOnlyPressProps} />);
175169

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

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

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,14 @@ describe('userEvent.longPress with fake timers', () => {
7777
test('works with testOnly_onPress handlers', async () => {
7878
const { events, logEvent } = createEventLogger();
7979
const user = userEvent.setup();
80-
81-
await render(
82-
<View
83-
testID="subject"
84-
// @ts-expect-error Intentionally passing test-only event props.
85-
testOnly_onPress={logEvent('press')}
86-
// @ts-expect-error Intentionally passing test-only event props.
87-
testOnly_onPressIn={logEvent('pressIn')}
88-
// @ts-expect-error Intentionally passing test-only event props.
89-
testOnly_onPressOut={logEvent('pressOut')}
90-
// @ts-expect-error Intentionally passing test-only event props.
91-
testOnly_onLongPress={logEvent('longPress')}
92-
/>,
93-
);
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} />);
9488

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

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,20 +100,14 @@ describe('userEvent.press with fake timers', () => {
100100
test('works with testOnly_onPress handlers', async () => {
101101
const { events, logEvent } = createEventLogger();
102102
const user = userEvent.setup();
103+
const testOnlyPressProps = {
104+
testOnly_onPress: logEvent('press'),
105+
testOnly_onPressIn: logEvent('pressIn'),
106+
testOnly_onPressOut: logEvent('pressOut'),
107+
testOnly_onLongPress: logEvent('longPress'),
108+
};
103109

104-
await render(
105-
<View
106-
testID="subject"
107-
// @ts-expect-error Intentionally passing test-only event props.
108-
testOnly_onPress={logEvent('press')}
109-
// @ts-expect-error Intentionally passing test-only event props.
110-
testOnly_onPressIn={logEvent('pressIn')}
111-
// @ts-expect-error Intentionally passing test-only event props.
112-
testOnly_onPressOut={logEvent('pressOut')}
113-
// @ts-expect-error Intentionally passing test-only event props.
114-
testOnly_onLongPress={logEvent('longPress')}
115-
/>,
116-
);
110+
await render(<View testID="subject" {...testOnlyPressProps} />);
117111

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

0 commit comments

Comments
 (0)