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