@@ -245,16 +245,16 @@ describe('Resource', () => {
245
245
} ) ;
246
246
247
247
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' } ;
251
250
251
+ it ( 'can create a record' , ( ) => {
252
252
const responseBody = { data : record } ;
253
253
api . post . mockResolvedValue ( { data : responseBody } ) ;
254
254
255
255
const result = resource . create ( { attributes, relationships} ) ;
256
256
257
- expect ( api . post ) . toHaveBeenCalledWith ( 'widgets' , {
257
+ expect ( api . post ) . toHaveBeenCalledWith ( 'widgets? ' , {
258
258
data : {
259
259
type : 'widgets' ,
260
260
attributes,
@@ -264,6 +264,21 @@ describe('Resource', () => {
264
264
return expect ( result ) . resolves . toEqual ( responseBody ) ;
265
265
} ) ;
266
266
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
+
267
282
it ( 'rejects with the response upon error' , ( ) => {
268
283
const errorResponse = { dummy : 'data' } ;
269
284
api . post . mockRejectedValue ( { response : errorResponse } ) ;
0 commit comments