@@ -45,7 +45,8 @@ describe('updateRecordFactory', () => {
45
45
recordStub = createStubInstance ( BaseRecord , {
46
46
id : sinon . stub < any , string > ( ) . returns ( '1' ) ,
47
47
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 > ( ) ,
49
50
} )
50
51
recordStub . params = { }
51
52
} )
@@ -92,13 +93,14 @@ describe('updateRecordFactory', () => {
92
93
it ( 'updates all fields in the record' , async ( ) => {
93
94
await updateRecord ( response , request , actionContext )
94
95
95
- expect ( recordStub . update ) . to . have . been . calledWith ( sinon . match ( {
96
+ expect ( recordStub . storeParams ) . to . have . been . calledWith ( sinon . match ( {
96
97
[ uploadOptions . properties . key ] : expectedKey ,
97
98
[ uploadOptions . properties . bucket as string ] : provider . bucket ,
98
99
[ uploadOptions . properties . size as string ] : File . size . toString ( ) ,
99
100
[ uploadOptions . properties . mimeType as string ] : File . type ,
100
101
[ uploadOptions . properties . filename as string ] : File . name ,
101
102
} ) )
103
+ expect ( recordStub . save ) . to . have . been . calledWith ( )
102
104
} )
103
105
104
106
it ( 'does not delete any old file if there were not file before' , async ( ) => {
@@ -138,13 +140,14 @@ describe('updateRecordFactory', () => {
138
140
139
141
expect ( provider . delete ) . to . have . been . calledWith ( expectedKey , storedBucket )
140
142
141
- expect ( recordStub . update ) . to . have . been . calledWith ( sinon . match ( {
143
+ expect ( recordStub . storeParams ) . to . have . been . calledWith ( sinon . match ( {
142
144
[ uploadOptions . properties . key ] : null ,
143
145
[ uploadOptions . properties . bucket as string ] : null ,
144
146
[ uploadOptions . properties . size as string ] : null ,
145
147
[ uploadOptions . properties . mimeType as string ] : null ,
146
148
[ uploadOptions . properties . filename as string ] : null ,
147
149
} ) )
150
+ expect ( recordStub . save ) . to . have . been . calledWith ( )
148
151
} )
149
152
} )
150
153
@@ -188,11 +191,12 @@ describe('updateRecordFactory', () => {
188
191
[ `${ uploadOptions . properties . filename } .${ index } ` as string ] : Files [ index ] . name ,
189
192
} )
190
193
191
- expect ( recordStub . update ) . to . have . been . calledWith ( sinon . match ( {
194
+ expect ( recordStub . storeParams ) . to . have . been . calledWith ( sinon . match ( {
192
195
...values ( 0 ) ,
193
196
...values ( 1 ) ,
194
197
...values ( 2 ) ,
195
198
} ) )
199
+ expect ( recordStub . save ) . to . have . been . calledWith ( )
196
200
} )
197
201
} )
198
202
@@ -226,19 +230,22 @@ describe('updateRecordFactory', () => {
226
230
} ,
227
231
record : new BaseRecord ( oldParams , { } as BaseResource ) ,
228
232
} 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' )
230
236
231
237
updateRecord = updateRecordFactory ( uploadOptions , provider )
232
238
} )
233
239
234
240
it ( 'removes files from the database' , async ( ) => {
235
241
await updateRecord ( response , request , actionContext )
236
242
237
- expect ( BaseRecord . prototype . update ) . to . have . been . calledWith ( {
243
+ expect ( BaseRecord . prototype . storeParams ) . to . have . been . calledWith ( {
238
244
'media.key.0' : 'key1' ,
239
245
'media.bucket.0' : 'bucket1' ,
240
246
'media.type.0' : 'mime1' ,
241
247
} )
248
+ expect ( BaseRecord . prototype . save ) . to . have . been . calledWith ( )
242
249
} )
243
250
244
251
it ( 'removes files from the adapter store' , async ( ) => {
0 commit comments