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
@@ -25,13 +25,6 @@ describe('TimeInput', () => {
2525 className : 'react-time-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 ( < TimeInput { ...defaultProps } /> ) ;
3730
@@ -316,7 +309,7 @@ describe('TimeInput', () => {
316309 const hourInput = customInputs [ 0 ] as HTMLInputElement ;
317310 const minuteInput = customInputs [ 1 ] ;
318311
319- await user . type ( hourInput , '{arrowright}' ) ;
312+ await userEvent . type ( hourInput , '{arrowright}' ) ;
320313
321314 expect ( minuteInput ) . toHaveFocus ( ) ;
322315 } ) ;
@@ -333,7 +326,7 @@ describe('TimeInput', () => {
333326 ) as HTMLSpanElement ;
334327 const separatorKey = separator . textContent as string ;
335328
336- await user . type ( hourInput , separatorKey ) ;
329+ await userEvent . type ( hourInput , separatorKey ) ;
337330
338331 expect ( minuteInput ) . toHaveFocus ( ) ;
339332 } ) ;
@@ -344,7 +337,7 @@ describe('TimeInput', () => {
344337
345338 const select = container . querySelector ( 'select' ) as HTMLSelectElement ;
346339
347- await user . type ( select , '{arrowright}' ) ;
340+ await userEvent . type ( select , '{arrowright}' ) ;
348341
349342 expect ( select ) . toHaveFocus ( ) ;
350343 } ) ;
@@ -356,7 +349,7 @@ describe('TimeInput', () => {
356349 const hourInput = customInputs [ 0 ] ;
357350 const minuteInput = customInputs [ 1 ] as HTMLInputElement ;
358351
359- await user . type ( minuteInput , '{arrowleft}' ) ;
352+ await userEvent . type ( minuteInput , '{arrowleft}' ) ;
360353
361354 expect ( hourInput ) . toHaveFocus ( ) ;
362355 } ) ;
@@ -367,7 +360,7 @@ describe('TimeInput', () => {
367360 const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
368361 const hourInput = customInputs [ 0 ] as HTMLInputElement ;
369362
370- await user . type ( hourInput , '{arrowleft}' ) ;
363+ await userEvent . type ( hourInput , '{arrowleft}' ) ;
371364
372365 expect ( hourInput ) . toHaveFocus ( ) ;
373366 } ) ;
@@ -379,7 +372,7 @@ describe('TimeInput', () => {
379372 const hourInput = customInputs [ 0 ] as HTMLInputElement ;
380373 const minuteInput = customInputs [ 1 ] ;
381374
382- await user . type ( hourInput , '4' ) ;
375+ await userEvent . type ( hourInput , '4' ) ;
383376
384377 expect ( minuteInput ) . toHaveFocus ( ) ;
385378 } ) ;
@@ -391,7 +384,7 @@ describe('TimeInput', () => {
391384 const hourInput = customInputs [ 0 ] as HTMLInputElement ;
392385 const minuteInput = customInputs [ 1 ] ;
393386
394- await user . type ( hourInput , '03' ) ;
387+ await userEvent . type ( hourInput , '03' ) ;
395388
396389 expect ( minuteInput ) . toHaveFocus ( ) ;
397390 } ) ;
@@ -439,7 +432,7 @@ describe('TimeInput', () => {
439432 const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
440433 const hourInput = customInputs [ 0 ] as HTMLInputElement ;
441434
442- await user . type ( hourInput , '1' ) ;
435+ await userEvent . type ( hourInput , '1' ) ;
443436
444437 expect ( hourInput ) . toHaveFocus ( ) ;
445438 } ) ;
0 commit comments