@@ -1972,6 +1972,55 @@ describe('loadCliConfig fileFiltering', () => {
19721972 ) ;
19731973} ) ;
19741974
1975+ describe ( 'Output Format Configuration' , ( ) => {
1976+ const originalArgv = process . argv ;
1977+
1978+ afterEach ( ( ) => {
1979+ process . argv = originalArgv ;
1980+ vi . restoreAllMocks ( ) ;
1981+ } ) ;
1982+
1983+ it ( 'should default to text format when no setting or flag is provided' , async ( ) => {
1984+ process . argv = [ 'node' , 'script.js' ] ;
1985+ const argv = await parseArguments ( { } as Settings ) ;
1986+ const config = await loadCliConfig (
1987+ { } as Settings ,
1988+ [ ] ,
1989+ 'test-session' ,
1990+ argv ,
1991+ ) ;
1992+ expect ( config . getOutputFormat ( ) ) . toBe ( ServerConfig . OutputFormat . TEXT ) ;
1993+ } ) ;
1994+
1995+ it ( 'should use the format from settings when no flag is provided' , async ( ) => {
1996+ process . argv = [ 'node' , 'script.js' ] ;
1997+ const settings : Settings = { output : { format : 'json' } } ;
1998+ const argv = await parseArguments ( settings ) ;
1999+ const config = await loadCliConfig ( settings , [ ] , 'test-session' , argv ) ;
2000+ expect ( config . getOutputFormat ( ) ) . toBe ( ServerConfig . OutputFormat . JSON ) ;
2001+ } ) ;
2002+
2003+ it ( 'should use the format from the flag when provided' , async ( ) => {
2004+ process . argv = [ 'node' , 'script.js' , '--output-format' , 'json' ] ;
2005+ const argv = await parseArguments ( { } as Settings ) ;
2006+ const config = await loadCliConfig (
2007+ { } as Settings ,
2008+ [ ] ,
2009+ 'test-session' ,
2010+ argv ,
2011+ ) ;
2012+ expect ( config . getOutputFormat ( ) ) . toBe ( ServerConfig . OutputFormat . JSON ) ;
2013+ } ) ;
2014+
2015+ it ( 'should prioritize the flag over the setting' , async ( ) => {
2016+ process . argv = [ 'node' , 'script.js' , '--output-format' , 'text' ] ;
2017+ const settings : Settings = { output : { format : 'json' } } ;
2018+ const argv = await parseArguments ( settings ) ;
2019+ const config = await loadCliConfig ( settings , [ ] , 'test-session' , argv ) ;
2020+ expect ( config . getOutputFormat ( ) ) . toBe ( ServerConfig . OutputFormat . TEXT ) ;
2021+ } ) ;
2022+ } ) ;
2023+
19752024describe ( 'parseArguments with positional prompt' , ( ) => {
19762025 const originalArgv = process . argv ;
19772026
0 commit comments