@@ -167,97 +167,6 @@ describe('Hover event responder', () => {
167
167
) ;
168
168
expect ( onHoverStart ) . not . toBeCalled ( ) ;
169
169
} ) ;
170
-
171
- describe ( 'delayHoverStart' , ( ) => {
172
- it ( 'can be configured' , ( ) => {
173
- const Component = ( ) => {
174
- useHoverListener ( {
175
- onHoverStart : onHoverStart ,
176
- } ) ;
177
- return (
178
- < div
179
- ref = { ref }
180
- responders = { < HoverResponder delayHoverStart = { 2000 } /> }
181
- />
182
- ) ;
183
- } ;
184
- ReactDOM . render ( < Component /> , container ) ;
185
-
186
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
187
- jest . advanceTimersByTime ( 1999 ) ;
188
- expect ( onHoverStart ) . not . toBeCalled ( ) ;
189
- jest . advanceTimersByTime ( 1 ) ;
190
- expect ( onHoverStart ) . toHaveBeenCalledTimes ( 1 ) ;
191
- } ) ;
192
-
193
- it ( 'is reset if "pointerout" is dispatched during a delay' , ( ) => {
194
- const Component = ( ) => {
195
- useHoverListener ( {
196
- onHoverStart : onHoverStart ,
197
- } ) ;
198
- return (
199
- < div
200
- ref = { ref }
201
- responders = { < HoverResponder delayHoverStart = { 500 } /> }
202
- />
203
- ) ;
204
- } ;
205
- ReactDOM . render ( < Component /> , container ) ;
206
-
207
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
208
- jest . advanceTimersByTime ( 499 ) ;
209
- ref . current . dispatchEvent ( createEvent ( 'pointerout' ) ) ;
210
- jest . advanceTimersByTime ( 1 ) ;
211
- expect ( onHoverStart ) . not . toBeCalled ( ) ;
212
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
213
- jest . runAllTimers ( ) ;
214
- expect ( onHoverStart ) . toHaveBeenCalledTimes ( 1 ) ;
215
- } ) ;
216
-
217
- it ( 'onHoverStart is called synchronously if delay is 0ms' , ( ) => {
218
- const Component = ( ) => {
219
- useHoverListener ( {
220
- onHoverStart : onHoverStart ,
221
- } ) ;
222
- return (
223
- < div
224
- ref = { ref }
225
- responders = { < HoverResponder delayHoverStart = { 0 } /> }
226
- />
227
- ) ;
228
- } ;
229
- ReactDOM . render ( < Component /> , container ) ;
230
-
231
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
232
- expect ( onHoverStart ) . toHaveBeenCalledTimes ( 1 ) ;
233
- } ) ;
234
-
235
- it ( 'onHoverStart is only called once per active hover' , ( ) => {
236
- const Component = ( ) => {
237
- useHoverListener ( {
238
- onHoverStart : onHoverStart ,
239
- } ) ;
240
- return (
241
- < div
242
- ref = { ref }
243
- responders = {
244
- < HoverResponder delayHoverStart = { 500 } delayHoverEnd = { 100 } />
245
- }
246
- />
247
- ) ;
248
- } ;
249
- ReactDOM . render ( < Component /> , container ) ;
250
-
251
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
252
- jest . advanceTimersByTime ( 500 ) ;
253
- expect ( onHoverStart ) . toHaveBeenCalledTimes ( 1 ) ;
254
- ref . current . dispatchEvent ( createEvent ( 'pointerout' ) ) ;
255
- jest . advanceTimersByTime ( 10 ) ;
256
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
257
- jest . runAllTimers ( ) ;
258
- expect ( onHoverStart ) . toHaveBeenCalledTimes ( 1 ) ;
259
- } ) ;
260
- } ) ;
261
170
} ) ;
262
171
263
172
describe ( 'onHoverChange' , ( ) => {
@@ -399,114 +308,6 @@ describe('Hover event responder', () => {
399
308
ref . current . dispatchEvent ( createEvent ( 'mouseout' ) ) ;
400
309
expect ( onHoverEnd ) . not . toBeCalled ( ) ;
401
310
} ) ;
402
-
403
- describe ( 'delayHoverEnd' , ( ) => {
404
- it ( 'can be configured' , ( ) => {
405
- const Component = ( ) => {
406
- useHoverListener ( {
407
- onHoverEnd,
408
- } ) ;
409
- return (
410
- < div
411
- ref = { ref }
412
- responders = { < HoverResponder delayHoverEnd = { 2000 } /> }
413
- />
414
- ) ;
415
- } ;
416
- ReactDOM . render ( < Component /> , container ) ;
417
-
418
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
419
- ref . current . dispatchEvent ( createEvent ( 'pointerout' ) ) ;
420
- jest . advanceTimersByTime ( 1999 ) ;
421
- expect ( onHoverEnd ) . not . toBeCalled ( ) ;
422
- jest . advanceTimersByTime ( 1 ) ;
423
- expect ( onHoverEnd ) . toHaveBeenCalledTimes ( 1 ) ;
424
- } ) ;
425
-
426
- it ( 'delayHoverEnd is called synchronously if delay is 0ms' , ( ) => {
427
- const Component = ( ) => {
428
- useHoverListener ( {
429
- onHoverEnd,
430
- } ) ;
431
- return (
432
- < div ref = { ref } responders = { < HoverResponder delayHoverEnd = { 0 } /> } />
433
- ) ;
434
- } ;
435
- ReactDOM . render ( < Component /> , container ) ;
436
-
437
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
438
- ref . current . dispatchEvent ( createEvent ( 'pointerout' ) ) ;
439
- expect ( onHoverEnd ) . toHaveBeenCalledTimes ( 1 ) ;
440
- } ) ;
441
-
442
- it ( 'onHoverEnd is only called once per active hover' , ( ) => {
443
- const Component = ( ) => {
444
- useHoverListener ( {
445
- onHoverEnd,
446
- } ) ;
447
- return (
448
- < div
449
- ref = { ref }
450
- responders = { < HoverResponder delayHoverEnd = { 500 } /> }
451
- />
452
- ) ;
453
- } ;
454
- ReactDOM . render ( < Component /> , container ) ;
455
-
456
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
457
- ref . current . dispatchEvent ( createEvent ( 'pointerout' ) ) ;
458
- jest . advanceTimersByTime ( 499 ) ;
459
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
460
- jest . advanceTimersByTime ( 100 ) ;
461
- ref . current . dispatchEvent ( createEvent ( 'pointerout' ) ) ;
462
- jest . runAllTimers ( ) ;
463
- expect ( onHoverEnd ) . toHaveBeenCalledTimes ( 1 ) ;
464
- } ) ;
465
-
466
- it ( 'onHoverEnd is not called if "pointerover" is dispatched during a delay' , ( ) => {
467
- const Component = ( ) => {
468
- useHoverListener ( {
469
- onHoverEnd,
470
- } ) ;
471
- return (
472
- < div
473
- ref = { ref }
474
- responders = { < HoverResponder delayHoverEnd = { 500 } /> }
475
- />
476
- ) ;
477
- } ;
478
- ReactDOM . render ( < Component /> , container ) ;
479
-
480
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
481
- ref . current . dispatchEvent ( createEvent ( 'pointerout' ) ) ;
482
- jest . advanceTimersByTime ( 499 ) ;
483
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
484
- jest . advanceTimersByTime ( 1 ) ;
485
- expect ( onHoverEnd ) . not . toBeCalled ( ) ;
486
- } ) ;
487
-
488
- it ( 'onHoverEnd is not called if there was no active hover' , ( ) => {
489
- const Component = ( ) => {
490
- useHoverListener ( {
491
- onHoverEnd,
492
- } ) ;
493
- return (
494
- < div
495
- ref = { ref }
496
- responders = {
497
- < HoverResponder delayHoverStart = { 500 } delayHoverEnd = { 100 } />
498
- }
499
- />
500
- ) ;
501
- } ;
502
- ReactDOM . render ( < Component /> , container ) ;
503
-
504
- ref . current . dispatchEvent ( createEvent ( 'pointerover' ) ) ;
505
- ref . current . dispatchEvent ( createEvent ( 'pointerout' ) ) ;
506
- jest . runAllTimers ( ) ;
507
- expect ( onHoverEnd ) . not . toBeCalled ( ) ;
508
- } ) ;
509
- } ) ;
510
311
} ) ;
511
312
512
313
describe ( 'onHoverMove' , ( ) => {
0 commit comments