@@ -581,4 +581,111 @@ describe('config.util', () => {
581581 expect ( result ) . to . equal ( false ) ;
582582 } ) ;
583583 } ) ;
584+
585+ describe ( 'resolveStringConfig' , ( ) => {
586+ beforeEach ( ( ) => {
587+ delete process . env . TEST_STRING_VAR ;
588+ } ) ;
589+
590+ afterEach ( ( ) => {
591+ delete process . env . TEST_STRING_VAR ;
592+ } ) ;
593+
594+ it ( 'should return the default value when no env var or config value is provided' , ( ) => {
595+ const result = util . resolveStringConfig ( {
596+ envVar : 'TEST_STRING_VAR' ,
597+ configValue : undefined ,
598+ defaultValue : 'default-value' ,
599+ configPath : 'config.test.string'
600+ } ) ;
601+
602+ expect ( result ) . to . equal ( 'default-value' ) ;
603+ } ) ;
604+
605+ it . skip ( 'should prioritize env var over config value' , ( ) => {
606+ process . env . TEST_STRING_VAR = 'env-value' ;
607+
608+ const result = util . resolveStringConfig ( {
609+ envVar : 'TEST_STRING_VAR' ,
610+ configValue : 'config-value' ,
611+ defaultValue : 'default-value' ,
612+ configPath : 'config.test.string'
613+ } ) ;
614+
615+ expect ( result ) . to . equal ( 'env-value' ) ;
616+ } ) ;
617+
618+ it ( 'should use env var when config value is not set' , ( ) => {
619+ process . env . TEST_STRING_VAR = 'env-value' ;
620+
621+ const result = util . resolveStringConfig ( {
622+ envVar : 'TEST_STRING_VAR' ,
623+ configValue : undefined ,
624+ defaultValue : 'default-value' ,
625+ configPath : 'config.test.string'
626+ } ) ;
627+
628+ expect ( result ) . to . equal ( 'env-value' ) ;
629+ } ) ;
630+
631+ it ( 'should use config value when env var is not set' , ( ) => {
632+ const result = util . resolveStringConfig ( {
633+ envVar : 'TEST_STRING_VAR' ,
634+ configValue : 'config-value' ,
635+ defaultValue : 'default-value' ,
636+ configPath : 'config.test.string'
637+ } ) ;
638+
639+ expect ( result ) . to . equal ( 'config-value' ) ;
640+ } ) ;
641+
642+ it ( 'should handle empty string as a valid config value' , ( ) => {
643+ const result = util . resolveStringConfig ( {
644+ envVar : 'TEST_STRING_VAR' ,
645+ configValue : '' ,
646+ defaultValue : 'default-value' ,
647+ configPath : 'config.test.string'
648+ } ) ;
649+
650+ expect ( result ) . to . equal ( '' ) ;
651+ } ) ;
652+
653+ it ( 'should handle empty string as a valid env var value' , ( ) => {
654+ process . env . TEST_STRING_VAR = '' ;
655+
656+ const result = util . resolveStringConfig ( {
657+ envVar : 'TEST_STRING_VAR' ,
658+ configValue : undefined ,
659+ defaultValue : 'default-value' ,
660+ configPath : 'config.test.string'
661+ } ) ;
662+
663+ expect ( result ) . to . equal ( '' ) ;
664+ } ) ;
665+
666+ it ( 'should handle undefined config value as not set' , ( ) => {
667+ process . env . TEST_STRING_VAR = 'env-value' ;
668+
669+ const result = util . resolveStringConfig ( {
670+ envVar : 'TEST_STRING_VAR' ,
671+ configValue : undefined ,
672+ defaultValue : 'default-value' ,
673+ configPath : 'config.test.string'
674+ } ) ;
675+
676+ expect ( result ) . to . equal ( 'env-value' ) ;
677+ } ) ;
678+
679+ it ( 'should handle multiline string values' , ( ) => {
680+ const multilineValue = 'line1\nline2\nline3' ;
681+ const result = util . resolveStringConfig ( {
682+ envVar : undefined ,
683+ configValue : multilineValue ,
684+ defaultValue : 'default-value' ,
685+ configPath : 'config.test.string'
686+ } ) ;
687+
688+ expect ( result ) . to . equal ( multilineValue ) ;
689+ } ) ;
690+ } ) ;
584691} ) ;
0 commit comments