File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -642,4 +642,31 @@ describe('requestCommand', () => {
642642
643643 expect ( consoleLogSpy ) . toHaveBeenCalledWith ( expectedOutput )
644644 } )
645+
646+ it ( 'should display JSON body correctly with --json and --include options' , async ( ) => {
647+ const mockApp = new Hono ( )
648+ const jsonBody = { message : 'Hello JSON' }
649+ mockApp . get ( '/json-data' , ( c ) => c . json ( jsonBody ) )
650+ setupBasicMocks ( 'test-app.js' , mockApp )
651+
652+ await program . parseAsync ( [
653+ 'node' ,
654+ 'test' ,
655+ 'request' ,
656+ '-P' ,
657+ '/json-data' ,
658+ '-J' ,
659+ '-i' ,
660+ 'test-app.js' ,
661+ ] )
662+
663+ const expectedOutput = [
664+ 'STATUS 200' ,
665+ 'content-type: application/json' ,
666+ '' ,
667+ JSON . stringify ( jsonBody , null , 2 ) ,
668+ ] . join ( '\n' )
669+
670+ expect ( consoleLogSpy ) . toHaveBeenCalledWith ( expectedOutput )
671+ } )
645672} )
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ export function requestCommand(program: Command) {
5252 const outputBody = formatResponseBody (
5353 result . body ,
5454 result . headers [ 'content-type' ] ,
55- options . json
55+ options . json && ! options . include
5656 )
5757 const buffer = await result . response . clone ( ) . arrayBuffer ( )
5858 const isBinaryData = isBinaryResponse ( buffer )
You can’t perform that action at this time.
0 commit comments