@@ -62,6 +62,39 @@ describe('quota show command', () => {
6262 }
6363 } ) ;
6464
65+ it ( 'honors JSON output resolved from config without an output flag' , async ( ) => {
66+ server = createMockServer ( {
67+ routes : {
68+ '/v1/token_plan/remains' : ( ) => jsonResponse ( {
69+ model_remains : [ ] ,
70+ base_resp : { status_code : 0 , status_msg : 'ok' } ,
71+ } ) ,
72+ } ,
73+ } ) ;
74+
75+ const output : string [ ] = [ ] ;
76+ const originalLog = console . log ;
77+ const ttyDescriptor = Object . getOwnPropertyDescriptor ( process . stdout , 'isTTY' ) ;
78+ console . log = ( message ?: unknown ) => { output . push ( String ( message ?? '' ) ) ; } ;
79+ Object . defineProperty ( process . stdout , 'isTTY' , { value : true , configurable : true } ) ;
80+
81+ try {
82+ await showCommand . execute (
83+ { ...baseConfig , baseUrl : server . url , output : 'json' } ,
84+ { ...baseFlags , output : undefined } ,
85+ ) ;
86+ } finally {
87+ console . log = originalLog ;
88+ if ( ttyDescriptor ) {
89+ Object . defineProperty ( process . stdout , 'isTTY' , ttyDescriptor ) ;
90+ } else {
91+ delete ( process . stdout as unknown as Record < string , unknown > ) . isTTY ;
92+ }
93+ }
94+
95+ expect ( JSON . parse ( output . join ( '\n' ) ) ) . toMatchObject ( { model_remains : [ ] } ) ;
96+ } ) ;
97+
6598 it ( 'uses account/query_balance for sk-api keys' , async ( ) => {
6699 server = createMockServer ( {
67100 routes : {
0 commit comments