Skip to content

Commit

Permalink
refactor: move noisy snapshot to separate files
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjastrzebski committed Nov 30, 2023
1 parent ff55828 commit 96e2791
Show file tree
Hide file tree
Showing 4 changed files with 188 additions and 182 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`userEvent.longPress with fake timers calls onLongPress if the delayLongPress is the default one 1`] = `
[
{
"name": "longPress",
"payload": {
"currentTarget": {
"measure": [MockFunction] {
"calls": [
[
[Function],
],
[
[Function],
],
],
"results": [
{
"type": "return",
"value": undefined,
},
{
"type": "return",
"value": undefined,
},
],
},
},
"dispatchConfig": {
"registrationName": "onResponderGrant",
},
"nativeEvent": {
"changedTouches": [],
"identifier": 0,
"locationX": 0,
"locationY": 0,
"pageX": 0,
"pageY": 0,
"target": 0,
"timestamp": 0,
"touches": [],
},
"persist": [MockFunction] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
},
"target": {},
},
},
]
`;
127 changes: 127 additions & 0 deletions src/user-event/press/__tests__/__snapshots__/press.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`userEvent.press with fake timers calls onPressIn, onPress and onPressOut prop of touchable 1`] = `
[
{
"name": "pressIn",
"payload": {
"currentTarget": {
"measure": [MockFunction] {
"calls": [
[
[Function],
],
[
[Function],
],
],
"results": [
{
"type": "return",
"value": undefined,
},
{
"type": "return",
"value": undefined,
},
],
},
},
"dispatchConfig": {
"registrationName": "onResponderGrant",
},
"nativeEvent": {
"changedTouches": [],
"identifier": 0,
"locationX": 0,
"locationY": 0,
"pageX": 0,
"pageY": 0,
"target": 0,
"timestamp": 0,
"touches": [],
},
"persist": [MockFunction] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
},
"target": {},
},
},
{
"name": "press",
"payload": {
"currentTarget": {
"measure": [MockFunction],
},
"dispatchConfig": {
"registrationName": "onResponderRelease",
},
"nativeEvent": {
"changedTouches": [],
"identifier": 0,
"locationX": 0,
"locationY": 0,
"pageX": 0,
"pageY": 0,
"target": 0,
"timestamp": 0,
"touches": [],
},
"persist": [MockFunction] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
},
"target": {},
},
},
{
"name": "pressOut",
"payload": {
"currentTarget": {
"measure": [MockFunction],
},
"dispatchConfig": {
"registrationName": "onResponderRelease",
},
"nativeEvent": {
"changedTouches": [],
"identifier": 0,
"locationX": 0,
"locationY": 0,
"pageX": 0,
"pageY": 0,
"target": 0,
"timestamp": 0,
"touches": [],
},
"persist": [MockFunction] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
},
"target": {},
},
},
]
`;
58 changes: 1 addition & 57 deletions src/user-event/press/__tests__/longPress.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,63 +24,7 @@ describe('userEvent.longPress with fake timers', () => {
);
await user.longPress(screen.getByText('press me'));

expect(events).toMatchInlineSnapshot(`
[
{
"name": "longPress",
"payload": {
"currentTarget": {
"measure": [MockFunction] {
"calls": [
[
[Function],
],
[
[Function],
],
],
"results": [
{
"type": "return",
"value": undefined,
},
{
"type": "return",
"value": undefined,
},
],
},
},
"dispatchConfig": {
"registrationName": "onResponderGrant",
},
"nativeEvent": {
"changedTouches": [],
"identifier": 0,
"locationX": 0,
"locationY": 0,
"pageX": 0,
"pageY": 0,
"target": 0,
"timestamp": 0,
"touches": [],
},
"persist": [MockFunction] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
},
"target": {},
},
},
]
`);
expect(events).toMatchSnapshot();
});

test('calls onLongPress when duration is greater than specified delayLongPress', async () => {
Expand Down
126 changes: 1 addition & 125 deletions src/user-event/press/__tests__/press.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,131 +32,7 @@ describe('userEvent.press with fake timers', () => {
);
await user.press(screen.getByTestId('pressable'));

expect(events).toMatchInlineSnapshot(`
[
{
"name": "pressIn",
"payload": {
"currentTarget": {
"measure": [MockFunction] {
"calls": [
[
[Function],
],
[
[Function],
],
],
"results": [
{
"type": "return",
"value": undefined,
},
{
"type": "return",
"value": undefined,
},
],
},
},
"dispatchConfig": {
"registrationName": "onResponderGrant",
},
"nativeEvent": {
"changedTouches": [],
"identifier": 0,
"locationX": 0,
"locationY": 0,
"pageX": 0,
"pageY": 0,
"target": 0,
"timestamp": 0,
"touches": [],
},
"persist": [MockFunction] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
},
"target": {},
},
},
{
"name": "press",
"payload": {
"currentTarget": {
"measure": [MockFunction],
},
"dispatchConfig": {
"registrationName": "onResponderRelease",
},
"nativeEvent": {
"changedTouches": [],
"identifier": 0,
"locationX": 0,
"locationY": 0,
"pageX": 0,
"pageY": 0,
"target": 0,
"timestamp": 0,
"touches": [],
},
"persist": [MockFunction] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
},
"target": {},
},
},
{
"name": "pressOut",
"payload": {
"currentTarget": {
"measure": [MockFunction],
},
"dispatchConfig": {
"registrationName": "onResponderRelease",
},
"nativeEvent": {
"changedTouches": [],
"identifier": 0,
"locationX": 0,
"locationY": 0,
"pageX": 0,
"pageY": 0,
"target": 0,
"timestamp": 0,
"touches": [],
},
"persist": [MockFunction] {
"calls": [
[],
],
"results": [
{
"type": "return",
"value": undefined,
},
],
},
"target": {},
},
},
]
`);
expect(events).toMatchSnapshot();
});

test('does not trigger event when pressable is disabled', async () => {
Expand Down

0 comments on commit 96e2791

Please sign in to comment.