@@ -137,29 +137,20 @@ describe('Config', () => {
137137 Object . assign ( process . env , originalEnv ) ;
138138 } ) ;
139139
140- it ( 'should convert number-like strings to numbers' , ( ) => {
141- process . env . testnumberproperty = '101' ;
140+ const tests = [
141+ { name : 'should convert number-like strings to numbers' , envName : 'testnumber' , value : '101' , expected : 101 } ,
142+ { name : 'should convert underscores to hyphens' , envName : 'test_underscore' , value : 'PASS' , configName : 'test-underscore' } ,
143+ { name : 'should convert to lowercase' , envName : 'TESTUPPERCASE' , value : 'PASS' , configName : 'testuppercase' } ,
144+ { name : 'should convert boolean-like strings to booleans' , envName : 'testboolean' , value : 'true' , expected : true } ,
145+ ] ;
146+
147+ tests . forEach ( test => it ( `${ test . name } ` , ( ) => {
148+ process . env [ test . envName ] = test . value ;
142149 const config = new Config ( ) ;
143- const result = config . get ( 'testnumberproperty' ) ;
150+ const result = config . get ( test . configName || test . envName ) ;
144151 should . exist ( result ) ;
145- result . should . equal ( 101 ) ;
146- } ) ;
147-
148- it ( 'should convert underscores to hyphens' , ( ) => {
149- process . env . test_underscore_property = 'PASS' ;
150- const config = new Config ( ) ;
151- const result = config . get ( 'test-underscore-property' ) ;
152- should . exist ( result ) ;
153- result . should . equal ( 'PASS' ) ;
154- } ) ;
155-
156- it ( 'should convert to lowercase' , ( ) => {
157- process . env . TESTUPPERCASEPROPERTY = 'PASS' ;
158- const config = new Config ( ) ;
159- const result = config . get ( 'testuppercaseproperty' ) ;
160- should . exist ( result ) ;
161- result . should . equal ( 'PASS' ) ;
162- } ) ;
152+ result . should . equal ( test . expected || test . value ) ;
153+ } ) ) ;
163154 } ) ;
164155
165156 describe ( '#set' , ( ) => {
0 commit comments