@@ -208,7 +208,10 @@ describe('client', () => {
208208
209209 const result = await client . posts . getPosts ( { } ) ;
210210
211- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
211+ expect ( result . body ) . toStrictEqual ( value ) ;
212+ expect ( result . status ) . toBe ( 200 ) ;
213+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
214+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
212215 } ) ;
213216
214217 it ( 'w/ no query parameters' , async ( ) => {
@@ -225,7 +228,10 @@ describe('client', () => {
225228
226229 const result = await client . posts . getPosts ( { query : { } } ) ;
227230
228- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
231+ expect ( result . body ) . toStrictEqual ( value ) ;
232+ expect ( result . status ) . toBe ( 200 ) ;
233+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
234+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
229235 } ) ;
230236
231237 it ( 'w/ no parameters (not provided)' , async ( ) => {
@@ -242,7 +248,10 @@ describe('client', () => {
242248
243249 const result = await client . posts . getPosts ( ) ;
244250
245- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
251+ expect ( result . body ) . toStrictEqual ( value ) ;
252+ expect ( result . status ) . toBe ( 200 ) ;
253+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
254+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
246255 } ) ;
247256
248257 it ( 'w/ query parameters' , async ( ) => {
@@ -259,7 +268,10 @@ describe('client', () => {
259268
260269 const result = await client . posts . getPosts ( { query : { take : 10 } } ) ;
261270
262- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
271+ expect ( result . body ) . toStrictEqual ( value ) ;
272+ expect ( result . status ) . toBe ( 200 ) ;
273+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
274+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
263275 } ) ;
264276
265277 it ( 'w/ json query parameters' , async ( ) => {
@@ -304,7 +316,10 @@ describe('client', () => {
304316 } ,
305317 } ) ;
306318
307- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
319+ expect ( result . body ) . toStrictEqual ( value ) ;
320+ expect ( result . status ) . toBe ( 200 ) ;
321+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
322+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
308323 } ) ;
309324
310325 it ( 'w/ undefined query parameters' , async ( ) => {
@@ -323,7 +338,10 @@ describe('client', () => {
323338 query : { take : 10 , skip : undefined } ,
324339 } ) ;
325340
326- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
341+ expect ( result . body ) . toStrictEqual ( value ) ;
342+ expect ( result . status ) . toBe ( 200 ) ;
343+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
344+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
327345 } ) ;
328346
329347 it ( 'w/ sub path' , async ( ) => {
@@ -340,7 +358,10 @@ describe('client', () => {
340358
341359 const result = await client . posts . getPost ( { params : { id : '1' } } ) ;
342360
343- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
361+ expect ( result . body ) . toStrictEqual ( value ) ;
362+ expect ( result . status ) . toBe ( 200 ) ;
363+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
364+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
344365 } ) ;
345366
346367 it ( 'w/ a non json response (string)' , async ( ) => {
@@ -362,7 +383,10 @@ describe('client', () => {
362383
363384 const result = await client . posts . getPosts ( { } ) ;
364385
365- expect ( result ) . toStrictEqual ( { body : 'string' , status : 200 } ) ;
386+ expect ( result . body ) . toStrictEqual ( 'string' ) ;
387+ expect ( result . status ) . toBe ( 200 ) ;
388+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '6' ) ;
389+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'text/plain' ) ;
366390 } ) ;
367391 } ) ;
368392
@@ -383,7 +407,10 @@ describe('client', () => {
383407 body : { title : 'title' , content : 'content' , authorId : 'authorId' } ,
384408 } ) ;
385409
386- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
410+ expect ( result . body ) . toStrictEqual ( value ) ;
411+ expect ( result . status ) . toBe ( 200 ) ;
412+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
413+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
387414 } ) ;
388415
389416 it ( 'w/ query params' , async ( ) => {
@@ -403,7 +430,10 @@ describe('client', () => {
403430 body : { } ,
404431 } ) ;
405432
406- expect ( result ) . toStrictEqual ( { body : { } , status : 200 } ) ;
433+ expect ( result . body ) . toStrictEqual ( { } ) ;
434+ expect ( result . status ) . toBe ( 200 ) ;
435+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '2' ) ;
436+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
407437 } ) ;
408438 } ) ;
409439
@@ -430,7 +460,10 @@ describe('client', () => {
430460 body : { title : 'title' , content : 'content' , authorId : 'authorId' } ,
431461 } ) ;
432462
433- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
463+ expect ( result . body ) . toStrictEqual ( value ) ;
464+ expect ( result . status ) . toBe ( 200 ) ;
465+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
466+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
434467 } ) ;
435468 } ) ;
436469
@@ -452,7 +485,10 @@ describe('client', () => {
452485 body : null ,
453486 } ) ;
454487
455- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
488+ expect ( result . body ) . toStrictEqual ( value ) ;
489+ expect ( result . status ) . toBe ( 200 ) ;
490+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
491+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
456492 } ) ;
457493 } ) ;
458494
@@ -474,7 +510,10 @@ describe('client', () => {
474510 body : null ,
475511 } ) ;
476512
477- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
513+ expect ( result . body ) . toStrictEqual ( value ) ;
514+ expect ( result . status ) . toBe ( 200 ) ;
515+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
516+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
478517 } ) ;
479518 } ) ;
480519
@@ -494,7 +533,10 @@ describe('client', () => {
494533 body : { file } ,
495534 } ) ;
496535
497- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
536+ expect ( result . body ) . toStrictEqual ( value ) ;
537+ expect ( result . status ) . toBe ( 200 ) ;
538+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
539+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
498540
499541 expect ( fetchMock ) . toHaveLastFetched ( true , {
500542 matcher : ( _ , options ) => {
@@ -520,7 +562,10 @@ describe('client', () => {
520562 body : formData ,
521563 } ) ;
522564
523- expect ( result ) . toStrictEqual ( { body : value , status : 200 } ) ;
565+ expect ( result . body ) . toStrictEqual ( value ) ;
566+ expect ( result . status ) . toBe ( 200 ) ;
567+ expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
568+ expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
524569
525570 expect ( fetchMock ) . toHaveLastFetched ( true , {
526571 matcher : ( _ , options ) => {
@@ -553,6 +598,7 @@ const customClient = initClient(router, {
553598 return {
554599 status : 200 ,
555600 body : { message : 'Hello' } ,
601+ headers : new Headers ( ) ,
556602 } ;
557603 } ,
558604} ) ;
0 commit comments