1
- import { beforeEach , describe , expect , it , vi } from 'vitest' ;
1
+ import { userEvent } from '@vitest/browser/context' ;
2
+ import { describe , expect , it , vi } from 'vitest' ;
2
3
import { fireEvent , render } from '@testing-library/react' ;
3
- import { userEvent } from '@testing-library/user-event' ;
4
4
5
5
import DateTimeInput from './DateTimeInput.js' ;
6
6
@@ -25,13 +25,6 @@ describe('DateTimeInput', () => {
25
25
className : 'react-datetime-picker__inputGroup' ,
26
26
} ;
27
27
28
- let user : ReturnType < typeof userEvent . setup > ;
29
- beforeEach ( ( ) => {
30
- user = userEvent . setup ( {
31
- advanceTimers : vi . advanceTimersByTime . bind ( vi ) ,
32
- } ) ;
33
- } ) ;
34
-
35
28
it ( 'renders a native input and custom inputs' , ( ) => {
36
29
const { container } = render ( < DateTimeInput { ...defaultProps } /> ) ;
37
30
@@ -496,7 +489,7 @@ describe('DateTimeInput', () => {
496
489
const monthInput = customInputs [ 0 ] as HTMLInputElement ;
497
490
const dayInput = customInputs [ 1 ] ;
498
491
499
- await user . type ( monthInput , '{arrowright}' ) ;
492
+ await userEvent . type ( monthInput , '{arrowright}' ) ;
500
493
501
494
expect ( dayInput ) . toHaveFocus ( ) ;
502
495
} ) ;
@@ -514,7 +507,7 @@ describe('DateTimeInput', () => {
514
507
. filter ( ( el ) => el . trim ( ) ) ;
515
508
const separatorKey = separatorsTexts [ 0 ] as string ;
516
509
517
- await user . type ( monthInput , separatorKey ) ;
510
+ await userEvent . type ( monthInput , separatorKey ) ;
518
511
519
512
expect ( dayInput ) . toHaveFocus ( ) ;
520
513
} ) ;
@@ -532,7 +525,7 @@ describe('DateTimeInput', () => {
532
525
. filter ( ( el ) => el . trim ( ) ) ;
533
526
const separatorKey = separatorsTexts [ separatorsTexts . length - 1 ] as string ;
534
527
535
- await user . type ( monthInput , separatorKey ) ;
528
+ await userEvent . type ( monthInput , separatorKey ) ;
536
529
537
530
expect ( dayInput ) . toHaveFocus ( ) ;
538
531
} ) ;
@@ -543,7 +536,7 @@ describe('DateTimeInput', () => {
543
536
544
537
const select = container . querySelector ( 'select' ) as HTMLSelectElement ;
545
538
546
- await user . type ( select , '{arrowright}' ) ;
539
+ await userEvent . type ( select , '{arrowright}' ) ;
547
540
548
541
expect ( select ) . toHaveFocus ( ) ;
549
542
} ) ;
@@ -555,7 +548,7 @@ describe('DateTimeInput', () => {
555
548
const monthInput = customInputs [ 0 ] ;
556
549
const dayInput = customInputs [ 1 ] as HTMLInputElement ;
557
550
558
- await user . type ( dayInput , '{arrowleft}' ) ;
551
+ await userEvent . type ( dayInput , '{arrowleft}' ) ;
559
552
560
553
expect ( monthInput ) . toHaveFocus ( ) ;
561
554
} ) ;
@@ -566,7 +559,7 @@ describe('DateTimeInput', () => {
566
559
const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
567
560
const monthInput = customInputs [ 0 ] as HTMLInputElement ;
568
561
569
- await user . type ( monthInput , '{arrowleft}' ) ;
562
+ await userEvent . type ( monthInput , '{arrowleft}' ) ;
570
563
571
564
expect ( monthInput ) . toHaveFocus ( ) ;
572
565
} ) ;
@@ -578,7 +571,7 @@ describe('DateTimeInput', () => {
578
571
const monthInput = customInputs [ 0 ] as HTMLInputElement ;
579
572
const dayInput = customInputs [ 1 ] ;
580
573
581
- await user . type ( monthInput , '4' ) ;
574
+ await userEvent . type ( monthInput , '4' ) ;
582
575
583
576
expect ( dayInput ) . toHaveFocus ( ) ;
584
577
} ) ;
@@ -590,7 +583,7 @@ describe('DateTimeInput', () => {
590
583
const monthInput = customInputs [ 0 ] as HTMLInputElement ;
591
584
const dayInput = customInputs [ 1 ] ;
592
585
593
- await user . type ( monthInput , '03' ) ;
586
+ await userEvent . type ( monthInput , '03' ) ;
594
587
595
588
expect ( dayInput ) . toHaveFocus ( ) ;
596
589
} ) ;
@@ -638,7 +631,7 @@ describe('DateTimeInput', () => {
638
631
const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
639
632
const monthInput = customInputs [ 0 ] as HTMLInputElement ;
640
633
641
- await user . type ( monthInput , '1' ) ;
634
+ await userEvent . type ( monthInput , '1' ) ;
642
635
643
636
expect ( monthInput ) . toHaveFocus ( ) ;
644
637
} ) ;
0 commit comments