@@ -459,6 +459,13 @@ describe('uploader', () => {
459
459
} ,
460
460
} ,
461
461
] ;
462
+
463
+ const batchEventFiles = files . map ( file =>
464
+ expect . objectContaining ( {
465
+ file,
466
+ } ) ,
467
+ ) ;
468
+
462
469
const sleep = ( timeout = 500 ) => new Promise ( resolve => setTimeout ( resolve , timeout ) ) ;
463
470
464
471
async function testWrapper ( props ) {
@@ -482,7 +489,7 @@ describe('uploader', () => {
482
489
483
490
it ( 'trigger without pending' , async ( ) => {
484
491
const onBatchStart = await testWrapper ( ) ;
485
- expect ( onBatchStart ) . toHaveBeenCalledWith ( files ) ;
492
+ expect ( onBatchStart ) . toHaveBeenCalledWith ( batchEventFiles ) ;
486
493
} ) ;
487
494
488
495
it ( 'trigger with beforeUpload delay' , async ( ) => {
@@ -497,7 +504,7 @@ describe('uploader', () => {
497
504
const onBatchStart = await testWrapper ( { beforeUpload } ) ;
498
505
499
506
expect ( beforeUpload ) . toHaveBeenCalledTimes ( 2 ) ;
500
- expect ( onBatchStart ) . toHaveBeenCalledWith ( files ) ;
507
+ expect ( onBatchStart ) . toHaveBeenCalledWith ( batchEventFiles ) ;
501
508
} ) ;
502
509
503
510
it ( 'beforeUpload but one is deny' , async ( ) => {
@@ -512,7 +519,14 @@ describe('uploader', () => {
512
519
const onBatchStart = await testWrapper ( { beforeUpload } ) ;
513
520
514
521
expect ( beforeUpload ) . toHaveBeenCalledTimes ( 2 ) ;
515
- expect ( onBatchStart ) . toHaveBeenCalledWith ( files . filter ( f => f . name !== 'light.png' ) ) ;
522
+ expect ( onBatchStart ) . toHaveBeenCalledWith (
523
+ files . map ( file =>
524
+ expect . objectContaining ( {
525
+ file,
526
+ parsedFile : file . name === 'light.png' ? null : file ,
527
+ } ) ,
528
+ ) ,
529
+ ) ;
516
530
} ) ;
517
531
518
532
it ( 'action delay' , async ( ) => {
@@ -524,7 +538,7 @@ describe('uploader', () => {
524
538
const onBatchStart = await testWrapper ( { action } ) ;
525
539
526
540
expect ( action ) . toHaveBeenCalledTimes ( 2 ) ;
527
- expect ( onBatchStart ) . toHaveBeenCalledWith ( files ) ;
541
+ expect ( onBatchStart ) . toHaveBeenCalledWith ( batchEventFiles ) ;
528
542
} ) ;
529
543
530
544
it ( 'data delay' , async ( ) => {
@@ -536,7 +550,7 @@ describe('uploader', () => {
536
550
const onBatchStart = await testWrapper ( { data } ) ;
537
551
538
552
expect ( data ) . toHaveBeenCalledTimes ( 2 ) ;
539
- expect ( onBatchStart ) . toHaveBeenCalledWith ( files ) ;
553
+ expect ( onBatchStart ) . toHaveBeenCalledWith ( batchEventFiles ) ;
540
554
} ) ;
541
555
} ) ;
542
556
} ) ;
0 commit comments