@@ -65,6 +65,37 @@ describe.skip('Config Command', () => {
6565 interactive : false ,
6666 command : 'list' ,
6767 } as any ) ;
68+ it ( 'should filter out invalid config keys in list command' , async ( ) => {
69+ // Mock getConfig to return config with invalid keys
70+ vi . mocked ( getConfig ) . mockReturnValue ( {
71+ githubMode : false ,
72+ invalidKey : 'some value' ,
73+ } as any ) ;
74+
75+ // Mock getDefaultConfig to return only valid keys
76+ vi . mocked ( getDefaultConfig ) . mockReturnValue ( {
77+ githubMode : false ,
78+ } ) ;
79+
80+ await command . handler ! ( {
81+ _ : [ 'config' , 'config' , 'list' ] ,
82+ logLevel : 'info' ,
83+ interactive : false ,
84+ command : 'list' ,
85+ } as any ) ;
86+
87+ expect ( getConfig ) . toHaveBeenCalled ( ) ;
88+ expect ( getDefaultConfig ) . toHaveBeenCalled ( ) ;
89+
90+ // Should show the valid key
91+ expect ( mockLogger . info ) . toHaveBeenCalledWith (
92+ expect . stringContaining ( 'githubMode' ) ,
93+ ) ;
94+
95+ // Should not show the invalid key
96+ const infoCallArgs = mockLogger . info . mock . calls . flat ( ) ;
97+ expect ( infoCallArgs . join ( ) ) . not . toContain ( 'invalidKey' ) ;
98+ } ) ;
6899
69100 expect ( getConfig ) . toHaveBeenCalled ( ) ;
70101 expect ( mockLogger . info ) . toHaveBeenCalledWith ( 'Current configuration:' ) ;
@@ -147,6 +178,21 @@ describe.skip('Config Command', () => {
147178 ) ;
148179 } ) ;
149180
181+ it ( 'should validate key exists in default config for set command' , async ( ) => {
182+ await command . handler ! ( {
183+ _ : [ 'config' , 'config' , 'set' , 'invalidKey' , 'value' ] ,
184+ logLevel : 'info' ,
185+ interactive : false ,
186+ command : 'set' ,
187+ key : 'invalidKey' ,
188+ value : 'value' ,
189+ } as any ) ;
190+
191+ expect ( mockLogger . error ) . toHaveBeenCalledWith (
192+ expect . stringContaining ( 'Invalid configuration key' ) ,
193+ ) ;
194+ } ) ;
195+
150196 it ( 'should handle unknown command' , async ( ) => {
151197 await command . handler ! ( {
152198 _ : [ 'config' , 'config' , 'unknown' ] ,
0 commit comments