1
1
const ResourceClient = require ( '../src/ResourceClient' ) ;
2
2
3
3
describe ( 'ResourceClient' , ( ) => {
4
+ const contentTypeHeaders = {
5
+ headers : { 'Content-Type' : 'application/vnd.api+json' } ,
6
+ } ;
7
+
4
8
const name = 'widgets' ;
5
9
let api ;
6
10
let resource ;
@@ -254,13 +258,17 @@ describe('ResourceClient', () => {
254
258
255
259
const result = resource . create ( { attributes, relationships} ) ;
256
260
257
- expect ( api . post ) . toHaveBeenCalledWith ( 'widgets?' , {
258
- data : {
259
- type : 'widgets' ,
260
- attributes,
261
- relationships,
261
+ expect ( api . post ) . toHaveBeenCalledWith (
262
+ 'widgets?' ,
263
+ {
264
+ data : {
265
+ type : 'widgets' ,
266
+ attributes,
267
+ relationships,
268
+ } ,
262
269
} ,
263
- } ) ;
270
+ contentTypeHeaders ,
271
+ ) ;
264
272
return expect ( result ) . resolves . toEqual ( responseBody ) ;
265
273
} ) ;
266
274
@@ -274,9 +282,13 @@ describe('ResourceClient', () => {
274
282
options : optionsWithInclude ,
275
283
} ) ;
276
284
277
- expect ( api . post ) . toHaveBeenCalledWith ( 'widgets?include=comments' , {
278
- data : { type : 'widgets' , attributes, relationships} ,
279
- } ) ;
285
+ expect ( api . post ) . toHaveBeenCalledWith (
286
+ 'widgets?include=comments' ,
287
+ {
288
+ data : { type : 'widgets' , attributes, relationships} ,
289
+ } ,
290
+ contentTypeHeaders ,
291
+ ) ;
280
292
} ) ;
281
293
282
294
it ( 'rejects with the response upon error' , ( ) => {
@@ -302,9 +314,13 @@ describe('ResourceClient', () => {
302
314
303
315
const result = resource . update ( { id, attributes, relationships} ) ;
304
316
305
- expect ( api . patch ) . toHaveBeenCalledWith ( 'widgets/1?' , {
306
- data : { id, type : 'widgets' , attributes, relationships} ,
307
- } ) ;
317
+ expect ( api . patch ) . toHaveBeenCalledWith (
318
+ 'widgets/1?' ,
319
+ {
320
+ data : { id, type : 'widgets' , attributes, relationships} ,
321
+ } ,
322
+ contentTypeHeaders ,
323
+ ) ;
308
324
return expect ( result ) . resolves . toEqual ( responseBody ) ;
309
325
} ) ;
310
326
@@ -319,9 +335,13 @@ describe('ResourceClient', () => {
319
335
options : optionsWithInclude ,
320
336
} ) ;
321
337
322
- expect ( api . patch ) . toHaveBeenCalledWith ( 'widgets/1?include=comments' , {
323
- data : { id, type : 'widgets' , attributes, relationships} ,
324
- } ) ;
338
+ expect ( api . patch ) . toHaveBeenCalledWith (
339
+ 'widgets/1?include=comments' ,
340
+ {
341
+ data : { id, type : 'widgets' , attributes, relationships} ,
342
+ } ,
343
+ contentTypeHeaders ,
344
+ ) ;
325
345
} ) ;
326
346
327
347
it ( 'rejects with the response upon error' , ( ) => {
0 commit comments