@@ -87,6 +87,56 @@ describe('uploadFile', () => {
8787
8888 expect ( actual ) . toEqual ( testDestination . storageId )
8989 } )
90+
91+ test ( 'should include S3 tagging header by default' , async ( ) => {
92+ const filesRepositoryStub : IFilesRepository = { } as IFilesRepository
93+ const testDestination : FileUploadDestination = createSingleFileUploadDestinationModel ( )
94+ filesRepositoryStub . getFileUploadDestination = jest . fn ( ) . mockResolvedValue ( testDestination )
95+
96+ const axiosPutSpy = jest . spyOn ( axios , 'put' ) . mockResolvedValue ( undefined )
97+
98+ const sut = new DirectUploadClient ( filesRepositoryStub )
99+
100+ const progressMock = jest . fn ( )
101+ const abortController = new AbortController ( )
102+
103+ await sut . uploadFile ( 1 , testFile , progressMock , abortController )
104+
105+ expect ( axiosPutSpy ) . toHaveBeenCalledWith (
106+ testDestination . urls [ 0 ] ,
107+ expect . anything ( ) ,
108+ expect . objectContaining ( {
109+ headers : expect . objectContaining ( {
110+ 'x-amz-tagging' : 'dv-state=temp'
111+ } )
112+ } )
113+ )
114+ } )
115+
116+ test ( 'should not include S3 tagging header when useS3Tagging is false' , async ( ) => {
117+ const filesRepositoryStub : IFilesRepository = { } as IFilesRepository
118+ const testDestination : FileUploadDestination = createSingleFileUploadDestinationModel ( )
119+ filesRepositoryStub . getFileUploadDestination = jest . fn ( ) . mockResolvedValue ( testDestination )
120+
121+ const axiosPutSpy = jest . spyOn ( axios , 'put' ) . mockResolvedValue ( undefined )
122+
123+ const sut = new DirectUploadClient ( filesRepositoryStub , { useS3Tagging : false } )
124+
125+ const progressMock = jest . fn ( )
126+ const abortController = new AbortController ( )
127+
128+ await sut . uploadFile ( 1 , testFile , progressMock , abortController )
129+
130+ expect ( axiosPutSpy ) . toHaveBeenCalledWith (
131+ testDestination . urls [ 0 ] ,
132+ expect . anything ( ) ,
133+ expect . objectContaining ( {
134+ headers : expect . not . objectContaining ( {
135+ 'x-amz-tagging' : expect . anything ( )
136+ } )
137+ } )
138+ )
139+ } )
90140 } )
91141
92142 describe ( 'Multiple parts file' , ( ) => {
@@ -113,7 +163,7 @@ describe('uploadFile', () => {
113163 jest . spyOn ( axios , 'delete' ) . mockResolvedValue ( undefined )
114164 jest . spyOn ( axios , 'put' ) . mockRejectedValue ( 'error' )
115165
116- const sut = new DirectUploadClient ( filesRepositoryStub , 1 )
166+ const sut = new DirectUploadClient ( filesRepositoryStub , { maxMultipartRetries : 1 } )
117167
118168 const progressMock = jest . fn ( )
119169 const abortController = new AbortController ( )
@@ -143,7 +193,7 @@ describe('uploadFile', () => {
143193 const progressMock = jest . fn ( )
144194 const abortController = new AbortController ( )
145195
146- const sut = new DirectUploadClient ( filesRepositoryStub , 1 )
196+ const sut = new DirectUploadClient ( filesRepositoryStub , { maxMultipartRetries : 1 } )
147197
148198 await expect ( sut . uploadFile ( 1 , testFile , progressMock , abortController ) ) . rejects . toThrow (
149199 MultipartAbortError
@@ -165,7 +215,7 @@ describe('uploadFile', () => {
165215 const progressMock = jest . fn ( )
166216 const abortController = new AbortController ( )
167217
168- const sut = new DirectUploadClient ( filesRepositoryStub , 1 )
218+ const sut = new DirectUploadClient ( filesRepositoryStub , { maxMultipartRetries : 1 } )
169219 await expect ( sut . uploadFile ( 1 , testFile , progressMock , abortController ) ) . rejects . toThrow (
170220 MultipartCompletionError
171221 )
@@ -187,7 +237,7 @@ describe('uploadFile', () => {
187237 . mockResolvedValueOnce ( successfulPartResponse )
188238 . mockResolvedValueOnce ( undefined )
189239
190- const sut = new DirectUploadClient ( filesRepositoryStub , 1 )
240+ const sut = new DirectUploadClient ( filesRepositoryStub , { maxMultipartRetries : 1 } )
191241
192242 const progressMock = jest . fn ( )
193243 const abortController = new AbortController ( )
0 commit comments