@@ -232,7 +232,11 @@ describe('S3Adapter tests', () => {
232
232
expect ( resp . writeHead ) . toHaveBeenCalled ( ) ;
233
233
expect ( resp . write ) . toHaveBeenCalled ( ) ;
234
234
expect ( resp . end ) . toHaveBeenCalled ( ) ;
235
- const commandArg = s3ClientMock . send . calls . mostRecent ( ) . args [ 0 ] ;
235
+ const commands = s3ClientMock . send . calls . all ( ) ;
236
+ expect ( commands . length ) . toBe ( 2 ) ;
237
+ expect ( commands [ 0 ] . args [ 0 ] ) . toBeInstanceOf ( CreateBucketCommand ) ;
238
+ const commandArg = commands [ 1 ] . args [ 0 ] ;
239
+ expect ( commandArg ) . toBeInstanceOf ( GetObjectCommand ) ;
236
240
expect ( commandArg . input . Range ) . toBe ( 'bytes=0-1' ) ;
237
241
} ) ;
238
242
} ) ;
@@ -588,7 +592,11 @@ describe('S3Adapter tests', () => {
588
592
const metadata = { foo : 'bar' } ;
589
593
590
594
await s3 . createFile ( 'file.txt' , 'hello world' , 'text/utf8' , { metadata } ) ;
591
- const commandArg = s3ClientMock . send . calls . mostRecent ( ) . args [ 0 ] ;
595
+ const commands = s3ClientMock . send . calls . all ( ) ;
596
+ expect ( commands . length ) . toBe ( 2 ) ;
597
+ expect ( commands [ 0 ] . args [ 0 ] ) . toBeInstanceOf ( CreateBucketCommand ) ;
598
+ const commandArg = commands [ 1 ] . args [ 0 ] ;
599
+ expect ( commandArg ) . toBeInstanceOf ( PutObjectCommand ) ;
592
600
expect ( commandArg . input . Metadata ) . toEqual ( { foo : 'bar' } ) ;
593
601
} ) ;
594
602
@@ -598,7 +606,11 @@ describe('S3Adapter tests', () => {
598
606
const tags = { foo : 'bar' , baz : 'bin' } ;
599
607
600
608
await s3 . createFile ( 'file.txt' , 'hello world' , 'text/utf8' , { tags } ) ;
601
- const commandArg = s3ClientMock . send . calls . mostRecent ( ) . args [ 0 ] ;
609
+ const commands = s3ClientMock . send . calls . all ( ) ;
610
+ expect ( commands . length ) . toBe ( 2 ) ;
611
+ expect ( commands [ 0 ] . args [ 0 ] ) . toBeInstanceOf ( CreateBucketCommand ) ;
612
+ const commandArg = commands [ 1 ] . args [ 0 ] ;
613
+ expect ( commandArg ) . toBeInstanceOf ( PutObjectCommand ) ;
602
614
expect ( commandArg . input . Tagging ) . toBe ( 'foo=bar&baz=bin' ) ;
603
615
} ) ;
604
616
@@ -608,7 +620,11 @@ describe('S3Adapter tests', () => {
608
620
s3 . _s3Client = s3ClientMock ;
609
621
610
622
await s3 . createFile ( 'file.txt' , 'hello world' , 'text/utf8' , { } ) ;
611
- const commandArg = s3ClientMock . send . calls . mostRecent ( ) . args [ 0 ] ;
623
+ const commands = s3ClientMock . send . calls . all ( ) ;
624
+ expect ( commands . length ) . toBe ( 2 ) ;
625
+ expect ( commands [ 0 ] . args [ 0 ] ) . toBeInstanceOf ( CreateBucketCommand ) ;
626
+ const commandArg = commands [ 1 ] . args [ 0 ] ;
627
+ expect ( commandArg ) . toBeInstanceOf ( PutObjectCommand ) ;
612
628
expect ( commandArg . input . ACL ) . toBe ( 'public-read' ) ;
613
629
} ) ;
614
630
@@ -617,7 +633,11 @@ describe('S3Adapter tests', () => {
617
633
s3 . _s3Client = s3ClientMock ;
618
634
619
635
await s3 . createFile ( 'file.txt' , 'hello world' , 'text/utf8' , { } ) ;
620
- const commandArg = s3ClientMock . send . calls . mostRecent ( ) . args [ 0 ] ;
636
+ const commands = s3ClientMock . send . calls . all ( ) ;
637
+ expect ( commands . length ) . toBe ( 2 ) ;
638
+ expect ( commands [ 0 ] . args [ 0 ] ) . toBeInstanceOf ( CreateBucketCommand ) ;
639
+ const commandArg = commands [ 1 ] . args [ 0 ] ;
640
+ expect ( commandArg ) . toBeInstanceOf ( PutObjectCommand ) ;
621
641
expect ( commandArg . input . ACL ) . toBeUndefined ( ) ;
622
642
} ) ;
623
643
@@ -628,7 +648,11 @@ describe('S3Adapter tests', () => {
628
648
s3 . _s3Client = s3ClientMock ;
629
649
630
650
await s3 . createFile ( 'file.txt' , 'hello world' , 'text/utf8' , { } ) ;
631
- const commandArg = s3ClientMock . send . calls . mostRecent ( ) . args [ 0 ] ;
651
+ const commands = s3ClientMock . send . calls . all ( ) ;
652
+ expect ( commands . length ) . toBe ( 2 ) ;
653
+ expect ( commands [ 0 ] . args [ 0 ] ) . toBeInstanceOf ( CreateBucketCommand ) ;
654
+ const commandArg = commands [ 1 ] . args [ 0 ] ;
655
+ expect ( commandArg ) . toBeInstanceOf ( PutObjectCommand ) ;
632
656
expect ( commandArg . input . ACL ) . toBe ( 'private' ) ;
633
657
} ) ;
634
658
@@ -640,7 +664,11 @@ describe('S3Adapter tests', () => {
640
664
s3 . _s3Client = s3ClientMock ;
641
665
642
666
await s3 . createFile ( 'file.txt' , 'hello world' , 'text/utf8' , { } ) ;
643
- const commandArg = s3ClientMock . send . calls . mostRecent ( ) . args [ 0 ] ;
667
+ const commands = s3ClientMock . send . calls . all ( ) ;
668
+ expect ( commands . length ) . toBe ( 2 ) ;
669
+ expect ( commands [ 0 ] . args [ 0 ] ) . toBeInstanceOf ( CreateBucketCommand ) ;
670
+ const commandArg = commands [ 1 ] . args [ 0 ] ;
671
+ expect ( commandArg ) . toBeInstanceOf ( PutObjectCommand ) ;
644
672
expect ( commandArg . input . ACL ) . toBeUndefined ( ) ;
645
673
} ) ;
646
674
} ) ;
0 commit comments