Skip to content

Commit 3cee5cf

Browse files
authored
Replace target in snapshot, so it doesn't keep changing (#15924) (#15929)
* Replace target in snapshot, so it doesn't keep changing * fix * snapshot
1 parent 3822b3e commit 3cee5cf

File tree

3 files changed

+76
-67
lines changed

3 files changed

+76
-67
lines changed

packages/@react-native-windows/tester/src/js/examples-win/Pointer/PointerClickEventsExample.windows.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import type {RNTesterModuleExample} from '../../types/RNTesterTypes';
1212

1313
const React = require('react');
14-
import {Pressable, StyleSheet, View} from 'react-native';
14+
import {StyleSheet, View} from 'react-native';
1515
import RNTesterText from '../../components/RNTesterText';
1616

1717
function PointerClickEventsExample(): React.Node {

packages/e2e-test-app-fabric/test/PointerClickEventsTest.test.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ describe('Pointer onClick Test', () => {
4444
);
4545

4646
const text = await stateText.getText();
47-
expect(text).toMatchSnapshot();
47+
const nativeEvent = JSON.parse(text.split('onClick.nativeEvent: ')[1]);
48+
expect(typeof nativeEvent.target).toBe('number');
49+
nativeEvent.target = '<target>';
50+
expect(nativeEvent).toMatchSnapshot();
4851
});
4952
test('onAuxClick reports correct native event properties on middle click', async () => {
5053
const component = await app.findElementByTestID('pointer-click-target');
@@ -70,7 +73,10 @@ describe('Pointer onClick Test', () => {
7073
);
7174

7275
const text = await stateText.getText();
73-
expect(text).toMatchSnapshot();
76+
const nativeEvent = JSON.parse(text.split('onAuxClick.nativeEvent: ')[1]);
77+
expect(typeof nativeEvent.target).toBe('number');
78+
nativeEvent.target = '<target>';
79+
expect(nativeEvent).toMatchSnapshot();
7480
});
7581
test('onAuxClick reports correct native event properties on right click', async () => {
7682
const component = await app.findElementByTestID('pointer-click-target');
@@ -96,6 +102,9 @@ describe('Pointer onClick Test', () => {
96102
);
97103

98104
const text = await stateText.getText();
99-
expect(text).toMatchSnapshot();
105+
const nativeEvent = JSON.parse(text.split('onAuxClick.nativeEvent: ')[1]);
106+
expect(typeof nativeEvent.target).toBe('number');
107+
nativeEvent.target = '<target>';
108+
expect(nativeEvent).toMatchSnapshot();
100109
});
101110
});
Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,100 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`Pointer onClick Test onAuxClick reports correct native event properties on middle click 1`] = `
4-
"onAuxClick.nativeEvent: {
5-
"pointerId": 1,
6-
"pressure": 0,
7-
"pointerType": "mouse",
4+
{
5+
"altKey": false,
6+
"button": 1,
7+
"buttons": 0,
88
"clientX": 110,
99
"clientY": 165,
10-
"x": 110,
11-
"y": 165,
10+
"ctrlKey": false,
11+
"detail": 0,
12+
"height": 0,
13+
"isPrimary": true,
14+
"metaKey": false,
15+
"offsetX": 100,
16+
"offsetY": 99,
1217
"pageX": 110,
1318
"pageY": 165,
19+
"pointerId": 1,
20+
"pointerType": "mouse",
21+
"pressure": 0,
1422
"screenX": 100,
1523
"screenY": 99,
16-
"offsetX": 100,
17-
"offsetY": 99,
18-
"width": 0,
19-
"height": 0,
24+
"shiftKey": false,
25+
"tangentialPressure": 0,
26+
"target": "<target>",
2027
"tiltX": 0,
2128
"tiltY": 0,
22-
"detail": 0,
23-
"buttons": 0,
24-
"tangentialPressure": 0,
2529
"twist": 0,
26-
"ctrlKey": false,
27-
"shiftKey": false,
28-
"altKey": false,
29-
"metaKey": false,
30-
"isPrimary": true,
31-
"button": 1,
32-
"target": 1272
33-
}"
30+
"width": 0,
31+
"x": 110,
32+
"y": 165,
33+
}
3434
`;
3535

3636
exports[`Pointer onClick Test onAuxClick reports correct native event properties on right click 1`] = `
37-
"onAuxClick.nativeEvent: {
38-
"pointerId": 1,
39-
"pressure": 0,
40-
"pointerType": "mouse",
37+
{
38+
"altKey": false,
39+
"button": 2,
40+
"buttons": 0,
4141
"clientX": 110,
4242
"clientY": 165,
43-
"x": 110,
44-
"y": 165,
43+
"ctrlKey": false,
44+
"detail": 0,
45+
"height": 0,
46+
"isPrimary": true,
47+
"metaKey": false,
48+
"offsetX": 100,
49+
"offsetY": 99,
4550
"pageX": 110,
4651
"pageY": 165,
52+
"pointerId": 1,
53+
"pointerType": "mouse",
54+
"pressure": 0,
4755
"screenX": 100,
4856
"screenY": 99,
49-
"offsetX": 100,
50-
"offsetY": 99,
51-
"width": 0,
52-
"height": 0,
57+
"shiftKey": false,
58+
"tangentialPressure": 0,
59+
"target": "<target>",
5360
"tiltX": 0,
5461
"tiltY": 0,
55-
"detail": 0,
56-
"buttons": 0,
57-
"tangentialPressure": 0,
5862
"twist": 0,
59-
"ctrlKey": false,
60-
"shiftKey": false,
61-
"altKey": false,
62-
"metaKey": false,
63-
"isPrimary": true,
64-
"button": 2,
65-
"target": 1272
66-
}"
63+
"width": 0,
64+
"x": 110,
65+
"y": 165,
66+
}
6767
`;
6868

6969
exports[`Pointer onClick Test onClick reports correct native event properties on left click 1`] = `
70-
"onClick.nativeEvent: {
71-
"pointerId": 1,
72-
"pressure": 0,
73-
"pointerType": "mouse",
70+
{
71+
"altKey": false,
72+
"button": 0,
73+
"buttons": 0,
7474
"clientX": 110,
7575
"clientY": 165,
76-
"x": 110,
77-
"y": 165,
76+
"ctrlKey": false,
77+
"detail": 0,
78+
"height": 0,
79+
"isPrimary": true,
80+
"metaKey": false,
81+
"offsetX": 100,
82+
"offsetY": 99,
7883
"pageX": 110,
7984
"pageY": 165,
85+
"pointerId": 1,
86+
"pointerType": "mouse",
87+
"pressure": 0,
8088
"screenX": 100,
8189
"screenY": 99,
82-
"offsetX": 100,
83-
"offsetY": 99,
84-
"width": 0,
85-
"height": 0,
90+
"shiftKey": false,
91+
"tangentialPressure": 0,
92+
"target": "<target>",
8693
"tiltX": 0,
8794
"tiltY": 0,
88-
"detail": 0,
89-
"buttons": 0,
90-
"tangentialPressure": 0,
9195
"twist": 0,
92-
"ctrlKey": false,
93-
"shiftKey": false,
94-
"altKey": false,
95-
"metaKey": false,
96-
"isPrimary": true,
97-
"button": 0,
98-
"target": 1272
99-
}"
96+
"width": 0,
97+
"x": 110,
98+
"y": 165,
99+
}
100100
`;

0 commit comments

Comments
 (0)