@@ -273,19 +273,38 @@ describe('Resource', () => {
273273 } ) ;
274274
275275 describe ( 'update' , ( ) => {
276+ const id = '1' ;
277+ const attributes = { key : 'value' } ;
278+ const relationships = { key : 'value' } ;
279+
276280 it ( 'can update a record' , ( ) => {
277- const partialRecord = { id : '1' , attributes : { key : 'value' } } ;
278281 const responseBody = { data : record } ;
279282 api . patch . mockResolvedValue ( { data : responseBody } ) ;
280283
281- const result = resource . update ( partialRecord ) ;
284+ const result = resource . update ( { id , attributes , relationships } ) ;
282285
283- expect ( api . patch ) . toHaveBeenCalledWith ( 'widgets/1' , {
284- data : { ... partialRecord , type : 'widgets' } ,
286+ expect ( api . patch ) . toHaveBeenCalledWith ( 'widgets/1? ' , {
287+ data : { id , type : 'widgets' , attributes , relationships } ,
285288 } ) ;
286289 return expect ( result ) . resolves . toEqual ( responseBody ) ;
287290 } ) ;
288291
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+
289308 it ( 'rejects with the response upon error' , ( ) => {
290309 const errorResponse = { dummy : 'data' } ;
291310 api . patch . mockRejectedValue ( { response : errorResponse } ) ;
0 commit comments