Skip to content

fix(user-event): Decouple press events from Jest dependency #1571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/user-event/event-builder/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function touch() {
timestamp: Date.now(),
touches: [],
},
persist: jest.fn(),
currentTarget: { measure: jest.fn() },
persist: () => {},
currentTarget: { measure: () => {} },
target: {},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,7 @@ exports[`userEvent.longPress with fake timers calls onLongPress if the delayLong
"name": "longPress",
"payload": {
"currentTarget": {
"measure": [MockFunction] {
"calls": [
[
[Function],
],
[
[Function],
],
],
"results": [
{
"type": "return",
"value": undefined,
},
{
"type": "return",
"value": undefined,
},
],
},
"measure": [Function],
},
"dispatchConfig": {
"registrationName": "onResponderGrant",
Expand All @@ -41,17 +22,7 @@ exports[`userEvent.longPress with fake timers calls onLongPress if the delayLong
"timestamp": 0,
"touches": [],
},
"persist": [MockFunction] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
},
"persist": [Function],
"target": {},
},
},
Expand Down
61 changes: 6 additions & 55 deletions src/user-event/press/__tests__/__snapshots__/press.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,7 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu
"name": "pressIn",
"payload": {
"currentTarget": {
"measure": [MockFunction] {
"calls": [
[
[Function],
],
[
[Function],
],
],
"results": [
{
"type": "return",
"value": undefined,
},
{
"type": "return",
"value": undefined,
},
],
},
"measure": [Function],
},
"dispatchConfig": {
"registrationName": "onResponderGrant",
Expand All @@ -41,25 +22,15 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu
"timestamp": 0,
"touches": [],
},
"persist": [MockFunction] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
},
"persist": [Function],
"target": {},
},
},
{
"name": "press",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"dispatchConfig": {
"registrationName": "onResponderRelease",
Expand All @@ -75,25 +46,15 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu
"timestamp": 0,
"touches": [],
},
"persist": [MockFunction] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
},
"persist": [Function],
"target": {},
},
},
{
"name": "pressOut",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"dispatchConfig": {
"registrationName": "onResponderRelease",
Expand All @@ -109,17 +70,7 @@ exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOu
"timestamp": 0,
"touches": [],
},
"persist": [MockFunction] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
},
"persist": [Function],
"target": {},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = `
"name": "pressIn",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"nativeEvent": {
"changedTouches": [],
Expand All @@ -19,7 +19,7 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = `
"timestamp": 100100100100,
"touches": [],
},
"persist": [MockFunction],
"persist": [Function],
"target": {},
},
},
Expand All @@ -37,7 +37,7 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = `
"name": "pressOut",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"nativeEvent": {
"changedTouches": [],
Expand All @@ -50,7 +50,7 @@ exports[`type() for managed TextInput supports basic case: input: "Wow" 1`] = `
"timestamp": 100100100100,
"touches": [],
},
"persist": [MockFunction],
"persist": [Function],
"target": {},
},
},
Expand Down Expand Up @@ -201,7 +201,7 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC"
"name": "pressIn",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"nativeEvent": {
"changedTouches": [],
Expand All @@ -214,7 +214,7 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC"
"timestamp": 100100100100,
"touches": [],
},
"persist": [MockFunction],
"persist": [Function],
"target": {},
},
},
Expand All @@ -232,7 +232,7 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC"
"name": "pressOut",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"nativeEvent": {
"changedTouches": [],
Expand All @@ -245,7 +245,7 @@ exports[`type() for managed TextInput supports rejecting TextInput: input: "ABC"
"timestamp": 100100100100,
"touches": [],
},
"persist": [MockFunction],
"persist": [Function],
"target": {},
},
},
Expand Down
32 changes: 16 additions & 16 deletions src/user-event/type/__tests__/__snapshots__/type.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1
"name": "pressIn",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"nativeEvent": {
"changedTouches": [],
Expand All @@ -19,7 +19,7 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1
"timestamp": 100100100100,
"touches": [],
},
"persist": [MockFunction],
"persist": [Function],
"target": {},
},
},
Expand All @@ -37,7 +37,7 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1
"name": "pressOut",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"nativeEvent": {
"changedTouches": [],
Expand All @@ -50,7 +50,7 @@ exports[`type() supports backspace: input: "{Backspace}a", defaultValue: "xxx" 1
"timestamp": 100100100100,
"touches": [],
},
"persist": [MockFunction],
"persist": [Function],
"target": {},
},
},
Expand Down Expand Up @@ -162,7 +162,7 @@ exports[`type() supports basic case: input: "abc" 1`] = `
"name": "pressIn",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"nativeEvent": {
"changedTouches": [],
Expand All @@ -175,7 +175,7 @@ exports[`type() supports basic case: input: "abc" 1`] = `
"timestamp": 100100100100,
"touches": [],
},
"persist": [MockFunction],
"persist": [Function],
"target": {},
},
},
Expand All @@ -193,7 +193,7 @@ exports[`type() supports basic case: input: "abc" 1`] = `
"name": "pressOut",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"nativeEvent": {
"changedTouches": [],
Expand All @@ -206,7 +206,7 @@ exports[`type() supports basic case: input: "abc" 1`] = `
"timestamp": 100100100100,
"touches": [],
},
"persist": [MockFunction],
"persist": [Function],
"target": {},
},
},
Expand Down Expand Up @@ -357,7 +357,7 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`]
"name": "pressIn",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"nativeEvent": {
"changedTouches": [],
Expand All @@ -370,7 +370,7 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`]
"timestamp": 100100100100,
"touches": [],
},
"persist": [MockFunction],
"persist": [Function],
"target": {},
},
},
Expand All @@ -388,7 +388,7 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`]
"name": "pressOut",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"nativeEvent": {
"changedTouches": [],
Expand All @@ -401,7 +401,7 @@ exports[`type() supports defaultValue prop: input: "ab", defaultValue: "xxx" 1`]
"timestamp": 100100100100,
"touches": [],
},
"persist": [MockFunction],
"persist": [Function],
"target": {},
},
},
Expand Down Expand Up @@ -513,7 +513,7 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = `
"name": "pressIn",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"nativeEvent": {
"changedTouches": [],
Expand All @@ -526,7 +526,7 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = `
"timestamp": 100100100100,
"touches": [],
},
"persist": [MockFunction],
"persist": [Function],
"target": {},
},
},
Expand All @@ -544,7 +544,7 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = `
"name": "pressOut",
"payload": {
"currentTarget": {
"measure": [MockFunction],
"measure": [Function],
},
"nativeEvent": {
"changedTouches": [],
Expand All @@ -557,7 +557,7 @@ exports[`type() supports multiline: input: "{Enter}\\n", multiline: true 1`] = `
"timestamp": 100100100100,
"touches": [],
},
"persist": [MockFunction],
"persist": [Function],
"target": {},
},
},
Expand Down
Loading