@@ -45,7 +45,8 @@ describe('updateRecordFactory', () => {
4545 recordStub = createStubInstance ( BaseRecord , {
4646 id : sinon . stub < any , string > ( ) . returns ( '1' ) ,
4747 isValid : sinon . stub < any , boolean > ( ) . returns ( true ) ,
48- update : sinon . stub < any , Promise < BaseRecord > > ( ) . returnsThis ( ) ,
48+ save : sinon . stub < [ ] , Promise < BaseRecord > > ( ) . returnsThis ( ) ,
49+ storeParams : sinon . stub < any , void > ( ) ,
4950 } )
5051 recordStub . params = { }
5152 } )
@@ -92,13 +93,14 @@ describe('updateRecordFactory', () => {
9293 it ( 'updates all fields in the record' , async ( ) => {
9394 await updateRecord ( response , request , actionContext )
9495
95- expect ( recordStub . update ) . to . have . been . calledWith ( sinon . match ( {
96+ expect ( recordStub . storeParams ) . to . have . been . calledWith ( sinon . match ( {
9697 [ uploadOptions . properties . key ] : expectedKey ,
9798 [ uploadOptions . properties . bucket as string ] : provider . bucket ,
9899 [ uploadOptions . properties . size as string ] : File . size . toString ( ) ,
99100 [ uploadOptions . properties . mimeType as string ] : File . type ,
100101 [ uploadOptions . properties . filename as string ] : File . name ,
101102 } ) )
103+ expect ( recordStub . save ) . to . have . been . calledWith ( )
102104 } )
103105
104106 it ( 'does not delete any old file if there were not file before' , async ( ) => {
@@ -138,13 +140,14 @@ describe('updateRecordFactory', () => {
138140
139141 expect ( provider . delete ) . to . have . been . calledWith ( expectedKey , storedBucket )
140142
141- expect ( recordStub . update ) . to . have . been . calledWith ( sinon . match ( {
143+ expect ( recordStub . storeParams ) . to . have . been . calledWith ( sinon . match ( {
142144 [ uploadOptions . properties . key ] : null ,
143145 [ uploadOptions . properties . bucket as string ] : null ,
144146 [ uploadOptions . properties . size as string ] : null ,
145147 [ uploadOptions . properties . mimeType as string ] : null ,
146148 [ uploadOptions . properties . filename as string ] : null ,
147149 } ) )
150+ expect ( recordStub . save ) . to . have . been . calledWith ( )
148151 } )
149152 } )
150153
@@ -188,11 +191,12 @@ describe('updateRecordFactory', () => {
188191 [ `${ uploadOptions . properties . filename } .${ index } ` as string ] : Files [ index ] . name ,
189192 } )
190193
191- expect ( recordStub . update ) . to . have . been . calledWith ( sinon . match ( {
194+ expect ( recordStub . storeParams ) . to . have . been . calledWith ( sinon . match ( {
192195 ...values ( 0 ) ,
193196 ...values ( 1 ) ,
194197 ...values ( 2 ) ,
195198 } ) )
199+ expect ( recordStub . save ) . to . have . been . calledWith ( )
196200 } )
197201 } )
198202
@@ -226,19 +230,22 @@ describe('updateRecordFactory', () => {
226230 } ,
227231 record : new BaseRecord ( oldParams , { } as BaseResource ) ,
228232 } as unknown as ActionContext
229- sinon . stub ( BaseRecord . prototype , 'update' )
233+ sinon . stub ( BaseRecord . prototype , 'save' )
234+ sinon . stub ( BaseRecord . prototype , 'storeParams' )
235+ sinon . stub ( BaseRecord . prototype , 'toJSON' )
230236
231237 updateRecord = updateRecordFactory ( uploadOptions , provider )
232238 } )
233239
234240 it ( 'removes files from the database' , async ( ) => {
235241 await updateRecord ( response , request , actionContext )
236242
237- expect ( BaseRecord . prototype . update ) . to . have . been . calledWith ( {
243+ expect ( BaseRecord . prototype . storeParams ) . to . have . been . calledWith ( {
238244 'media.key.0' : 'key1' ,
239245 'media.bucket.0' : 'bucket1' ,
240246 'media.type.0' : 'mime1' ,
241247 } )
248+ expect ( BaseRecord . prototype . save ) . to . have . been . calledWith ( )
242249 } )
243250
244251 it ( 'removes files from the adapter store' , async ( ) => {
0 commit comments