From 51481d9a1991fd5fa36cdbd0ee05d787a32a085e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Jastrze=CC=A8bski?= Date: Wed, 24 Apr 2024 22:02:00 +0200 Subject: [PATCH 1/5] fix: add stup base synthetic event methods --- src/user-event/event-builder/base.ts | 9 +++++++++ src/user-event/event-builder/common.ts | 11 +++++------ src/user-event/event-builder/scroll-view.ts | 5 +++-- src/user-event/event-builder/text-input.ts | 22 ++++++++------------- 4 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 src/user-event/event-builder/base.ts diff --git a/src/user-event/event-builder/base.ts b/src/user-event/event-builder/base.ts new file mode 100644 index 000000000..bd798a257 --- /dev/null +++ b/src/user-event/event-builder/base.ts @@ -0,0 +1,9 @@ +export function baseSyntheticEvent() { + return { + currentTarget: {}, + target: {}, + preventDefault: () => {}, + stopPropagation: () => {}, + persist: () => {}, + }; +} diff --git a/src/user-event/event-builder/common.ts b/src/user-event/event-builder/common.ts index f52b2a082..173c8ec7e 100644 --- a/src/user-event/event-builder/common.ts +++ b/src/user-event/event-builder/common.ts @@ -1,3 +1,5 @@ +import { baseSyntheticEvent } from './base'; + /** * Experimental values: * - iOS: `{"changedTouches": [[Circular]], "identifier": 1, "locationX": 253, "locationY": 30.333328247070312, "pageX": 273, "pageY": 141.3333282470703, "target": 75, "timestamp": 875928682.0450834, "touches": [[Circular]]}` @@ -5,6 +7,7 @@ */ function touch() { return { + ...baseSyntheticEvent(), nativeEvent: { changedTouches: [], identifier: 0, @@ -16,9 +19,7 @@ function touch() { timestamp: Date.now(), touches: [], }, - persist: () => {}, currentTarget: { measure: () => {} }, - target: {}, }; } @@ -46,11 +47,10 @@ export const CommonEventBuilder = { */ focus: () => { return { + ...baseSyntheticEvent(), nativeEvent: { target: 0, }, - currentTarget: {}, - target: {}, }; }, @@ -61,11 +61,10 @@ export const CommonEventBuilder = { */ blur: () => { return { + ...baseSyntheticEvent(), nativeEvent: { target: 0, }, - currentTarget: {}, - target: {}, }; }, }; diff --git a/src/user-event/event-builder/scroll-view.ts b/src/user-event/event-builder/scroll-view.ts index 4bae5aa19..c477b6c29 100644 --- a/src/user-event/event-builder/scroll-view.ts +++ b/src/user-event/event-builder/scroll-view.ts @@ -1,3 +1,5 @@ +import { baseSyntheticEvent } from './base'; + /** * Scroll position of a scrollable element. */ @@ -28,6 +30,7 @@ export type ScrollEventOptions = { export const ScrollViewEventBuilder = { scroll: (offset: ContentOffset = { y: 0, x: 0 }, options?: ScrollEventOptions) => { return { + ...baseSyntheticEvent(), nativeEvent: { contentInset: { bottom: 0, left: 0, right: 0, top: 0 }, contentOffset: { y: offset.y, x: offset.x }, @@ -43,8 +46,6 @@ export const ScrollViewEventBuilder = { target: 0, velocity: { y: 0, x: 0 }, }, - currentTarget: {}, - target: {}, }; }, }; diff --git a/src/user-event/event-builder/text-input.ts b/src/user-event/event-builder/text-input.ts index b0d215235..89a45a340 100644 --- a/src/user-event/event-builder/text-input.ts +++ b/src/user-event/event-builder/text-input.ts @@ -1,5 +1,6 @@ import { ContentSize } from '../utils/content-size'; import { TextRange } from '../utils/text-range'; +import { baseSyntheticEvent } from './base'; export const TextInputEventBuilder = { /** @@ -9,9 +10,8 @@ export const TextInputEventBuilder = { */ change: (text: string) => { return { + ...baseSyntheticEvent(), nativeEvent: { text, target: 0, eventCount: 0 }, - currentTarget: {}, - target: {}, }; }, @@ -22,9 +22,8 @@ export const TextInputEventBuilder = { */ keyPress: (key: string) => { return { + ...baseSyntheticEvent(), nativeEvent: { key }, - currentTarget: {}, - target: {}, }; }, @@ -35,9 +34,8 @@ export const TextInputEventBuilder = { */ submitEditing: (text: string) => { return { + ...baseSyntheticEvent(), nativeEvent: { text, target: 0 }, - currentTarget: {}, - target: {}, }; }, @@ -48,9 +46,8 @@ export const TextInputEventBuilder = { */ endEditing: (text: string) => { return { + ...baseSyntheticEvent(), nativeEvent: { text, target: 0 }, - currentTarget: {}, - target: {}, }; }, @@ -61,9 +58,8 @@ export const TextInputEventBuilder = { */ selectionChange: ({ start, end }: TextRange) => { return { + ...baseSyntheticEvent(), nativeEvent: { selection: { start, end } }, - currentTarget: {}, - target: {}, }; }, @@ -74,14 +70,13 @@ export const TextInputEventBuilder = { */ textInput: (text: string, previousText: string) => { return { + ...baseSyntheticEvent(), nativeEvent: { text, previousText, range: { start: text.length, end: text.length }, target: 0, }, - currentTarget: {}, - target: {}, }; }, @@ -92,9 +87,8 @@ export const TextInputEventBuilder = { */ contentSizeChange: ({ width, height }: ContentSize) => { return { + ...baseSyntheticEvent(), nativeEvent: { contentSize: { width, height }, target: 0 }, - currentTarget: {}, - target: {}, }; }, }; From 4e56ce7902849ece62900b28efed87e1f005a4d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Jastrze=CC=A8bski?= Date: Wed, 24 Apr 2024 22:03:55 +0200 Subject: [PATCH 2/5] chore: update snapshots --- .../__snapshots__/clear.test.tsx.snap | 72 +++++++++ .../__snapshots__/longPress.test.tsx.snap | 2 + .../__snapshots__/press.test.tsx.snap | 6 + .../scroll-to-flat-list.test.tsx.snap | 15 ++ .../__snapshots__/scroll-to.test.tsx.snap | 15 ++ .../__snapshots__/type-managed.test.tsx.snap | 80 ++++++++++ .../__snapshots__/type.test.tsx.snap | 148 ++++++++++++++++++ 7 files changed, 338 insertions(+) diff --git a/src/user-event/__tests__/__snapshots__/clear.test.tsx.snap b/src/user-event/__tests__/__snapshots__/clear.test.tsx.snap index c0d849e4c..94c0801f7 100644 --- a/src/user-event/__tests__/__snapshots__/clear.test.tsx.snap +++ b/src/user-event/__tests__/__snapshots__/clear.test.tsx.snap @@ -9,6 +9,9 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -22,6 +25,9 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "start": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -32,6 +38,9 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "nativeEvent": { "key": "Backspace", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -44,6 +53,9 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "target": 0, "text": "", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -61,6 +73,9 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "start": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -72,6 +87,9 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "target": 0, "text": "", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -82,6 +100,9 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -97,6 +118,9 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -110,6 +134,9 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "start": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -120,6 +147,9 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "nativeEvent": { "key": "Backspace", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -132,6 +162,9 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "target": 0, "text": "", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -149,6 +182,9 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "start": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -160,6 +196,9 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "target": 0, "text": "", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -170,6 +209,9 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -186,6 +228,9 @@ How are you?" multiline: true, 1`] = ` "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -199,6 +244,9 @@ How are you?" multiline: true, 1`] = ` "start": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -209,6 +257,9 @@ How are you?" multiline: true, 1`] = ` "nativeEvent": { "key": "Backspace", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -226,6 +277,9 @@ How are you?", "target": 0, "text": "", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -238,6 +292,9 @@ How are you?", "target": 0, "text": "", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -255,6 +312,9 @@ How are you?", "start": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -269,6 +329,9 @@ How are you?", }, "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -280,6 +343,9 @@ How are you?", "target": 0, "text": "", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -290,6 +356,9 @@ How are you?", "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -310,6 +379,9 @@ exports[`clear() works when not all events have handlers 1`] = ` "target": 0, "text": "", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, diff --git a/src/user-event/press/__tests__/__snapshots__/longPress.test.tsx.snap b/src/user-event/press/__tests__/__snapshots__/longPress.test.tsx.snap index 7ff43a1bf..d79002a53 100644 --- a/src/user-event/press/__tests__/__snapshots__/longPress.test.tsx.snap +++ b/src/user-event/press/__tests__/__snapshots__/longPress.test.tsx.snap @@ -23,6 +23,8 @@ exports[`userEvent.longPress with fake timers calls onLongPress if the delayLong "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, diff --git a/src/user-event/press/__tests__/__snapshots__/press.test.tsx.snap b/src/user-event/press/__tests__/__snapshots__/press.test.tsx.snap index 48c109876..c5adce07d 100644 --- a/src/user-event/press/__tests__/__snapshots__/press.test.tsx.snap +++ b/src/user-event/press/__tests__/__snapshots__/press.test.tsx.snap @@ -23,6 +23,8 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -47,6 +49,8 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -71,6 +75,8 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, diff --git a/src/user-event/scroll/__tests__/__snapshots__/scroll-to-flat-list.test.tsx.snap b/src/user-event/scroll/__tests__/__snapshots__/scroll-to-flat-list.test.tsx.snap index d8131e435..eb2e2ba95 100644 --- a/src/user-event/scroll/__tests__/__snapshots__/scroll-to-flat-list.test.tsx.snap +++ b/src/user-event/scroll/__tests__/__snapshots__/scroll-to-flat-list.test.tsx.snap @@ -32,6 +32,9 @@ exports[`scrollTo() with FlatList supports vertical drag scroll: scrollTo({ y: 1 "y": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -65,6 +68,9 @@ exports[`scrollTo() with FlatList supports vertical drag scroll: scrollTo({ y: 1 "y": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -98,6 +104,9 @@ exports[`scrollTo() with FlatList supports vertical drag scroll: scrollTo({ y: 1 "y": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -131,6 +140,9 @@ exports[`scrollTo() with FlatList supports vertical drag scroll: scrollTo({ y: 1 "y": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -164,6 +176,9 @@ exports[`scrollTo() with FlatList supports vertical drag scroll: scrollTo({ y: 1 "y": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, diff --git a/src/user-event/scroll/__tests__/__snapshots__/scroll-to.test.tsx.snap b/src/user-event/scroll/__tests__/__snapshots__/scroll-to.test.tsx.snap index 7055f54c8..0e278de6d 100644 --- a/src/user-event/scroll/__tests__/__snapshots__/scroll-to.test.tsx.snap +++ b/src/user-event/scroll/__tests__/__snapshots__/scroll-to.test.tsx.snap @@ -32,6 +32,9 @@ exports[`scrollTo() supports vertical drag scroll: scrollTo({ y: 100 }) 1`] = ` "y": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -65,6 +68,9 @@ exports[`scrollTo() supports vertical drag scroll: scrollTo({ y: 100 }) 1`] = ` "y": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -98,6 +104,9 @@ exports[`scrollTo() supports vertical drag scroll: scrollTo({ y: 100 }) 1`] = ` "y": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -131,6 +140,9 @@ exports[`scrollTo() supports vertical drag scroll: scrollTo({ y: 100 }) 1`] = ` "y": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -164,6 +176,9 @@ exports[`scrollTo() supports vertical drag scroll: scrollTo({ y: 100 }) 1`] = ` "y": 0, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, diff --git a/src/user-event/type/__tests__/__snapshots__/type-managed.test.tsx.snap b/src/user-event/type/__tests__/__snapshots__/type-managed.test.tsx.snap index 6fad62214..353fb6a20 100644 --- a/src/user-event/type/__tests__/__snapshots__/type-managed.test.tsx.snap +++ b/src/user-event/type/__tests__/__snapshots__/type-managed.test.tsx.snap @@ -20,6 +20,8 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -30,6 +32,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -51,6 +56,8 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -61,6 +68,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "nativeEvent": { "key": "W", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -73,6 +83,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "target": 0, "text": "W", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -90,6 +103,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "start": 1, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -100,6 +116,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "nativeEvent": { "key": "o", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -112,6 +131,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "target": 0, "text": "Wo", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -129,6 +151,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "start": 2, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -139,6 +164,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "nativeEvent": { "key": "w", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -151,6 +179,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "target": 0, "text": "Wow", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -168,6 +199,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "start": 3, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -179,6 +213,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "target": 0, "text": "Wow", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -189,6 +226,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -215,6 +255,8 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -225,6 +267,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -246,6 +291,8 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -256,6 +303,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "nativeEvent": { "key": "A", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -268,6 +318,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "target": 0, "text": "XXXA", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -285,6 +338,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "start": 4, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -295,6 +351,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "nativeEvent": { "key": "B", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -307,6 +366,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "target": 0, "text": "XXXB", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -324,6 +386,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "start": 4, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -334,6 +399,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "nativeEvent": { "key": "C", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -346,6 +414,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "target": 0, "text": "XXXC", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -363,6 +434,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "start": 4, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -374,6 +448,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "target": 0, "text": "XXX", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -384,6 +461,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, diff --git a/src/user-event/type/__tests__/__snapshots__/type.test.tsx.snap b/src/user-event/type/__tests__/__snapshots__/type.test.tsx.snap index 8873df672..2995e6d42 100644 --- a/src/user-event/type/__tests__/__snapshots__/type.test.tsx.snap +++ b/src/user-event/type/__tests__/__snapshots__/type.test.tsx.snap @@ -20,6 +20,8 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -30,6 +32,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -51,6 +56,8 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -61,6 +68,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "nativeEvent": { "key": "Backspace", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -73,6 +83,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "target": 0, "text": "xx", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -90,6 +103,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "start": 2, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -100,6 +116,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "nativeEvent": { "key": "a", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -112,6 +131,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "target": 0, "text": "xxa", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -129,6 +151,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "start": 3, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -140,6 +165,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "target": 0, "text": "xxa", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -150,6 +178,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -176,6 +207,8 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -186,6 +219,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -207,6 +243,8 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -217,6 +255,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "nativeEvent": { "key": "a", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -229,6 +270,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "target": 0, "text": "a", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -246,6 +290,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "start": 1, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -256,6 +303,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "nativeEvent": { "key": "b", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -268,6 +318,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "target": 0, "text": "ab", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -285,6 +338,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "start": 2, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -295,6 +351,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "nativeEvent": { "key": "c", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -307,6 +366,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "target": 0, "text": "abc", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -324,6 +386,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "start": 3, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -335,6 +400,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "target": 0, "text": "abc", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -345,6 +413,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -371,6 +442,8 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -381,6 +454,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -402,6 +478,8 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -412,6 +490,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "nativeEvent": { "key": "a", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -424,6 +505,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "target": 0, "text": "xxxa", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -441,6 +525,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "start": 4, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -451,6 +538,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "nativeEvent": { "key": "b", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -463,6 +553,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "target": 0, "text": "xxxab", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -480,6 +573,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "start": 5, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -491,6 +587,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "target": 0, "text": "xxxab", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -501,6 +600,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -527,6 +629,8 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -537,6 +641,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -558,6 +665,8 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "touches": [], }, "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -568,6 +677,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "nativeEvent": { "key": "Enter", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -585,6 +697,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "text": " ", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -598,6 +713,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "text": " ", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -616,6 +734,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "start": 1, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -630,6 +751,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` }, "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -640,6 +764,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "nativeEvent": { "key": "Enter", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -659,6 +786,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` ", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -673,6 +803,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` ", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -692,6 +825,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "start": 2, }, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -706,6 +842,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` }, "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -719,6 +858,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` ", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -729,6 +871,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "nativeEvent": { "target": 0, }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, @@ -757,6 +902,9 @@ exports[`type() works when not all events have handlers: input: "abc" 1`] = ` "target": 0, "text": "abc", }, + "persist": [Function], + "preventDefault": [Function], + "stopPropagation": [Function], "target": {}, }, }, From dcbeaccb3c8eaf01050a430f289ace8bb26e5502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Jastrze=CC=A8bski?= Date: Wed, 24 Apr 2024 22:29:31 +0200 Subject: [PATCH 3/5] refactor: self code review --- src/user-event/event-builder/base.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/user-event/event-builder/base.ts b/src/user-event/event-builder/base.ts index bd798a257..7a2e5ba10 100644 --- a/src/user-event/event-builder/base.ts +++ b/src/user-event/event-builder/base.ts @@ -1,9 +1,15 @@ -export function baseSyntheticEvent() { +import { BaseSyntheticEvent } from 'react'; + +/** Builds base syntentic event stub, with prop values as inspected in RN runtime. */ +export function baseSyntheticEvent(): Partial> { return { currentTarget: {}, target: {}, preventDefault: () => {}, + isDefaultPrevented: () => false, stopPropagation: () => {}, + isPropagationStopped: () => false, persist: () => {}, + timeStamp: 0, }; } From 73310a94ce1eadf1428723d2c9411e3628aee0dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Jastrze=CC=A8bski?= Date: Wed, 24 Apr 2024 22:35:33 +0200 Subject: [PATCH 4/5] refactor: improvements --- .../__snapshots__/clear.test.tsx.snap | 96 ++++++++ src/user-event/event-builder/base.ts | 2 + .../__snapshots__/longPress.test.tsx.snap | 4 + .../__snapshots__/press.test.tsx.snap | 12 + .../scroll-to-flat-list.test.tsx.snap | 20 ++ .../__snapshots__/scroll-to.test.tsx.snap | 20 ++ .../__snapshots__/type-managed.test.tsx.snap | 112 ++++++++++ .../__snapshots__/type.test.tsx.snap | 208 ++++++++++++++++++ src/user-event/type/__tests__/type.test.tsx | 2 +- 9 files changed, 475 insertions(+), 1 deletion(-) diff --git a/src/user-event/__tests__/__snapshots__/clear.test.tsx.snap b/src/user-event/__tests__/__snapshots__/clear.test.tsx.snap index 94c0801f7..7ac08d0b5 100644 --- a/src/user-event/__tests__/__snapshots__/clear.test.tsx.snap +++ b/src/user-event/__tests__/__snapshots__/clear.test.tsx.snap @@ -6,6 +6,9 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "name": "focus", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -13,12 +16,16 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 6, @@ -29,12 +36,16 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "Backspace", }, @@ -42,12 +53,16 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -57,6 +72,7 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -67,6 +83,9 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 0, @@ -77,12 +96,16 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "endEditing", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, "text": "", @@ -91,12 +114,16 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "blur", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -104,6 +131,7 @@ exports[`clear() supports basic case: value: "Hello! 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] @@ -115,6 +143,9 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "name": "focus", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -122,12 +153,16 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 14, @@ -138,12 +173,16 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "Backspace", }, @@ -151,12 +190,16 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -166,6 +209,7 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -176,6 +220,9 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 0, @@ -186,12 +233,16 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "endEditing", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, "text": "", @@ -200,12 +251,16 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "blur", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -213,6 +268,7 @@ exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] @@ -225,6 +281,9 @@ How are you?" multiline: true, 1`] = ` "name": "focus", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -232,12 +291,16 @@ How are you?" multiline: true, 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 25, @@ -248,12 +311,16 @@ How are you?" multiline: true, 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "Backspace", }, @@ -261,12 +328,16 @@ How are you?" multiline: true, 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "textInput", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "previousText": "Hello World! How are you?", @@ -281,12 +352,16 @@ How are you?", "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -296,6 +371,7 @@ How are you?", "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -306,6 +382,9 @@ How are you?", "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 0, @@ -316,12 +395,16 @@ How are you?", "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "contentSizeChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentSize": { "height": 16, @@ -333,12 +416,16 @@ How are you?", "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "endEditing", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, "text": "", @@ -347,12 +434,16 @@ How are you?", "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "blur", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -360,6 +451,7 @@ How are you?", "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] @@ -375,6 +467,9 @@ exports[`clear() works when not all events have handlers 1`] = ` "name": "endEditing", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, "text": "", @@ -383,6 +478,7 @@ exports[`clear() works when not all events have handlers 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] diff --git a/src/user-event/event-builder/base.ts b/src/user-event/event-builder/base.ts index 7a2e5ba10..0de21e8b7 100644 --- a/src/user-event/event-builder/base.ts +++ b/src/user-event/event-builder/base.ts @@ -10,6 +10,8 @@ export function baseSyntheticEvent(): Partial {}, isPropagationStopped: () => false, persist: () => {}, + // @ts-expect-error: `isPersistent` is not a standard prop, but it's used in RN runtime. See: https://react.dev/reference/react-dom/components/common#react-event-object-methods + isPersistent: () => false, timeStamp: 0, }; } diff --git a/src/user-event/press/__tests__/__snapshots__/longPress.test.tsx.snap b/src/user-event/press/__tests__/__snapshots__/longPress.test.tsx.snap index d79002a53..fa31b7a34 100644 --- a/src/user-event/press/__tests__/__snapshots__/longPress.test.tsx.snap +++ b/src/user-event/press/__tests__/__snapshots__/longPress.test.tsx.snap @@ -11,6 +11,9 @@ exports[`userEvent.longPress with fake timers calls onLongPress if the delayLong "dispatchConfig": { "registrationName": "onResponderGrant", }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -26,6 +29,7 @@ exports[`userEvent.longPress with fake timers calls onLongPress if the delayLong "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] diff --git a/src/user-event/press/__tests__/__snapshots__/press.test.tsx.snap b/src/user-event/press/__tests__/__snapshots__/press.test.tsx.snap index c5adce07d..ceb2803f3 100644 --- a/src/user-event/press/__tests__/__snapshots__/press.test.tsx.snap +++ b/src/user-event/press/__tests__/__snapshots__/press.test.tsx.snap @@ -11,6 +11,9 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu "dispatchConfig": { "registrationName": "onResponderGrant", }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -26,6 +29,7 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -37,6 +41,9 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu "dispatchConfig": { "registrationName": "onResponderRelease", }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -52,6 +59,7 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -63,6 +71,9 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu "dispatchConfig": { "registrationName": "onResponderRelease", }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -78,6 +89,7 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] diff --git a/src/user-event/scroll/__tests__/__snapshots__/scroll-to-flat-list.test.tsx.snap b/src/user-event/scroll/__tests__/__snapshots__/scroll-to-flat-list.test.tsx.snap index eb2e2ba95..faa7ee49d 100644 --- a/src/user-event/scroll/__tests__/__snapshots__/scroll-to-flat-list.test.tsx.snap +++ b/src/user-event/scroll/__tests__/__snapshots__/scroll-to-flat-list.test.tsx.snap @@ -6,6 +6,9 @@ exports[`scrollTo() with FlatList supports vertical drag scroll: scrollTo({ y: 1 "name": "scrollBeginDrag", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentInset": { "bottom": 0, @@ -36,12 +39,16 @@ exports[`scrollTo() with FlatList supports vertical drag scroll: scrollTo({ y: 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "scroll", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentInset": { "bottom": 0, @@ -72,12 +79,16 @@ exports[`scrollTo() with FlatList supports vertical drag scroll: scrollTo({ y: 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "scroll", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentInset": { "bottom": 0, @@ -108,12 +119,16 @@ exports[`scrollTo() with FlatList supports vertical drag scroll: scrollTo({ y: 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "scroll", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentInset": { "bottom": 0, @@ -144,12 +159,16 @@ exports[`scrollTo() with FlatList supports vertical drag scroll: scrollTo({ y: 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "scrollEndDrag", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentInset": { "bottom": 0, @@ -180,6 +199,7 @@ exports[`scrollTo() with FlatList supports vertical drag scroll: scrollTo({ y: 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] diff --git a/src/user-event/scroll/__tests__/__snapshots__/scroll-to.test.tsx.snap b/src/user-event/scroll/__tests__/__snapshots__/scroll-to.test.tsx.snap index 0e278de6d..60fac01aa 100644 --- a/src/user-event/scroll/__tests__/__snapshots__/scroll-to.test.tsx.snap +++ b/src/user-event/scroll/__tests__/__snapshots__/scroll-to.test.tsx.snap @@ -6,6 +6,9 @@ exports[`scrollTo() supports vertical drag scroll: scrollTo({ y: 100 }) 1`] = ` "name": "scrollBeginDrag", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentInset": { "bottom": 0, @@ -36,12 +39,16 @@ exports[`scrollTo() supports vertical drag scroll: scrollTo({ y: 100 }) 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "scroll", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentInset": { "bottom": 0, @@ -72,12 +79,16 @@ exports[`scrollTo() supports vertical drag scroll: scrollTo({ y: 100 }) 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "scroll", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentInset": { "bottom": 0, @@ -108,12 +119,16 @@ exports[`scrollTo() supports vertical drag scroll: scrollTo({ y: 100 }) 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "scroll", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentInset": { "bottom": 0, @@ -144,12 +159,16 @@ exports[`scrollTo() supports vertical drag scroll: scrollTo({ y: 100 }) 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "scrollEndDrag", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentInset": { "bottom": 0, @@ -180,6 +199,7 @@ exports[`scrollTo() supports vertical drag scroll: scrollTo({ y: 100 }) 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] diff --git a/src/user-event/type/__tests__/__snapshots__/type-managed.test.tsx.snap b/src/user-event/type/__tests__/__snapshots__/type-managed.test.tsx.snap index 353fb6a20..ac3a21865 100644 --- a/src/user-event/type/__tests__/__snapshots__/type-managed.test.tsx.snap +++ b/src/user-event/type/__tests__/__snapshots__/type-managed.test.tsx.snap @@ -8,6 +8,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "currentTarget": { "measure": [Function], }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -23,12 +26,16 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "focus", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -36,6 +43,7 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -44,6 +52,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "currentTarget": { "measure": [Function], }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -59,12 +70,16 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "W", }, @@ -72,12 +87,16 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -87,6 +106,7 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -97,6 +117,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 1, @@ -107,12 +130,16 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "o", }, @@ -120,12 +147,16 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -135,6 +166,7 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -145,6 +177,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 2, @@ -155,12 +190,16 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "w", }, @@ -168,12 +207,16 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -183,6 +226,7 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -193,6 +237,9 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 3, @@ -203,12 +250,16 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "endEditing", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, "text": "Wow", @@ -217,12 +268,16 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "blur", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -230,6 +285,7 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] @@ -243,6 +299,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "currentTarget": { "measure": [Function], }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -258,12 +317,16 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "focus", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -271,6 +334,7 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -279,6 +343,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "currentTarget": { "measure": [Function], }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -294,12 +361,16 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "A", }, @@ -307,12 +378,16 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -322,6 +397,7 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -332,6 +408,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 4, @@ -342,12 +421,16 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "B", }, @@ -355,12 +438,16 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -370,6 +457,7 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -380,6 +468,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 4, @@ -390,12 +481,16 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "C", }, @@ -403,12 +498,16 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -418,6 +517,7 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -428,6 +528,9 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 4, @@ -438,12 +541,16 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "endEditing", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, "text": "XXX", @@ -452,12 +559,16 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "blur", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -465,6 +576,7 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC" "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] diff --git a/src/user-event/type/__tests__/__snapshots__/type.test.tsx.snap b/src/user-event/type/__tests__/__snapshots__/type.test.tsx.snap index 2995e6d42..b75157f8f 100644 --- a/src/user-event/type/__tests__/__snapshots__/type.test.tsx.snap +++ b/src/user-event/type/__tests__/__snapshots__/type.test.tsx.snap @@ -8,6 +8,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "currentTarget": { "measure": [Function], }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -23,12 +26,16 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "focus", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -36,6 +43,7 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -44,6 +52,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "currentTarget": { "measure": [Function], }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -59,12 +70,16 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "Backspace", }, @@ -72,12 +87,16 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -87,6 +106,7 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -97,6 +117,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 2, @@ -107,12 +130,16 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "a", }, @@ -120,12 +147,16 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -135,6 +166,7 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -145,6 +177,9 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 3, @@ -155,12 +190,16 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "endEditing", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, "text": "xxa", @@ -169,12 +208,16 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "blur", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -182,6 +225,7 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1 "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] @@ -195,6 +239,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "currentTarget": { "measure": [Function], }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -210,12 +257,16 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "focus", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -223,6 +274,7 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -231,6 +283,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "currentTarget": { "measure": [Function], }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -246,12 +301,16 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "a", }, @@ -259,12 +318,16 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -274,6 +337,7 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -284,6 +348,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 1, @@ -294,12 +361,16 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "b", }, @@ -307,12 +378,16 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -322,6 +397,7 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -332,6 +408,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 2, @@ -342,12 +421,16 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "c", }, @@ -355,12 +438,16 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -370,6 +457,7 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -380,6 +468,9 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 3, @@ -390,12 +481,16 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "endEditing", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, "text": "abc", @@ -404,12 +499,16 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "blur", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -417,6 +516,7 @@ exports[`type() supports basic case: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] @@ -430,6 +530,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "currentTarget": { "measure": [Function], }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -445,12 +548,16 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "focus", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -458,6 +565,7 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -466,6 +574,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "currentTarget": { "measure": [Function], }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -481,12 +592,16 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "a", }, @@ -494,12 +609,16 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -509,6 +628,7 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -519,6 +639,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 4, @@ -529,12 +652,16 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "b", }, @@ -542,12 +669,16 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -557,6 +688,7 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -567,6 +699,9 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 5, @@ -577,12 +712,16 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "endEditing", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, "text": "xxxab", @@ -591,12 +730,16 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "blur", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -604,6 +747,7 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`] "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] @@ -617,6 +761,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "currentTarget": { "measure": [Function], }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -632,12 +779,16 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "focus", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -645,6 +796,7 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -653,6 +805,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "currentTarget": { "measure": [Function], }, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "changedTouches": [], "identifier": 0, @@ -668,12 +823,16 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "Enter", }, @@ -681,12 +840,16 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "textInput", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "previousText": "", "range": { @@ -701,12 +864,16 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -717,6 +884,7 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -728,6 +896,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 1, @@ -738,12 +909,16 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "contentSizeChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentSize": { "height": 32, @@ -755,12 +930,16 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "keyPress", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "key": "Enter", }, @@ -768,12 +947,16 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "textInput", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "previousText": " ", @@ -790,12 +973,16 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "change", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "eventCount": 0, "target": 0, @@ -807,6 +994,7 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { @@ -819,6 +1007,9 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "name": "selectionChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "selection": { "end": 2, @@ -829,12 +1020,16 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "contentSizeChange", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "contentSize": { "height": 48, @@ -846,12 +1041,16 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "endEditing", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, "text": " @@ -862,12 +1061,16 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, { "name": "blur", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, }, @@ -875,6 +1078,7 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] @@ -898,6 +1102,9 @@ exports[`type() works when not all events have handlers: input: "abc" 1`] = ` "name": "endEditing", "payload": { "currentTarget": {}, + "isDefaultPrevented": [Function], + "isPersistent": [Function], + "isPropagationStopped": [Function], "nativeEvent": { "target": 0, "text": "abc", @@ -906,6 +1113,7 @@ exports[`type() works when not all events have handlers: input: "abc" 1`] = ` "preventDefault": [Function], "stopPropagation": [Function], "target": {}, + "timeStamp": 0, }, }, ] diff --git a/src/user-event/type/__tests__/type.test.tsx b/src/user-event/type/__tests__/type.test.tsx index ad3564724..fa9c7e9c8 100644 --- a/src/user-event/type/__tests__/type.test.tsx +++ b/src/user-event/type/__tests__/type.test.tsx @@ -242,7 +242,7 @@ describe('type()', () => { ]); expect(events[7].name).toBe('submitEditing'); - expect(events[7].payload).toEqual({ + expect(events[7].payload).toMatchObject({ nativeEvent: { text: 'a', target: 0 }, currentTarget: {}, target: {}, From 4be7e96c787f43560587684aeb8e43627eca5349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Jastrze=CC=A8bski?= Date: Wed, 24 Apr 2024 22:42:59 +0200 Subject: [PATCH 5/5] chore: add test --- src/user-event/type/__tests__/type.test.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/user-event/type/__tests__/type.test.tsx b/src/user-event/type/__tests__/type.test.tsx index fa9c7e9c8..4918e3f2a 100644 --- a/src/user-event/type/__tests__/type.test.tsx +++ b/src/user-event/type/__tests__/type.test.tsx @@ -321,4 +321,21 @@ describe('type()', () => { const eventNames = events.map((event) => event.name); expect(eventNames).toEqual(['focus', 'changeText', 'changeText', 'changeText', 'blur']); }); + + // See: https://github.com/callstack/react-native-testing-library/issues/1588 + it('can call "persist()" on "onKeyPress" event handler', async () => { + const handleKeyPress = jest.fn(); + render( + { + e.persist(); + handleKeyPress(); + }} + />, + ); + + await userEvent.type(screen.getByTestId('input'), 'abc'); + expect(handleKeyPress).toHaveBeenCalledTimes(3); + }); });