@@ -232,7 +232,11 @@ describe('S3Adapter tests', () => {
232232 expect ( resp . writeHead ) . toHaveBeenCalled ( ) ;
233233 expect ( resp . write ) . toHaveBeenCalled ( ) ;
234234 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 ) ;
236240 expect ( commandArg . input . Range ) . toBe ( 'bytes=0-1' ) ;
237241 } ) ;
238242 } ) ;
@@ -588,7 +592,11 @@ describe('S3Adapter tests', () => {
588592 const metadata = { foo : 'bar' } ;
589593
590594 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 ) ;
592600 expect ( commandArg . input . Metadata ) . toEqual ( { foo : 'bar' } ) ;
593601 } ) ;
594602
@@ -598,7 +606,11 @@ describe('S3Adapter tests', () => {
598606 const tags = { foo : 'bar' , baz : 'bin' } ;
599607
600608 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 ) ;
602614 expect ( commandArg . input . Tagging ) . toBe ( 'foo=bar&baz=bin' ) ;
603615 } ) ;
604616
@@ -608,7 +620,11 @@ describe('S3Adapter tests', () => {
608620 s3 . _s3Client = s3ClientMock ;
609621
610622 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 ) ;
612628 expect ( commandArg . input . ACL ) . toBe ( 'public-read' ) ;
613629 } ) ;
614630
@@ -617,7 +633,11 @@ describe('S3Adapter tests', () => {
617633 s3 . _s3Client = s3ClientMock ;
618634
619635 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 ) ;
621641 expect ( commandArg . input . ACL ) . toBeUndefined ( ) ;
622642 } ) ;
623643
@@ -628,7 +648,11 @@ describe('S3Adapter tests', () => {
628648 s3 . _s3Client = s3ClientMock ;
629649
630650 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 ) ;
632656 expect ( commandArg . input . ACL ) . toBe ( 'private' ) ;
633657 } ) ;
634658
@@ -640,7 +664,11 @@ describe('S3Adapter tests', () => {
640664 s3 . _s3Client = s3ClientMock ;
641665
642666 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 ) ;
644672 expect ( commandArg . input . ACL ) . toBeUndefined ( ) ;
645673 } ) ;
646674 } ) ;
0 commit comments