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 TimeInput from './TimeInput.js' ;
66
@@ -26,13 +26,6 @@ describe('TimeInput', () => {
2626 className : 'react-time-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 ( < TimeInput { ...defaultProps } /> ) ;
3831
@@ -317,7 +310,7 @@ describe('TimeInput', () => {
317310 const hourInput = customInputs [ 0 ] as HTMLInputElement ;
318311 const minuteInput = customInputs [ 1 ] ;
319312
320- await user . type ( hourInput , '{arrowright}' ) ;
313+ await userEvent . type ( hourInput , '{arrowright}' ) ;
321314
322315 expect ( minuteInput ) . toHaveFocus ( ) ;
323316 } ) ;
@@ -334,7 +327,7 @@ describe('TimeInput', () => {
334327 ) as HTMLSpanElement ;
335328 const separatorKey = separator . textContent as string ;
336329
337- await user . type ( hourInput , separatorKey ) ;
330+ await userEvent . type ( hourInput , separatorKey ) ;
338331
339332 expect ( minuteInput ) . toHaveFocus ( ) ;
340333 } ) ;
@@ -345,7 +338,7 @@ describe('TimeInput', () => {
345338
346339 const select = container . querySelector ( 'select' ) as HTMLSelectElement ;
347340
348- await user . type ( select , '{arrowright}' ) ;
341+ await userEvent . type ( select , '{arrowright}' ) ;
349342
350343 expect ( select ) . toHaveFocus ( ) ;
351344 } ) ;
@@ -357,7 +350,7 @@ describe('TimeInput', () => {
357350 const hourInput = customInputs [ 0 ] ;
358351 const minuteInput = customInputs [ 1 ] as HTMLInputElement ;
359352
360- await user . type ( minuteInput , '{arrowleft}' ) ;
353+ await userEvent . type ( minuteInput , '{arrowleft}' ) ;
361354
362355 expect ( hourInput ) . toHaveFocus ( ) ;
363356 } ) ;
@@ -368,7 +361,7 @@ describe('TimeInput', () => {
368361 const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
369362 const hourInput = customInputs [ 0 ] as HTMLInputElement ;
370363
371- await user . type ( hourInput , '{arrowleft}' ) ;
364+ await userEvent . type ( hourInput , '{arrowleft}' ) ;
372365
373366 expect ( hourInput ) . toHaveFocus ( ) ;
374367 } ) ;
@@ -380,7 +373,7 @@ describe('TimeInput', () => {
380373 const hourInput = customInputs [ 0 ] as HTMLInputElement ;
381374 const minuteInput = customInputs [ 1 ] ;
382375
383- await user . type ( hourInput , '4' ) ;
376+ await userEvent . type ( hourInput , '4' ) ;
384377
385378 expect ( minuteInput ) . toHaveFocus ( ) ;
386379 } ) ;
@@ -392,7 +385,7 @@ describe('TimeInput', () => {
392385 const hourInput = customInputs [ 0 ] as HTMLInputElement ;
393386 const minuteInput = customInputs [ 1 ] ;
394387
395- await user . type ( hourInput , '03' ) ;
388+ await userEvent . type ( hourInput , '03' ) ;
396389
397390 expect ( minuteInput ) . toHaveFocus ( ) ;
398391 } ) ;
@@ -440,7 +433,7 @@ describe('TimeInput', () => {
440433 const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
441434 const hourInput = customInputs [ 0 ] as HTMLInputElement ;
442435
443- await user . type ( hourInput , '1' ) ;
436+ await userEvent . type ( hourInput , '1' ) ;
444437
445438 expect ( hourInput ) . toHaveFocus ( ) ;
446439 } ) ;
0 commit comments