@@ -112,7 +112,10 @@ const postsRouter = c.router({
112112 responses : {
113113 200 : c . type < Post > ( ) ,
114114 } ,
115- body : null ,
115+ headers : z . object ( {
116+ 'content-type' : z . literal ( 'application/merge-patch+json' ) ,
117+ } ) ,
118+ body : z . object ( { } ) . passthrough ( ) ,
116119 } ,
117120 deletePost : {
118121 method : 'DELETE' ,
@@ -516,20 +519,33 @@ describe('client', () => {
516519 describe ( 'patch' , ( ) => {
517520 it ( 'w/ body' , async ( ) => {
518521 const value = { key : 'value' } ;
522+
519523 fetchMock . patchOnce (
520524 {
521525 url : 'https://api.com/posts/1' ,
522526 } ,
523- { body : value , status : 200 } ,
527+ ( _ , req ) => ( {
528+ body : {
529+ contentType : ( req . headers as any ) [ 'content-type' ] ,
530+ reqBody : JSON . parse ( req . body as string ) ,
531+ } ,
532+ status : 200 ,
533+ } ) ,
524534 ) ;
525535
526536 const result = await client . posts . patchPost ( {
527537 params : { id : '1' } ,
538+ headers : {
539+ 'content-type' : 'application/merge-patch+json' ,
540+ } ,
541+ body : value ,
528542 } ) ;
529543
530- expect ( result . body ) . toStrictEqual ( value ) ;
544+ expect ( result . body ) . toEqual ( {
545+ contentType : 'application/merge-patch+json' ,
546+ reqBody : value ,
547+ } ) ;
531548 expect ( result . status ) . toBe ( 200 ) ;
532- expect ( result . headers . get ( 'Content-Length' ) ) . toBe ( '15' ) ;
533549 expect ( result . headers . get ( 'Content-Type' ) ) . toBe ( 'application/json' ) ;
534550 } ) ;
535551 } ) ;
0 commit comments