@@ -399,11 +399,56 @@ describe('validate config files', function () {
399399 }
400400 } ) ;
401401
402+ it ( 'should validate using default config file when no path provided' , function ( ) {
403+ const originalConfigFile = config . configFile ;
404+ const mainConfigPath = path . join ( __dirname , '..' , 'proxy.config.json' ) ;
405+ config . setConfigFile ( mainConfigPath ) ;
406+
407+ try {
408+ // default configFile
409+ expect ( ( ) => config . validate ( ) ) . to . not . throw ( ) ;
410+ } finally {
411+ // Restore original config file
412+ config . setConfigFile ( originalConfigFile ) ;
413+ }
414+ } ) ;
415+
402416 after ( function ( ) {
403417 delete require . cache [ require . resolve ( '../src/config' ) ] ;
404418 } ) ;
405419} ) ;
406420
421+ describe ( 'setConfigFile function' , function ( ) {
422+ const config = require ( '../src/config/file' ) ;
423+ let originalConfigFile ;
424+
425+ beforeEach ( function ( ) {
426+ originalConfigFile = config . configFile ;
427+ } ) ;
428+
429+ afterEach ( function ( ) {
430+ // Restore original config file
431+ config . setConfigFile ( originalConfigFile ) ;
432+ } ) ;
433+
434+ it ( 'should set the config file path' , function ( ) {
435+ const newPath = '/tmp/new-config.json' ;
436+ config . setConfigFile ( newPath ) ;
437+ expect ( config . configFile ) . to . equal ( newPath ) ;
438+ } ) ;
439+
440+ it ( 'should allow changing config file multiple times' , function ( ) {
441+ const firstPath = '/tmp/first-config.json' ;
442+ const secondPath = '/tmp/second-config.json' ;
443+
444+ config . setConfigFile ( firstPath ) ;
445+ expect ( config . configFile ) . to . equal ( firstPath ) ;
446+
447+ config . setConfigFile ( secondPath ) ;
448+ expect ( config . configFile ) . to . equal ( secondPath ) ;
449+ } ) ;
450+ } ) ;
451+
407452describe ( 'Configuration Update Handling' , function ( ) {
408453 let tempDir ;
409454 let tempUserFile ;
0 commit comments