-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
57 lines (50 loc) · 1.66 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'use strict';
var assert = require('assert');
var configurator = require('./');
var configSetup = {
'baseUrl': 'http://test.com',
'$prod_baseUrl': 'https://prod.com',
'number': 2 * 4,
'endpoints': {
'users': '<%= baseUrl %>/users',
'accounts': '<%= baseUrl %>/accounts'
},
$prod_array: ["prod",1,2],
array: ["default",11,12],
$prod_areaCodes: {
"area1": "abcd"
},
$test_areaCodes: {
"area1": "test_abcd"
},
'interpolation': '<%= nested.hello %>bar',
'$prod_foo': 'prod foo',
'$test_foo': 'test foo',
'nested': {
'webpages': ["abc", "DEF"],
'hello': 'hi',
'$prod_onlyInProduction': 'Only in prod',
'deep': {
'abc': 'foobar',
'$test_abc': 'foobar for test'
}
}
};
it('should filter out unnecessarily varibles ', function () {
var config = configurator(configSetup, 'prod');
assert.strictEqual(config.foo, 'prod foo' );
assert.strictEqual(config.nested.onlyInProduction, 'Only in prod' );
assert.strictEqual(config.nested.deep.abc, 'foobar' );
assert.strictEqual(config['$test_foo'], undefined );
assert.strictEqual(config.interpolation, 'hibar' );
assert.strictEqual(config.endpoints.users, 'https://prod.com/users' );
assert.strictEqual(config.areaCodes.area1, 'abcd' );
assert.deepEqual(config.array, ["prod",1,2] );
assert.deepEqual(config.nested.webpages, ["abc", "DEF"] );
var configTest = configurator(configSetup, 'test');
assert.strictEqual(configTest.nested.onlyInProduction,undefined );
assert.strictEqual(configTest.endpoints.users, 'http://test.com/users' );
assert.strictEqual(configTest.number, 8 );
assert.strictEqual(configTest.areaCodes.area1, 'test_abcd' );
assert.deepEqual(configTest.array, ["default",11,12] );
});