@@ -273,21 +273,38 @@ describe('Resource', () => {
273
273
} ) ;
274
274
275
275
describe ( 'update' , ( ) => {
276
+ const id = '1' ;
277
+ const attributes = { key : 'value' } ;
278
+ const relationships = { key : 'value' } ;
279
+
276
280
it ( 'can update a record' , ( ) => {
277
- const id = '1' ;
278
- const attributes = { key : 'value' } ;
279
- const relationships = { key : 'value' } ;
280
281
const responseBody = { data : record } ;
281
282
api . patch . mockResolvedValue ( { data : responseBody } ) ;
282
283
283
284
const result = resource . update ( { id, attributes, relationships } ) ;
284
285
285
- expect ( api . patch ) . toHaveBeenCalledWith ( 'widgets/1' , {
286
+ expect ( api . patch ) . toHaveBeenCalledWith ( 'widgets/1? ' , {
286
287
data : { id, type : 'widgets' , attributes, relationships } ,
287
288
} ) ;
288
289
return expect ( result ) . resolves . toEqual ( responseBody ) ;
289
290
} ) ;
290
291
292
+ it ( 'passes options' , ( ) => {
293
+ const responseBody = { data : record } ;
294
+ api . patch . mockResolvedValue ( { data : responseBody } ) ;
295
+
296
+ const result = resource . update ( {
297
+ id,
298
+ attributes,
299
+ relationships,
300
+ options : optionsWithInclude ,
301
+ } ) ;
302
+
303
+ expect ( api . patch ) . toHaveBeenCalledWith ( 'widgets/1?include=comments' , {
304
+ data : { id, type : 'widgets' , attributes, relationships } ,
305
+ } ) ;
306
+ } ) ;
307
+
291
308
it ( 'rejects with the response upon error' , ( ) => {
292
309
const errorResponse = { dummy : 'data' } ;
293
310
api . patch . mockRejectedValue ( { response : errorResponse } ) ;
0 commit comments