[test] Added tests (which are now passing) for

This commit is contained in:
indexzero 2011-11-23 15:46:02 -05:00
parent 16a18bffe6
commit 0fbc9a2722
3 changed files with 42 additions and 0 deletions

5
test/fixtures/hierarchy/global.json vendored Normal file
View file

@ -0,0 +1,5 @@
{
"title": "My generic title",
"color": "red",
"movie": "Kill Bill"
}

4
test/fixtures/hierarchy/user.json vendored Normal file
View file

@ -0,0 +1,4 @@
{
"title": "My specific title",
"color": "green"
}

33
test/hierarchy-test.js Normal file
View file

@ -0,0 +1,33 @@
/*
* hierarchy-test.js: Basic tests for hierarchical file stores.
*
* (C) 2011, Charlie Robbins
*
*/
var assert = require('assert'),
path = require('path'),
vows = require('vows'),
nconf = require('../lib/nconf');
var configDir = path.join(__dirname, 'fixtures', 'hierarchy'),
globalConfig = path.join(configDir, 'global.json'),
userConfig = path.join(configDir, 'user.json');
vows.describe('nconf/hierarchy').addBatch({
"When using nconf": {
"configured with two file stores": {
topic: function () {
nconf.add('user', { type: 'file', file: userConfig })
nconf.add('global', { type: 'file', file: globalConfig })
nconf.load();
return nconf;
},
"should have the appropriate keys present": function () {
assert.equal(nconf.get('title'), 'My specific title');
assert.equal(nconf.get('color'), 'green');
assert.equal(nconf.get('movie'), 'Kill Bill');
}
}
}
}).export(module);