12
12
13
13
import { fireEvent , installPointerEvent , render , waitFor } from '@react-spectrum/test-utils-internal' ;
14
14
import React , { useEffect , useRef } from 'react' ;
15
- import ReactDOM , { createPortal , render as ReactDOMRender } from 'react-dom' ;
15
+ import ReactDOM , { createPortal } from 'react-dom' ;
16
16
import { useInteractOutside } from '../' ;
17
17
18
18
function Example ( props ) {
@@ -42,10 +42,12 @@ describe('useInteractOutside', function () {
42
42
let el = res . getByText ( 'test' ) ;
43
43
fireEvent ( el , pointerEvent ( 'pointerdown' ) ) ;
44
44
fireEvent ( el , pointerEvent ( 'pointerup' ) ) ;
45
+ fireEvent . click ( el ) ;
45
46
expect ( onInteractOutside ) . not . toHaveBeenCalled ( ) ;
46
47
47
48
fireEvent ( document . body , pointerEvent ( 'pointerdown' ) ) ;
48
49
fireEvent ( document . body , pointerEvent ( 'pointerup' ) ) ;
50
+ fireEvent . click ( document . body ) ;
49
51
expect ( onInteractOutside ) . toHaveBeenCalledTimes ( 1 ) ;
50
52
} ) ;
51
53
@@ -57,10 +59,12 @@ describe('useInteractOutside', function () {
57
59
58
60
fireEvent ( document . body , pointerEvent ( 'pointerdown' , { button : 1 } ) ) ;
59
61
fireEvent ( document . body , pointerEvent ( 'pointerup' , { button : 1 } ) ) ;
62
+ fireEvent . click ( document . body , { button : 1 } ) ;
60
63
expect ( onInteractOutside ) . not . toHaveBeenCalled ( ) ;
61
64
62
65
fireEvent ( document . body , pointerEvent ( 'pointerdown' , { button : 0 } ) ) ;
63
66
fireEvent ( document . body , pointerEvent ( 'pointerup' , { button : 0 } ) ) ;
67
+ fireEvent . click ( document . body , { button : 0 } ) ;
64
68
expect ( onInteractOutside ) . toHaveBeenCalledTimes ( 1 ) ;
65
69
} ) ;
66
70
@@ -74,6 +78,7 @@ describe('useInteractOutside', function () {
74
78
) ;
75
79
76
80
fireEvent ( document . body , pointerEvent ( 'pointerup' ) ) ;
81
+ fireEvent . click ( document . body ) ;
77
82
expect ( onInteractOutside ) . not . toHaveBeenCalled ( ) ;
78
83
} ) ;
79
84
} ) ;
@@ -246,10 +251,12 @@ describe('useInteractOutside (iframes)', function () {
246
251
const el = document . querySelector ( 'iframe' ) . contentWindow . document . body . querySelector ( 'div[data-testid="example"]' ) ;
247
252
fireEvent ( el , pointerEvent ( 'pointerdown' ) ) ;
248
253
fireEvent ( el , pointerEvent ( 'pointerup' ) ) ;
254
+ fireEvent . click ( el ) ;
249
255
expect ( onInteractOutside ) . not . toHaveBeenCalled ( ) ;
250
256
251
257
fireEvent ( iframeDocument . body , pointerEvent ( 'pointerdown' ) ) ;
252
258
fireEvent ( iframeDocument . body , pointerEvent ( 'pointerup' ) ) ;
259
+ fireEvent . click ( iframeDocument . body ) ;
253
260
expect ( onInteractOutside ) . toHaveBeenCalledTimes ( 1 ) ;
254
261
} ) ;
255
262
@@ -265,10 +272,12 @@ describe('useInteractOutside (iframes)', function () {
265
272
266
273
fireEvent ( iframeDocument . body , pointerEvent ( 'pointerdown' , { button : 1 } ) ) ;
267
274
fireEvent ( iframeDocument . body , pointerEvent ( 'pointerup' , { button : 1 } ) ) ;
275
+ fireEvent . click ( iframeDocument . body , { button : 0 } ) ;
268
276
expect ( onInteractOutside ) . not . toHaveBeenCalled ( ) ;
269
277
270
278
fireEvent ( iframeDocument . body , pointerEvent ( 'pointerdown' , { button : 0 } ) ) ;
271
279
fireEvent ( iframeDocument . body , pointerEvent ( 'pointerup' , { button : 0 } ) ) ;
280
+ fireEvent . click ( iframeDocument . body , { button : 0 } ) ;
272
281
expect ( onInteractOutside ) . toHaveBeenCalledTimes ( 1 ) ;
273
282
} ) ;
274
283
@@ -285,6 +294,7 @@ describe('useInteractOutside (iframes)', function () {
285
294
expect ( document . querySelector ( 'iframe' ) . contentWindow . document . body . querySelector ( 'div[data-testid="example"]' ) ) . toBeTruthy ( ) ;
286
295
} ) ;
287
296
fireEvent ( iframeDocument . body , pointerEvent ( 'pointerup' ) ) ;
297
+ fireEvent . click ( iframeDocument . body ) ;
288
298
expect ( onInteractOutside ) . not . toHaveBeenCalled ( ) ;
289
299
} ) ;
290
300
} ) ;
0 commit comments