1 | var assert = require ('assert'),
|
2 | path = require('path');
|
3 |
|
4 | describe ('config manager', function(){
|
5 |
|
6 | it('should handle non existant config file', function(done){
|
7 | var configFilePath = path.join(process.cwd(), 'config', 'non_existant_config.json');
|
8 | var config = require ('../lib/config-manager')(configFilePath);
|
9 | assert.equal(null, config.get('test'));
|
10 | done();
|
11 | });
|
12 |
|
13 | it('should throw if invalid config file', function(done){
|
14 | var configFilePath = path.join(process.cwd(), 'test', 'fixtures', 'config', 'invalid_config.json');
|
15 | try {
|
16 | var config = require ('../lib/config-manager')(configFilePath);
|
17 | }
|
18 | catch(e){
|
19 | done();
|
20 | }
|
21 | });
|
22 |
|
23 | it('should handle valid config file', function(done){
|
24 | var configFilePath = path.join(process.cwd(), 'test', 'fixtures', 'config', 'valid_config.json');
|
25 | var config = require ('../lib/config-manager')(configFilePath);
|
26 | assert.equal('val1', config.get('key1'));
|
27 | done();
|
28 | });
|
29 |
|
30 | describe ('wallboard specific config', function(){
|
31 |
|
32 | it('should extend from atlasboard config', function(done){
|
33 | var atlasboardConfigFilePath = path.join(process.cwd(), 'test','fixtures', 'config', 'valid_config.json');
|
34 | var wallboardConfigFilePath = path.join(process.cwd(), 'test','fixtures', 'config', 'log-enabled.json');
|
35 | var config = require ('../lib/config-manager')(wallboardConfigFilePath, atlasboardConfigFilePath);
|
36 | assert.equal('val1', config.get('key1'));
|
37 | assert.equal(true, config.get('live-logging').enabled);
|
38 | done();
|
39 | });
|
40 |
|
41 | it('should shadow atlasboard default config', function(done){
|
42 | var atlasboardConfigFilePath = path.join(process.cwd(), 'test', 'fixtures', 'config', 'valid_config.json');
|
43 | var wallboardConfigFilePath = path.join(process.cwd(), 'test', 'fixtures', 'config', 'valid_config_shadowing.json');
|
44 | var config = require ('../lib/config-manager')(wallboardConfigFilePath, atlasboardConfigFilePath);
|
45 | assert.equal('val2', config.get('key1'));
|
46 | done();
|
47 | });
|
48 |
|
49 | });
|
50 |
|
51 | }); |
\ | No newline at end of file |