1- import { beforeEach , describe , expect , it , vi } from 'vitest' ;
1+ import { userEvent } from '@vitest/browser/context' ;
2+ import { describe , expect , it , vi } from 'vitest' ;
23import { fireEvent , render } from '@testing-library/react' ;
3- import { userEvent } from '@testing-library/user-event' ;
44
55import DateTimeInput from './DateTimeInput.js' ;
66
@@ -25,13 +25,6 @@ describe('DateTimeInput', () => {
2525 className : 'react-datetime-picker__inputGroup' ,
2626 } ;
2727
28- let user : ReturnType < typeof userEvent . setup > ;
29- beforeEach ( ( ) => {
30- user = userEvent . setup ( {
31- advanceTimers : vi . advanceTimersByTime . bind ( vi ) ,
32- } ) ;
33- } ) ;
34-
3528 it ( 'renders a native input and custom inputs' , ( ) => {
3629 const { container } = render ( < DateTimeInput { ...defaultProps } /> ) ;
3730
@@ -496,7 +489,7 @@ describe('DateTimeInput', () => {
496489 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
497490 const dayInput = customInputs [ 1 ] ;
498491
499- await user . type ( monthInput , '{arrowright}' ) ;
492+ await userEvent . type ( monthInput , '{arrowright}' ) ;
500493
501494 expect ( dayInput ) . toHaveFocus ( ) ;
502495 } ) ;
@@ -514,7 +507,7 @@ describe('DateTimeInput', () => {
514507 . filter ( ( el ) => el . trim ( ) ) ;
515508 const separatorKey = separatorsTexts [ 0 ] as string ;
516509
517- await user . type ( monthInput , separatorKey ) ;
510+ await userEvent . type ( monthInput , separatorKey ) ;
518511
519512 expect ( dayInput ) . toHaveFocus ( ) ;
520513 } ) ;
@@ -532,7 +525,7 @@ describe('DateTimeInput', () => {
532525 . filter ( ( el ) => el . trim ( ) ) ;
533526 const separatorKey = separatorsTexts [ separatorsTexts . length - 1 ] as string ;
534527
535- await user . type ( monthInput , separatorKey ) ;
528+ await userEvent . type ( monthInput , separatorKey ) ;
536529
537530 expect ( dayInput ) . toHaveFocus ( ) ;
538531 } ) ;
@@ -543,7 +536,7 @@ describe('DateTimeInput', () => {
543536
544537 const select = container . querySelector ( 'select' ) as HTMLSelectElement ;
545538
546- await user . type ( select , '{arrowright}' ) ;
539+ await userEvent . type ( select , '{arrowright}' ) ;
547540
548541 expect ( select ) . toHaveFocus ( ) ;
549542 } ) ;
@@ -555,7 +548,7 @@ describe('DateTimeInput', () => {
555548 const monthInput = customInputs [ 0 ] ;
556549 const dayInput = customInputs [ 1 ] as HTMLInputElement ;
557550
558- await user . type ( dayInput , '{arrowleft}' ) ;
551+ await userEvent . type ( dayInput , '{arrowleft}' ) ;
559552
560553 expect ( monthInput ) . toHaveFocus ( ) ;
561554 } ) ;
@@ -566,7 +559,7 @@ describe('DateTimeInput', () => {
566559 const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
567560 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
568561
569- await user . type ( monthInput , '{arrowleft}' ) ;
562+ await userEvent . type ( monthInput , '{arrowleft}' ) ;
570563
571564 expect ( monthInput ) . toHaveFocus ( ) ;
572565 } ) ;
@@ -578,7 +571,7 @@ describe('DateTimeInput', () => {
578571 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
579572 const dayInput = customInputs [ 1 ] ;
580573
581- await user . type ( monthInput , '4' ) ;
574+ await userEvent . type ( monthInput , '4' ) ;
582575
583576 expect ( dayInput ) . toHaveFocus ( ) ;
584577 } ) ;
@@ -590,7 +583,7 @@ describe('DateTimeInput', () => {
590583 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
591584 const dayInput = customInputs [ 1 ] ;
592585
593- await user . type ( monthInput , '03' ) ;
586+ await userEvent . type ( monthInput , '03' ) ;
594587
595588 expect ( dayInput ) . toHaveFocus ( ) ;
596589 } ) ;
@@ -638,7 +631,7 @@ describe('DateTimeInput', () => {
638631 const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
639632 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
640633
641- await user . type ( monthInput , '1' ) ;
634+ await userEvent . type ( monthInput , '1' ) ;
642635
643636 expect ( monthInput ) . toHaveFocus ( ) ;
644637 } ) ;
0 commit comments