@@ -97,7 +97,7 @@ describe('openapi-format CLI command', () => {
9797 expect ( sanitize ( result . stderr ) ) . toStrictEqual ( sanitize ( output ) ) ;
9898 } ) ;
9999
100- it ( 'should use the configFile with all settings' , async ( ) => {
100+ it ( 'should use the configFile with all settings including boolean options ' , async ( ) => {
101101 // const path = `test/__utils__`;
102102 const inputFile = `test/__utils__/mockOpenApi.json` ;
103103 const outputFile = `test/_cli-configfile/output.json` ;
@@ -146,6 +146,63 @@ describe('openapi-format CLI command', () => {
146146 fs . readFileSync . mockRestore ( ) ;
147147 } ) ;
148148
149+ it ( 'should respect boolean options from .openapiformatrc' , async ( ) => {
150+ // Create a temporary .openapiformatrc file with boolean options
151+ const defaultConfigPath = '.openapiformatrc' ;
152+ const configContent = {
153+ keepComments : true ,
154+ sortComponentsProps : true ,
155+ split : false
156+ } ;
157+
158+ // Write the config file
159+ fs . writeFileSync ( defaultConfigPath , JSON . stringify ( configContent , null , 2 ) ) ;
160+
161+ try {
162+ const inputFile = `test/yaml-no-sort-keep-comments/input.yaml` ;
163+ let result = await testUtils . cli ( [ inputFile , '--no-sort' ] , '.' ) ;
164+ expect ( result . code ) . toBe ( 0 ) ;
165+ expect ( result . stdout ) . toContain ( 'formatted successfully' ) ;
166+ expect ( result . stdout ) . toMatchSnapshot ( ) ;
167+ // The output should preserve comments due to keepComments: true in config
168+ expect ( result . stderr ) . toContain ( '#' ) ;
169+ } finally {
170+ // Clean up - remove the temporary config file
171+ if ( fs . existsSync ( defaultConfigPath ) ) {
172+ fs . unlinkSync ( defaultConfigPath ) ;
173+ }
174+ }
175+ } ) ;
176+
177+ it ( 'should use config file boolean options when set' , async ( ) => {
178+ // Create a config file with boolean options set to non-default values
179+ const defaultConfigPath = '.openapiformatrc' ;
180+ const configContent = {
181+ keepComments : true ,
182+ sortComponentsProps : true ,
183+ split : false ,
184+ sort : false
185+ } ;
186+
187+ // Write the config file
188+ fs . writeFileSync ( defaultConfigPath , JSON . stringify ( configContent , null , 2 ) ) ;
189+
190+ try {
191+ const inputFile = `test/yaml-no-sort-keep-comments/input.yaml` ;
192+ // Config file values should be applied
193+ let result = await testUtils . cli ( [ inputFile ] , '.' ) ;
194+ expect ( result . code ) . toBe ( 0 ) ;
195+ expect ( result . stdout ) . toContain ( 'formatted successfully' ) ;
196+ // The output should preserve comments due to config file setting
197+ expect ( result . stderr ) . toContain ( '#' ) ;
198+ } finally {
199+ // Clean up - remove the temporary config file
200+ if ( fs . existsSync ( defaultConfigPath ) ) {
201+ fs . unlinkSync ( defaultConfigPath ) ;
202+ }
203+ }
204+ } ) ;
205+
149206 it ( 'should use the casingFile' , async ( ) => {
150207 const path = `test/yaml-casing` ;
151208 const inputFile = `${ path } /input.yaml` ;
0 commit comments