react-dropzone 4.2.12 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.spec.js CHANGED
@@ -361,21 +361,21 @@ describe('Dropzone', () => {
361
361
  dragOverSpy.restore()
362
362
  })
363
363
 
364
- it('should set proper dragActive state on dragEnter', () => {
364
+ it('should set proper dragActive state on dragEnter', async () => {
365
365
  const dropzone = mount(<Dropzone>{props => <DummyChildComponent {...props} />}</Dropzone>)
366
366
  const child = dropzone.find(DummyChildComponent)
367
- dropzone.simulate('dragEnter', { dataTransfer: { files } })
367
+ await dropzone.simulate('dragEnter', { dataTransfer: { files } })
368
368
  expect(child).toHaveProp('isDragActive', true)
369
369
  expect(child).toHaveProp('isDragAccept', true)
370
370
  expect(child).toHaveProp('isDragReject', false)
371
371
  })
372
372
 
373
- it('should set proper dragReject state on dragEnter', () => {
373
+ it('should set proper dragReject state on dragEnter', async () => {
374
374
  const dropzone = mount(
375
375
  <Dropzone accept="image/*">{props => <DummyChildComponent {...props} />}</Dropzone>
376
376
  )
377
377
  const child = dropzone.find(DummyChildComponent)
378
- dropzone.simulate('dragEnter', {
378
+ await dropzone.simulate('dragEnter', {
379
379
  dataTransfer: { files: files.concat(images) }
380
380
  })
381
381
  expect(child).toHaveProp('isDragActive', true)
@@ -383,64 +383,64 @@ describe('Dropzone', () => {
383
383
  expect(child).toHaveProp('isDragReject', true)
384
384
  })
385
385
 
386
- it('should set proper dragAccept state if multiple is false', () => {
386
+ it('should set proper dragAccept state if multiple is false', async () => {
387
387
  const dropzone = mount(
388
388
  <Dropzone accept="image/*" multiple={false}>
389
389
  {props => <DummyChildComponent {...props} />}
390
390
  </Dropzone>
391
391
  )
392
392
  const child = dropzone.find(DummyChildComponent)
393
- dropzone.simulate('dragEnter', { dataTransfer: { files } })
393
+ await dropzone.simulate('dragEnter', { dataTransfer: { files } })
394
394
  expect(child).toHaveProp('isDragActive', true)
395
395
  expect(child).toHaveProp('isDragAccept', false)
396
396
  expect(child).toHaveProp('isDragReject', true)
397
397
  })
398
398
 
399
- it('should set proper dragAccept state if multiple is false', () => {
399
+ it('should set proper dragAccept state if multiple is false', async () => {
400
400
  const dropzone = mount(
401
401
  <Dropzone accept="image/*" multiple={false}>
402
402
  {props => <DummyChildComponent {...props} />}
403
403
  </Dropzone>
404
404
  )
405
405
  const child = dropzone.find(DummyChildComponent)
406
- dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
406
+ await dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
407
407
  expect(child).toHaveProp('isDragActive', true)
408
408
  expect(child).toHaveProp('isDragAccept', true)
409
409
  expect(child).toHaveProp('isDragReject', true)
410
410
  })
411
411
 
412
- it('should set activeClassName properly', () => {
412
+ it('should set activeClassName properly', async () => {
413
413
  const dropzone = mount(
414
414
  <Dropzone accept="image/*" activeClassName="👏" multiple={false}>
415
415
  {props => <DummyChildComponent {...props} />}
416
416
  </Dropzone>
417
417
  )
418
418
  const child = dropzone.find(DummyChildComponent)
419
- dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
419
+ await dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
420
420
  expect(child).toHaveProp('isDragActive', true)
421
421
  expect(dropzone.hasClass('👏')).toBe(true)
422
422
  })
423
423
 
424
- it('should set rejectClassName properly', () => {
424
+ it('should set rejectClassName properly', async () => {
425
425
  const dropzone = mount(
426
426
  <Dropzone accept="image/*" rejectClassName="👎" multiple={false}>
427
427
  {props => <DummyChildComponent {...props} />}
428
428
  </Dropzone>
429
429
  )
430
430
  const child = dropzone.find(DummyChildComponent)
431
- dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
431
+ await dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
432
432
  expect(child).toHaveProp('isDragReject', true)
433
433
  expect(dropzone.hasClass('👎')).toBe(true)
434
434
  })
435
435
 
436
- it('should set acceptClassName properly', () => {
436
+ it('should set acceptClassName properly', async () => {
437
437
  const dropzone = mount(
438
438
  <Dropzone accept="image/*" acceptClassName="👍" className="foo" multiple={false}>
439
439
  {props => <DummyChildComponent {...props} />}
440
440
  </Dropzone>
441
441
  )
442
442
  const child = dropzone.find(DummyChildComponent)
443
- dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
443
+ await dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
444
444
  expect(child).toHaveProp('isDragAccept', true)
445
445
  expect(dropzone.hasClass('👍')).toBe(true)
446
446
  })
@@ -454,16 +454,16 @@ describe('Dropzone', () => {
454
454
  expect(dropzone.hasClass('🤐')).toBe(true)
455
455
  })
456
456
 
457
- it('should keep dragging active when leaving from arbitrary node', () => {
457
+ it('should keep dragging active when leaving from arbitrary node', async () => {
458
458
  const arbitraryOverlay = mount(<div />)
459
459
  const dropzone = mount(<Dropzone>{props => <DummyChildComponent {...props} />}</Dropzone>)
460
- dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
460
+ await dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
461
461
  dropzone.simulate('dragLeave', { target: arbitraryOverlay })
462
462
  expect(dropzone.state('isDragActive')).toBe(true)
463
463
  expect(dropzone.state('draggedFiles').length > 0).toBe(true)
464
464
  })
465
465
 
466
- it('should apply acceptStyle if multiple is false and single file', () => {
466
+ it('should apply acceptStyle if multiple is false and single file', async () => {
467
467
  const dropzone = mount(
468
468
  <Dropzone
469
469
  accept="image/*"
@@ -474,12 +474,12 @@ describe('Dropzone', () => {
474
474
  {props => <DummyChildComponent {...props} />}
475
475
  </Dropzone>
476
476
  )
477
- dropzone.simulate('dragEnter', { dataTransfer: { files: [images[0]] } })
477
+ await dropzone.simulate('dragEnter', { dataTransfer: { files: [images[0]] } })
478
478
  const mainDiv = dropzone.find('div').at(0)
479
479
  expect(mainDiv).toHaveProp('style', { position: 'relative', ...acceptStyle })
480
480
  })
481
481
 
482
- it('should apply rejectStyle if multiple is false and single bad file type', () => {
482
+ it('should apply rejectStyle if multiple is false and single bad file type', async () => {
483
483
  const dropzone = mount(
484
484
  <Dropzone
485
485
  accept="image/*"
@@ -490,12 +490,12 @@ describe('Dropzone', () => {
490
490
  {props => <DummyChildComponent {...props} />}
491
491
  </Dropzone>
492
492
  )
493
- dropzone.simulate('dragEnter', { dataTransfer: { files: [files[0]] } })
493
+ await dropzone.simulate('dragEnter', { dataTransfer: { files: [files[0]] } })
494
494
  const mainDiv = dropzone.find('div').at(0)
495
495
  expect(mainDiv).toHaveProp('style', { position: 'relative', ...rejectStyle })
496
496
  })
497
497
 
498
- it('should apply acceptStyle + rejectStyle if multiple is false and multiple good file types', () => {
498
+ it('should apply acceptStyle + rejectStyle if multiple is false and multiple good file types', async () => {
499
499
  const dropzone = mount(
500
500
  <Dropzone
501
501
  accept="image/*"
@@ -506,7 +506,7 @@ describe('Dropzone', () => {
506
506
  {props => <DummyChildComponent {...props} />}
507
507
  </Dropzone>
508
508
  )
509
- dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
509
+ await dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
510
510
  const mainDiv = dropzone.find('div').at(0)
511
511
  const expectedStyle = {
512
512
  position: 'relative',
@@ -516,12 +516,12 @@ describe('Dropzone', () => {
516
516
  expect(mainDiv).toHaveProp('style', expectedStyle)
517
517
  })
518
518
 
519
- it('should set proper dragActive state if accept prop changes mid-drag', () => {
519
+ it('should set proper dragActive state if accept prop changes mid-drag', async () => {
520
520
  const dropzone = mount(
521
521
  <Dropzone accept="image/*">{props => <DummyChildComponent {...props} />}</Dropzone>
522
522
  )
523
523
  const child = dropzone.find(DummyChildComponent)
524
- dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
524
+ await dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
525
525
  expect(child).toHaveProp('isDragActive', true)
526
526
  expect(child).toHaveProp('isDragAccept', true)
527
527
  expect(child).toHaveProp('isDragReject', false)
@@ -532,7 +532,7 @@ describe('Dropzone', () => {
532
532
  expect(child).toHaveProp('isDragReject', true)
533
533
  })
534
534
 
535
- it('should expose state to children', () => {
535
+ it('should expose state to children', async () => {
536
536
  const dropzone = mount(
537
537
  <Dropzone accept="image/*">
538
538
  {({ isDragActive, isDragAccept, isDragReject }) => {
@@ -547,13 +547,13 @@ describe('Dropzone', () => {
547
547
  </Dropzone>
548
548
  )
549
549
  expect(dropzone.text()).toEqual('Empty')
550
- dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
550
+ await dropzone.simulate('dragEnter', { dataTransfer: { files: images } })
551
551
  expect(dropzone.text()).toEqual('Active and Accept')
552
- dropzone.simulate('dragEnter', { dataTransfer: { files } })
552
+ await dropzone.simulate('dragEnter', { dataTransfer: { files } })
553
553
  expect(dropzone.text()).toEqual('Active but Reject')
554
554
  })
555
555
 
556
- it('should reset the dragAccept/dragReject state when leaving after a child goes away', () => {
556
+ it('should reset the dragAccept/dragReject state when leaving after a child goes away', async () => {
557
557
  const DragActiveComponent = () => <p>Accept</p>
558
558
  const ChildComponent = () => <p>Child component content</p>
559
559
  const dropzone = mount(
@@ -571,9 +571,9 @@ describe('Dropzone', () => {
571
571
  )
572
572
  const child = dropzone.find(ChildComponent)
573
573
  child.simulate('dragEnter', { dataTransfer: { files } })
574
- dropzone.simulate('dragEnter', { dataTransfer: { files } })
574
+ await dropzone.simulate('dragEnter', { dataTransfer: { files } })
575
575
  // make sure we handle any duplicate dragEnter events that the browser may send us
576
- dropzone.simulate('dragEnter', { dataTransfer: { files } })
576
+ await dropzone.simulate('dragEnter', { dataTransfer: { files } })
577
577
  const dragActiveChild = dropzone.find(DragActiveComponent)
578
578
  expect(dragActiveChild).toBePresent()
579
579
  expect(dragActiveChild).toHaveProp('isDragAccept', true)
@@ -603,7 +603,7 @@ describe('Dropzone', () => {
603
603
  dropRejectedSpy.reset()
604
604
  })
605
605
 
606
- it('should reset the dragActive/dragReject state', () => {
606
+ it('should reset the dragActive/dragReject state', async () => {
607
607
  const dropzone = mount(
608
608
  <Dropzone
609
609
  onDrop={dropSpy}
@@ -614,7 +614,7 @@ describe('Dropzone', () => {
614
614
  </Dropzone>
615
615
  )
616
616
  const child = dropzone.find(DummyChildComponent)
617
- dropzone.simulate('dragEnter', { dataTransfer: { files } })
617
+ await dropzone.simulate('dragEnter', { dataTransfer: { files } })
618
618
  expect(child).toHaveProp('isDragActive', true)
619
619
  expect(child).toHaveProp('isDragReject', false)
620
620
  dropzone.simulate('drop', { dataTransfer: { files } })
@@ -622,47 +622,50 @@ describe('Dropzone', () => {
622
622
  expect(child).toHaveProp('isDragReject', false)
623
623
  })
624
624
 
625
- it('should add valid files to rejected files on a multple drop when multiple false', () => {
625
+ it('should reject invalid file when multiple is false', async () => {
626
626
  const dropzone = mount(<Dropzone accept="image/*" onDrop={dropSpy} multiple={false} />)
627
- dropzone.simulate('drop', { dataTransfer: { files: images } })
628
- const rejected = dropSpy.firstCall.args[0]
627
+ await dropzone.simulate('drop', {
628
+ dataTransfer: { files }
629
+ })
630
+ const [accepted, rejected] = dropSpy.firstCall.args
629
631
  expect(rejected.length).toEqual(1)
632
+ expect(accepted.length).toEqual(0)
630
633
  })
631
634
 
632
- it('should add invalid files to rejected when multiple is false', () => {
635
+ it('should allow single files to be dropped if multiple is false', async () => {
633
636
  const dropzone = mount(<Dropzone accept="image/*" onDrop={dropSpy} multiple={false} />)
634
- dropzone.simulate('drop', {
635
- dataTransfer: { files: images.concat(files) }
636
- })
637
- const rejected = dropSpy.firstCall.args[1]
638
- expect(rejected.length).toEqual(2)
637
+
638
+ await dropzone.simulate('drop', { dataTransfer: { files: [images[0]] } })
639
+ const [accepted, rejected] = dropSpy.firstCall.args
640
+ expect(accepted.length).toEqual(1)
641
+ expect(rejected.length).toEqual(0)
639
642
  })
640
643
 
641
- it('should allow single files to be dropped if multiple is false', () => {
644
+ it('should reject multiple files to be dropped if multiple is false', async () => {
642
645
  const dropzone = mount(<Dropzone accept="image/*" onDrop={dropSpy} multiple={false} />)
643
646
 
644
- dropzone.simulate('drop', { dataTransfer: { files: [images[0]] } })
647
+ await dropzone.simulate('drop', { dataTransfer: { files: images } })
645
648
  const [accepted, rejected] = dropSpy.firstCall.args
646
- expect(accepted.length).toEqual(1)
647
- expect(rejected.length).toEqual(0)
649
+ expect(accepted.length).toEqual(0)
650
+ expect(rejected.length).toEqual(2)
648
651
  })
649
652
 
650
- it('should take all dropped files if multiple is true', () => {
653
+ it('should take all dropped files if multiple is true', async () => {
651
654
  const dropzone = mount(<Dropzone onDrop={dropSpy} multiple />)
652
- dropzone.simulate('drop', { dataTransfer: { files: images } })
655
+ await dropzone.simulate('drop', { dataTransfer: { files: images } })
653
656
  expect(dropSpy.firstCall.args[0]).toHaveLength(2)
654
657
  expect(dropSpy.firstCall.args[0][0].name).toEqual(images[0].name)
655
658
  expect(dropSpy.firstCall.args[0][1].name).toEqual(images[1].name)
656
659
  })
657
660
 
658
- it('should set this.isFileDialogActive to false', () => {
661
+ it('should set this.isFileDialogActive to false', async () => {
659
662
  const dropzone = mount(<Dropzone />)
660
663
  dropzone.instance().isFileDialogActive = true
661
- dropzone.simulate('drop', { dataTransfer: { files } })
664
+ await dropzone.simulate('drop', { dataTransfer: { files } })
662
665
  expect(dropzone.instance().isFileDialogActive).toEqual(false)
663
666
  })
664
667
 
665
- it('should always call onDrop callback with accepted and rejected arguments', () => {
668
+ it('should always call onDrop callback with accepted and rejected arguments', async () => {
666
669
  const dropzone = mount(
667
670
  <Dropzone
668
671
  onDrop={dropSpy}
@@ -671,20 +674,20 @@ describe('Dropzone', () => {
671
674
  accept="image/*"
672
675
  />
673
676
  )
674
- dropzone.simulate('drop', { dataTransfer: { files } })
677
+ await dropzone.simulate('drop', { dataTransfer: { files } })
675
678
  expect(dropSpy.callCount).toEqual(1)
676
679
  expect(dropSpy.firstCall.args[0]).toEqual([], [...files])
677
- dropzone.simulate('drop', { dataTransfer: { files: images } })
680
+ await dropzone.simulate('drop', { dataTransfer: { files: images } })
678
681
  expect(dropSpy.callCount).toEqual(2)
679
682
  expect(dropSpy.lastCall.args[0]).toEqual([...images], [])
680
- dropzone.simulate('drop', {
683
+ await dropzone.simulate('drop', {
681
684
  dataTransfer: { files: files.concat(images) }
682
685
  })
683
686
  expect(dropSpy.callCount).toEqual(3)
684
687
  expect(dropSpy.lastCall.args[0]).toEqual([...images], [...files])
685
688
  })
686
689
 
687
- it('should call onDropAccepted callback if some files were accepted', () => {
690
+ it('should call onDropAccepted callback if some files were accepted', async () => {
688
691
  const dropzone = mount(
689
692
  <Dropzone
690
693
  onDrop={dropSpy}
@@ -693,19 +696,19 @@ describe('Dropzone', () => {
693
696
  accept="image/*"
694
697
  />
695
698
  )
696
- dropzone.simulate('drop', { dataTransfer: { files } })
699
+ await dropzone.simulate('drop', { dataTransfer: { files } })
697
700
  expect(dropAcceptedSpy.callCount).toEqual(0)
698
- dropzone.simulate('drop', { dataTransfer: { files: images } })
701
+ await dropzone.simulate('drop', { dataTransfer: { files: images } })
699
702
  expect(dropAcceptedSpy.callCount).toEqual(1)
700
703
  expect(dropAcceptedSpy.lastCall.args[0]).toEqual([...images])
701
- dropzone.simulate('drop', {
704
+ await dropzone.simulate('drop', {
702
705
  dataTransfer: { files: files.concat(images) }
703
706
  })
704
707
  expect(dropAcceptedSpy.callCount).toEqual(2)
705
708
  expect(dropAcceptedSpy.lastCall.args[0]).toEqual([...images])
706
709
  })
707
710
 
708
- it('should call onDropRejected callback if some files were rejected', () => {
711
+ it('should call onDropRejected callback if some files were rejected', async () => {
709
712
  const dropzone = mount(
710
713
  <Dropzone
711
714
  onDrop={dropSpy}
@@ -714,19 +717,19 @@ describe('Dropzone', () => {
714
717
  accept="image/*"
715
718
  />
716
719
  )
717
- dropzone.simulate('drop', { dataTransfer: { files } })
720
+ await dropzone.simulate('drop', { dataTransfer: { files } })
718
721
  expect(dropRejectedSpy.callCount).toEqual(1)
719
722
  expect(dropRejectedSpy.lastCall.args[0]).toEqual([...files])
720
- dropzone.simulate('drop', { dataTransfer: { files: images } })
723
+ await dropzone.simulate('drop', { dataTransfer: { files: images } })
721
724
  expect(dropRejectedSpy.callCount).toEqual(1)
722
- dropzone.simulate('drop', {
725
+ await dropzone.simulate('drop', {
723
726
  dataTransfer: { files: files.concat(images) }
724
727
  })
725
728
  expect(dropRejectedSpy.callCount).toEqual(2)
726
729
  expect(dropRejectedSpy.lastCall.args[0]).toEqual([...files])
727
730
  })
728
731
 
729
- it('applies the accept prop to the dropped files', () => {
732
+ it('applies the accept prop to the dropped files', async () => {
730
733
  const dropzone = mount(
731
734
  <Dropzone
732
735
  onDrop={dropSpy}
@@ -735,7 +738,7 @@ describe('Dropzone', () => {
735
738
  accept="image/*"
736
739
  />
737
740
  )
738
- dropzone.simulate('drop', { dataTransfer: { files } })
741
+ await dropzone.simulate('drop', { dataTransfer: { files } })
739
742
  expect(dropSpy.callCount).toEqual(1)
740
743
  expect(dropSpy.firstCall.args[0]).toHaveLength(0)
741
744
  expect(dropSpy.firstCall.args[1]).toHaveLength(1)
@@ -744,7 +747,7 @@ describe('Dropzone', () => {
744
747
  expect(dropRejectedSpy.firstCall.args[0]).toHaveLength(1)
745
748
  })
746
749
 
747
- it('applies the accept prop to the dropped images', () => {
750
+ it('applies the accept prop to the dropped images', async () => {
748
751
  const dropzone = mount(
749
752
  <Dropzone
750
753
  onDrop={dropSpy}
@@ -754,7 +757,7 @@ describe('Dropzone', () => {
754
757
  />
755
758
  )
756
759
 
757
- dropzone.simulate('drop', { dataTransfer: { files: images } })
760
+ await dropzone.simulate('drop', { dataTransfer: { files: images } })
758
761
  expect(dropSpy.callCount).toEqual(1)
759
762
  expect(dropSpy.firstCall.args[0]).toHaveLength(2)
760
763
  expect(dropSpy.firstCall.args[1]).toHaveLength(0)
@@ -763,7 +766,7 @@ describe('Dropzone', () => {
763
766
  expect(dropRejectedSpy.callCount).toEqual(0)
764
767
  })
765
768
 
766
- it('accepts a dropped image when Firefox provides a bogus file type', () => {
769
+ it('accepts a dropped image when Firefox provides a bogus file type', async () => {
767
770
  const dropzone = mount(
768
771
  <Dropzone
769
772
  onDrop={dropSpy}
@@ -780,7 +783,7 @@ describe('Dropzone', () => {
780
783
  }
781
784
  ]
782
785
 
783
- dropzone.simulate('drop', { dataTransfer: { files: bogusImages } })
786
+ await dropzone.simulate('drop', { dataTransfer: { files: bogusImages } })
784
787
  expect(dropSpy.callCount).toEqual(1)
785
788
  expect(dropSpy.firstCall.args[0]).toHaveLength(1)
786
789
  expect(dropSpy.firstCall.args[1]).toHaveLength(0)
@@ -789,7 +792,7 @@ describe('Dropzone', () => {
789
792
  expect(dropRejectedSpy.callCount).toEqual(0)
790
793
  })
791
794
 
792
- it('accepts all dropped files and images when no accept prop is specified', () => {
795
+ it('accepts all dropped files and images when no accept prop is specified', async () => {
793
796
  const dropzone = mount(
794
797
  <Dropzone
795
798
  onDrop={dropSpy}
@@ -797,7 +800,7 @@ describe('Dropzone', () => {
797
800
  onDropRejected={dropRejectedSpy}
798
801
  />
799
802
  )
800
- dropzone.simulate('drop', {
803
+ await dropzone.simulate('drop', {
801
804
  dataTransfer: { files: files.concat(images) }
802
805
  })
803
806
  expect(dropSpy.callCount).toEqual(1)
@@ -808,7 +811,7 @@ describe('Dropzone', () => {
808
811
  expect(dropRejectedSpy.callCount).toEqual(0)
809
812
  })
810
813
 
811
- it('applies the maxSize prop to the dropped files', () => {
814
+ it('applies the maxSize prop to the dropped files', async () => {
812
815
  const dropzone = mount(
813
816
  <Dropzone
814
817
  onDrop={dropSpy}
@@ -818,7 +821,7 @@ describe('Dropzone', () => {
818
821
  />
819
822
  )
820
823
 
821
- dropzone.simulate('drop', { dataTransfer: { files } })
824
+ await dropzone.simulate('drop', { dataTransfer: { files } })
822
825
  expect(dropSpy.callCount).toEqual(1)
823
826
  expect(dropSpy.firstCall.args[0]).toHaveLength(1)
824
827
  expect(dropSpy.firstCall.args[1]).toHaveLength(0)
@@ -827,7 +830,7 @@ describe('Dropzone', () => {
827
830
  expect(dropRejectedSpy.callCount).toEqual(0)
828
831
  })
829
832
 
830
- it('applies the maxSize prop to the dropped images', () => {
833
+ it('applies the maxSize prop to the dropped images', async () => {
831
834
  const dropzone = mount(
832
835
  <Dropzone
833
836
  onDrop={dropSpy}
@@ -836,7 +839,7 @@ describe('Dropzone', () => {
836
839
  maxSize={1111}
837
840
  />
838
841
  )
839
- dropzone.simulate('drop', { dataTransfer: { files: images } })
842
+ await dropzone.simulate('drop', { dataTransfer: { files: images } })
840
843
  expect(dropSpy.callCount).toEqual(1)
841
844
  expect(dropSpy.firstCall.args[0]).toHaveLength(0)
842
845
  expect(dropSpy.firstCall.args[1]).toHaveLength(2)
@@ -845,7 +848,7 @@ describe('Dropzone', () => {
845
848
  expect(dropRejectedSpy.firstCall.args[0]).toHaveLength(2)
846
849
  })
847
850
 
848
- it('applies the minSize prop to the dropped files', () => {
851
+ it('applies the minSize prop to the dropped files', async () => {
849
852
  const dropzone = mount(
850
853
  <Dropzone
851
854
  onDrop={dropSpy}
@@ -854,7 +857,7 @@ describe('Dropzone', () => {
854
857
  minSize={1112}
855
858
  />
856
859
  )
857
- dropzone.simulate('drop', { dataTransfer: { files } })
860
+ await dropzone.simulate('drop', { dataTransfer: { files } })
858
861
  expect(dropSpy.callCount).toEqual(1)
859
862
  expect(dropSpy.firstCall.args[0]).toHaveLength(0)
860
863
  expect(dropSpy.firstCall.args[1]).toHaveLength(1)
@@ -863,7 +866,7 @@ describe('Dropzone', () => {
863
866
  expect(dropRejectedSpy.firstCall.args[0]).toHaveLength(1)
864
867
  })
865
868
 
866
- it('applies the minSize prop to the dropped images', () => {
869
+ it('applies the minSize prop to the dropped images', async () => {
867
870
  const dropzone = mount(
868
871
  <Dropzone
869
872
  onDrop={dropSpy}
@@ -872,7 +875,7 @@ describe('Dropzone', () => {
872
875
  minSize={1112}
873
876
  />
874
877
  )
875
- dropzone.simulate('drop', { dataTransfer: { files: images } })
878
+ await dropzone.simulate('drop', { dataTransfer: { files: images } })
876
879
  expect(dropSpy.callCount).toEqual(1)
877
880
  expect(dropSpy.firstCall.args[0]).toHaveLength(2)
878
881
  expect(dropSpy.firstCall.args[1]).toHaveLength(0)
@@ -881,7 +884,7 @@ describe('Dropzone', () => {
881
884
  expect(dropRejectedSpy.callCount).toEqual(0)
882
885
  })
883
886
 
884
- it('accepts all dropped files and images when no size prop is specified', () => {
887
+ it('accepts all dropped files and images when no size prop is specified', async () => {
885
888
  const dropzone = mount(
886
889
  <Dropzone
887
890
  onDrop={dropSpy}
@@ -889,7 +892,7 @@ describe('Dropzone', () => {
889
892
  onDropRejected={dropRejectedSpy}
890
893
  />
891
894
  )
892
- dropzone.simulate('drop', {
895
+ await dropzone.simulate('drop', {
893
896
  dataTransfer: { files: files.concat(images) }
894
897
  })
895
898
  expect(dropSpy.callCount).toEqual(1)
@@ -902,36 +905,36 @@ describe('Dropzone', () => {
902
905
  })
903
906
 
904
907
  describe('preview', () => {
905
- it('should generate previews for non-images', () => {
908
+ it('should generate previews for non-images', async () => {
906
909
  const dropSpy = spy()
907
910
  const dropzone = mount(<Dropzone onDrop={dropSpy} />)
908
- dropzone.simulate('drop', { dataTransfer: { files } })
911
+ await dropzone.simulate('drop', { dataTransfer: { files } })
909
912
  expect(Object.keys(dropSpy.firstCall.args[0][0])).toContain('preview')
910
913
  expect(dropSpy.firstCall.args[0][0].preview).toContain('data://file1.pdf')
911
914
  })
912
915
 
913
- it('should generate previews for images', () => {
916
+ it('should generate previews for images', async () => {
914
917
  const dropSpy = spy()
915
918
  const dropzone = mount(<Dropzone onDrop={dropSpy} />)
916
- dropzone.simulate('drop', { dataTransfer: { files: images } })
919
+ await dropzone.simulate('drop', { dataTransfer: { files: images } })
917
920
  expect(Object.keys(dropSpy.firstCall.args[0][0])).toContain('preview')
918
921
  expect(dropSpy.firstCall.args[0][0].preview).toContain('data://cats.gif')
919
922
  })
920
923
 
921
- it('should not throw error when preview cannot be created', () => {
924
+ it('should not throw error when preview cannot be created', async () => {
922
925
  const dropSpy = spy()
923
926
  const dropzone = mount(<Dropzone onDrop={dropSpy} />)
924
927
 
925
- dropzone.simulate('drop', { dataTransfer: { files: ['bad_val'] } })
928
+ await dropzone.simulate('drop', { dataTransfer: { files: ['bad_val'] } })
926
929
 
927
930
  expect(Object.keys(dropSpy.firstCall.args[1][0])).not.toContain('preview')
928
931
  })
929
932
 
930
- it('should not generate previews if disablePreview is true', () => {
933
+ it('should not generate previews if disablePreview is true', async () => {
931
934
  const dropSpy = spy()
932
935
  const dropzone = mount(<Dropzone disablePreview onDrop={dropSpy} />)
933
- dropzone.simulate('drop', { dataTransfer: { files: images } })
934
- dropzone.simulate('drop', { dataTransfer: { files } })
936
+ await dropzone.simulate('drop', { dataTransfer: { files: images } })
937
+ await dropzone.simulate('drop', { dataTransfer: { files } })
935
938
  expect(dropSpy.callCount).toEqual(2)
936
939
  expect(Object.keys(dropSpy.firstCall.args[0][0])).not.toContain('preview')
937
940
  expect(Object.keys(dropSpy.lastCall.args[0][0])).not.toContain('preview')
@@ -1052,8 +1055,8 @@ describe('Dropzone', () => {
1052
1055
  innerDropzone = outerDropzone.find(InnerDropzone)
1053
1056
  })
1054
1057
 
1055
- it('does dragEnter on both dropzones', () => {
1056
- innerDropzone.simulate('dragEnter', {
1058
+ it('does dragEnter on both dropzones', async () => {
1059
+ await innerDropzone.simulate('dragEnter', {
1057
1060
  dataTransfer: { files: images }
1058
1061
  })
1059
1062
  expect(innerDropzone).toHaveProp('isDragActive', true)
@@ -9,6 +9,7 @@ export function getDataTransferItems(event) {
9
9
  let dataTransferItemsList = []
10
10
  if (event.dataTransfer) {
11
11
  const dt = event.dataTransfer
12
+
12
13
  if (dt.files && dt.files.length) {
13
14
  dataTransferItemsList = dt.files
14
15
  } else if (dt.items && dt.items.length) {
@@ -19,6 +20,7 @@ export function getDataTransferItems(event) {
19
20
  } else if (event.target && event.target.files) {
20
21
  dataTransferItemsList = event.target.files
21
22
  }
23
+
22
24
  // Convert from DataTransferItemsList to the native Array
23
25
  return Array.prototype.slice.call(dataTransferItemsList)
24
26
  }