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
@@ -26,13 +26,6 @@ describe('DateInput', () => {
2626 className : 'react-date-picker__inputGroup' ,
2727 } ;
2828
29- let user : ReturnType < typeof userEvent . setup > ;
30- beforeEach ( ( ) => {
31- user = userEvent . setup ( {
32- advanceTimers : vi . advanceTimersByTime . bind ( vi ) ,
33- } ) ;
34- } ) ;
35-
3629 it ( 'renders a native input and custom inputs' , ( ) => {
3730 const { container } = render ( < DateInput { ...defaultProps } /> ) ;
3831
@@ -311,7 +304,7 @@ describe('DateInput', () => {
311304 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
312305 const dayInput = customInputs [ 1 ] ;
313306
314- await user . type ( monthInput , '{arrowright}' ) ;
307+ await userEvent . type ( monthInput , '{arrowright}' ) ;
315308
316309 expect ( dayInput ) . toHaveFocus ( ) ;
317310 } ) ;
@@ -328,7 +321,7 @@ describe('DateInput', () => {
328321 ) as HTMLSpanElement ;
329322 const separatorKey = separator . textContent as string ;
330323
331- await user . type ( monthInput , separatorKey ) ;
324+ await userEvent . type ( monthInput , separatorKey ) ;
332325
333326 expect ( dayInput ) . toHaveFocus ( ) ;
334327 } ) ;
@@ -339,7 +332,7 @@ describe('DateInput', () => {
339332 const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
340333 const yearInput = customInputs [ 2 ] as HTMLInputElement ;
341334
342- await user . type ( yearInput , '{arrowright}' ) ;
335+ await userEvent . type ( yearInput , '{arrowright}' ) ;
343336
344337 expect ( yearInput ) . toHaveFocus ( ) ;
345338 } ) ;
@@ -351,7 +344,7 @@ describe('DateInput', () => {
351344 const monthInput = customInputs [ 0 ] ;
352345 const dayInput = customInputs [ 1 ] as HTMLInputElement ;
353346
354- await user . type ( dayInput , '{arrowleft}' ) ;
347+ await userEvent . type ( dayInput , '{arrowleft}' ) ;
355348
356349 expect ( monthInput ) . toHaveFocus ( ) ;
357350 } ) ;
@@ -362,7 +355,7 @@ describe('DateInput', () => {
362355 const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
363356 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
364357
365- await user . type ( monthInput , '{arrowleft}' ) ;
358+ await userEvent . type ( monthInput , '{arrowleft}' ) ;
366359
367360 expect ( monthInput ) . toHaveFocus ( ) ;
368361 } ) ;
@@ -374,7 +367,7 @@ describe('DateInput', () => {
374367 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
375368 const dayInput = customInputs [ 1 ] ;
376369
377- await user . type ( monthInput , '4' ) ;
370+ await userEvent . type ( monthInput , '4' ) ;
378371
379372 expect ( dayInput ) . toHaveFocus ( ) ;
380373 } ) ;
@@ -386,7 +379,7 @@ describe('DateInput', () => {
386379 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
387380 const dayInput = customInputs [ 1 ] ;
388381
389- await user . type ( monthInput , '03' ) ;
382+ await userEvent . type ( monthInput , '03' ) ;
390383
391384 expect ( dayInput ) . toHaveFocus ( ) ;
392385 } ) ;
@@ -434,7 +427,7 @@ describe('DateInput', () => {
434427 const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
435428 const monthInput = customInputs [ 0 ] as HTMLInputElement ;
436429
437- await user . type ( monthInput , '1' ) ;
430+ await userEvent . type ( monthInput , '1' ) ;
438431
439432 expect ( monthInput ) . toHaveFocus ( ) ;
440433 } ) ;
0 commit comments