1
- import { beforeEach , describe , expect , it , vi } from 'vitest' ;
1
+ import { userEvent } from '@vitest/browser/context' ;
2
+ import { describe , expect , it , vi } from 'vitest' ;
2
3
import { fireEvent , render } from '@testing-library/react' ;
3
- import { userEvent } from '@testing-library/user-event' ;
4
4
5
5
import DateInput from './DateInput.js' ;
6
6
@@ -26,13 +26,6 @@ describe('DateInput', () => {
26
26
className : 'react-date-picker__inputGroup' ,
27
27
} ;
28
28
29
- let user : ReturnType < typeof userEvent . setup > ;
30
- beforeEach ( ( ) => {
31
- user = userEvent . setup ( {
32
- advanceTimers : vi . advanceTimersByTime . bind ( vi ) ,
33
- } ) ;
34
- } ) ;
35
-
36
29
it ( 'renders a native input and custom inputs' , ( ) => {
37
30
const { container } = render ( < DateInput { ...defaultProps } /> ) ;
38
31
@@ -311,7 +304,7 @@ describe('DateInput', () => {
311
304
const monthInput = customInputs [ 0 ] as HTMLInputElement ;
312
305
const dayInput = customInputs [ 1 ] ;
313
306
314
- await user . type ( monthInput , '{arrowright}' ) ;
307
+ await userEvent . type ( monthInput , '{arrowright}' ) ;
315
308
316
309
expect ( dayInput ) . toHaveFocus ( ) ;
317
310
} ) ;
@@ -328,7 +321,7 @@ describe('DateInput', () => {
328
321
) as HTMLSpanElement ;
329
322
const separatorKey = separator . textContent as string ;
330
323
331
- await user . type ( monthInput , separatorKey ) ;
324
+ await userEvent . type ( monthInput , separatorKey ) ;
332
325
333
326
expect ( dayInput ) . toHaveFocus ( ) ;
334
327
} ) ;
@@ -339,7 +332,7 @@ describe('DateInput', () => {
339
332
const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
340
333
const yearInput = customInputs [ 2 ] as HTMLInputElement ;
341
334
342
- await user . type ( yearInput , '{arrowright}' ) ;
335
+ await userEvent . type ( yearInput , '{arrowright}' ) ;
343
336
344
337
expect ( yearInput ) . toHaveFocus ( ) ;
345
338
} ) ;
@@ -351,7 +344,7 @@ describe('DateInput', () => {
351
344
const monthInput = customInputs [ 0 ] ;
352
345
const dayInput = customInputs [ 1 ] as HTMLInputElement ;
353
346
354
- await user . type ( dayInput , '{arrowleft}' ) ;
347
+ await userEvent . type ( dayInput , '{arrowleft}' ) ;
355
348
356
349
expect ( monthInput ) . toHaveFocus ( ) ;
357
350
} ) ;
@@ -362,7 +355,7 @@ describe('DateInput', () => {
362
355
const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
363
356
const monthInput = customInputs [ 0 ] as HTMLInputElement ;
364
357
365
- await user . type ( monthInput , '{arrowleft}' ) ;
358
+ await userEvent . type ( monthInput , '{arrowleft}' ) ;
366
359
367
360
expect ( monthInput ) . toHaveFocus ( ) ;
368
361
} ) ;
@@ -374,7 +367,7 @@ describe('DateInput', () => {
374
367
const monthInput = customInputs [ 0 ] as HTMLInputElement ;
375
368
const dayInput = customInputs [ 1 ] ;
376
369
377
- await user . type ( monthInput , '4' ) ;
370
+ await userEvent . type ( monthInput , '4' ) ;
378
371
379
372
expect ( dayInput ) . toHaveFocus ( ) ;
380
373
} ) ;
@@ -386,7 +379,7 @@ describe('DateInput', () => {
386
379
const monthInput = customInputs [ 0 ] as HTMLInputElement ;
387
380
const dayInput = customInputs [ 1 ] ;
388
381
389
- await user . type ( monthInput , '03' ) ;
382
+ await userEvent . type ( monthInput , '03' ) ;
390
383
391
384
expect ( dayInput ) . toHaveFocus ( ) ;
392
385
} ) ;
@@ -434,7 +427,7 @@ describe('DateInput', () => {
434
427
const customInputs = container . querySelectorAll ( 'input[data-input]' ) ;
435
428
const monthInput = customInputs [ 0 ] as HTMLInputElement ;
436
429
437
- await user . type ( monthInput , '1' ) ;
430
+ await userEvent . type ( monthInput , '1' ) ;
438
431
439
432
expect ( monthInput ) . toHaveFocus ( ) ;
440
433
} ) ;
0 commit comments