@@ -20,7 +20,6 @@ afterEach(async () => {
2020 await verifyNoErrorLogs ( ) ;
2121} ) ;
2222
23-
2423describe ( 'Pointer onClick Test' , ( ) => {
2524 test ( 'onClick reports correct native event properties on left click' , async ( ) => {
2625 const component = await app . findElementByTestID ( 'pointer-click-target' ) ;
@@ -33,7 +32,9 @@ describe('Pointer onClick Test', () => {
3332 await app . waitUntil (
3433 async ( ) => {
3534 const currentText = await stateText . getText ( ) ;
36- return currentText . includes ( '"button": 0' ) && currentText . includes ( 'onClick' ) ;
35+ return (
36+ currentText . includes ( '"button": 0' ) && currentText . includes ( 'onClick' )
37+ ) ;
3738 } ,
3839 {
3940 timeout : 5000 ,
@@ -43,7 +44,10 @@ describe('Pointer onClick Test', () => {
4344 ) ;
4445
4546 const text = await stateText . getText ( ) ;
46- 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 ( ) ;
4751 } ) ;
4852 test ( 'onAuxClick reports correct native event properties on middle click' , async ( ) => {
4953 const component = await app . findElementByTestID ( 'pointer-click-target' ) ;
@@ -56,7 +60,10 @@ describe('Pointer onClick Test', () => {
5660 await app . waitUntil (
5761 async ( ) => {
5862 const currentText = await stateText . getText ( ) ;
59- return currentText . includes ( '"button": 1' ) && currentText . includes ( 'onAuxClick' ) ;
63+ return (
64+ currentText . includes ( '"button": 1' ) &&
65+ currentText . includes ( 'onAuxClick' )
66+ ) ;
6067 } ,
6168 {
6269 timeout : 5000 ,
@@ -66,20 +73,26 @@ describe('Pointer onClick Test', () => {
6673 ) ;
6774
6875 const text = await stateText . getText ( ) ;
69- 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 ( ) ;
7080 } ) ;
7181 test ( 'onAuxClick reports correct native event properties on right click' , async ( ) => {
7282 const component = await app . findElementByTestID ( 'pointer-click-target' ) ;
7383 await component . waitForDisplayed ( { timeout : 5000 } ) ;
7484
75- // Middle click triggers onPointerDown with button=2
85+ // Right click triggers onPointerDown with button=2
7686 await component . click ( { button : 'right' } ) ;
7787 const stateText = await app . findElementByTestID ( 'pointer-click-text' ) ;
7888
7989 await app . waitUntil (
8090 async ( ) => {
8191 const currentText = await stateText . getText ( ) ;
82- return currentText . includes ( '"button": 2' ) && currentText . includes ( 'onAuxClick' ) ;
92+ return (
93+ currentText . includes ( '"button": 2' ) &&
94+ currentText . includes ( 'onAuxClick' )
95+ ) ;
8396 } ,
8497 {
8598 timeout : 5000 ,
@@ -89,7 +102,9 @@ describe('Pointer onClick Test', () => {
89102 ) ;
90103
91104 const text = await stateText . getText ( ) ;
92- 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 ( ) ;
93109 } ) ;
94-
95110} ) ;
0 commit comments