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 DateInput from './DateInput.js' ;
66
@@ -25,13 +25,6 @@ describe('DateInput', () => {
2525 className : 'react-date-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 ( < DateInput { ...defaultProps } /> ) ;
3730
@@ -310,7 +303,7 @@ describe('DateInput', () => {
310303 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
311304 const dayInput = customInputs [ 1 ] ;
312305
313- await user . type ( monthInput , '{arrowright}' ) ;
306+ await userEvent . type ( monthInput , '{arrowright}' ) ;
314307
315308 expect ( dayInput ) . toHaveFocus ( ) ;
316309 } ) ;
@@ -327,7 +320,7 @@ describe('DateInput', () => {
327320 ) as HTMLSpanElement ;
328321 const separatorKey = separator . textContent as string ;
329322
330- await user . type ( monthInput , separatorKey ) ;
323+ await userEvent . type ( monthInput , separatorKey ) ;
331324
332325 expect ( dayInput ) . toHaveFocus ( ) ;
333326 } ) ;
@@ -338,7 +331,7 @@ describe('DateInput', () => {
338331 const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
339332 const yearInput = customInputs [ 2 ] as HTMLInputElement ;
340333
341- await user . type ( yearInput , '{arrowright}' ) ;
334+ await userEvent . type ( yearInput , '{arrowright}' ) ;
342335
343336 expect ( yearInput ) . toHaveFocus ( ) ;
344337 } ) ;
@@ -350,7 +343,7 @@ describe('DateInput', () => {
350343 const monthInput = customInputs [ 0 ] ;
351344 const dayInput = customInputs [ 1 ] as HTMLInputElement ;
352345
353- await user . type ( dayInput , '{arrowleft}' ) ;
346+ await userEvent . type ( dayInput , '{arrowleft}' ) ;
354347
355348 expect ( monthInput ) . toHaveFocus ( ) ;
356349 } ) ;
@@ -361,7 +354,7 @@ describe('DateInput', () => {
361354 const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
362355 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
363356
364- await user . type ( monthInput , '{arrowleft}' ) ;
357+ await userEvent . type ( monthInput , '{arrowleft}' ) ;
365358
366359 expect ( monthInput ) . toHaveFocus ( ) ;
367360 } ) ;
@@ -373,7 +366,7 @@ describe('DateInput', () => {
373366 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
374367 const dayInput = customInputs [ 1 ] ;
375368
376- await user . type ( monthInput , '4' ) ;
369+ await userEvent . type ( monthInput , '4' ) ;
377370
378371 expect ( dayInput ) . toHaveFocus ( ) ;
379372 } ) ;
@@ -385,7 +378,7 @@ describe('DateInput', () => {
385378 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
386379 const dayInput = customInputs [ 1 ] ;
387380
388- await user . type ( monthInput , '03' ) ;
381+ await userEvent . type ( monthInput , '03' ) ;
389382
390383 expect ( dayInput ) . toHaveFocus ( ) ;
391384 } ) ;
@@ -433,7 +426,7 @@ describe('DateInput', () => {
433426 const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
434427 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
435428
436- await user . type ( monthInput , '1' ) ;
429+ await userEvent . type ( monthInput , '1' ) ;
437430
438431 expect ( monthInput ) . toHaveFocus ( ) ;
439432 } ) ;
0 commit comments