@@ -245,16 +245,16 @@ describe('Resource', () => {
245245 } ) ;
246246
247247 describe ( 'create' , ( ) => {
248- it ( 'can create a record' , ( ) => {
249- const attributes = { key : 'value' } ;
250- const relationships = { key2 : 'value2' } ;
248+ const attributes = { key : 'value' } ;
249+ const relationships = { key2 : 'value2' } ;
251250
251+ it ( 'can create a record' , ( ) => {
252252 const responseBody = { data : record } ;
253253 api . post . mockResolvedValue ( { data : responseBody } ) ;
254254
255255 const result = resource . create ( { attributes, relationships} ) ;
256256
257- expect ( api . post ) . toHaveBeenCalledWith ( 'widgets' , {
257+ expect ( api . post ) . toHaveBeenCalledWith ( 'widgets? ' , {
258258 data : {
259259 type : 'widgets' ,
260260 attributes,
@@ -264,6 +264,21 @@ describe('Resource', () => {
264264 return expect ( result ) . resolves . toEqual ( responseBody ) ;
265265 } ) ;
266266
267+ it ( 'passes options' , ( ) => {
268+ const responseBody = { data : record } ;
269+ api . post . mockResolvedValue ( { data : responseBody } ) ;
270+
271+ resource . create ( {
272+ attributes,
273+ relationships,
274+ options : optionsWithInclude ,
275+ } ) ;
276+
277+ expect ( api . post ) . toHaveBeenCalledWith ( 'widgets?include=comments' , {
278+ data : { type : 'widgets' , attributes, relationships} ,
279+ } ) ;
280+ } ) ;
281+
267282 it ( 'rejects with the response upon error' , ( ) => {
268283 const errorResponse = { dummy : 'data' } ;
269284 api . post . mockRejectedValue ( { response : errorResponse } ) ;
0 commit comments