@@ -21,7 +21,8 @@ describe('lib.Configuration', () => {
21
21
array : [ 2 , 3 , 4 ] ,
22
22
subobj : {
23
23
attr : 'b'
24
- }
24
+ } ,
25
+ func : ( v = 0 ) => { return 1 + v }
25
26
}
26
27
} ,
27
28
envTest2 : {
@@ -37,7 +38,8 @@ describe('lib.Configuration', () => {
37
38
subobj : {
38
39
attr : 'b'
39
40
} ,
40
- int2 : 2
41
+ int2 : 2 ,
42
+ func : ( v = 0 ) => { return 2 + v }
41
43
}
42
44
} ,
43
45
envTest3 : {
@@ -73,7 +75,8 @@ describe('lib.Configuration', () => {
73
75
subobj : {
74
76
attr : 'a'
75
77
} ,
76
- nullValue : null
78
+ nullValue : null ,
79
+ func : ( v = 0 ) => { return 3 + v }
77
80
}
78
81
}
79
82
} )
@@ -144,6 +147,8 @@ describe('lib.Configuration', () => {
144
147
assert . equal ( config . customObject . array [ 0 ] , 2 )
145
148
assert ( typeof config . customObject . subobj === 'object' )
146
149
assert . equal ( config . customObject . subobj . attr , 'b' )
150
+ assert ( typeof config . customObject . func === 'function' )
151
+ assert . equal ( config . customObject . func ( 1 ) , 2 )
147
152
} )
148
153
149
154
it ( 'should merge partial custom env config' , ( ) => {
@@ -158,6 +163,8 @@ describe('lib.Configuration', () => {
158
163
assert . equal ( config . customObject . array [ 0 ] , 1 )
159
164
assert ( typeof config . customObject . subobj === 'object' )
160
165
assert . equal ( config . customObject . subobj . attr , 'b' )
166
+ assert ( typeof config . customObject . func === 'function' )
167
+ assert . equal ( config . customObject . func ( 1 ) , 3 )
161
168
} )
162
169
163
170
it ( 'should merge new custom attr in env config' , ( ) => {
@@ -173,6 +180,8 @@ describe('lib.Configuration', () => {
173
180
assert ( typeof config . customObject . subobj === 'object' )
174
181
assert . equal ( config . customObject . subobj . attr , 'b' )
175
182
assert . equal ( config . customObject . int2 , 2 )
183
+ assert ( typeof config . customObject . func === 'function' )
184
+ assert . equal ( config . customObject . func ( 1 ) , 3 )
176
185
} )
177
186
178
187
it ( 'should not override any configs if NODE_ENV matches no env' , ( ) => {
@@ -357,7 +366,10 @@ describe('lib.Configuration', () => {
357
366
subobj : {
358
367
attr : 'b'
359
368
} ,
360
- newValue : 'a'
369
+ newValue : 'a' ,
370
+ func : ( v = 4 ) => {
371
+ return v + 1
372
+ }
361
373
}
362
374
} , 'merge' )
363
375
// Old Value should be replaced?
@@ -370,6 +382,8 @@ describe('lib.Configuration', () => {
370
382
assert . deepEqual ( config . get ( 'customObject.stringArray' ) , [ 'one' , 'two' , 'three' ] )
371
383
assert . deepEqual ( config . get ( 'customObject.stringArray2' ) , [ 'one' , 'two' , 'three' ] )
372
384
385
+ assert . equal ( config . get ( 'customObject.func' ) ( 4 ) , 7 )
386
+
373
387
} )
374
388
375
389
it ( 'should completely ignore replaceable values' , ( ) => {
0 commit comments