transformer can now return an undefined key (#289)
This commit is contained in:
parent
81ce0be01e
commit
b9321b200a
2 changed files with 29 additions and 1 deletions
|
@ -154,7 +154,7 @@ common.transform = function(map, fn) {
|
|||
|
||||
if (!result) {
|
||||
return null;
|
||||
} else if (result.key && typeof result.value !== 'undefined') {
|
||||
} else if (result.key) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -242,6 +242,34 @@ vows.describe('nconf/multiple-stores').addBatch({
|
|||
teardown: function () {
|
||||
nconf.remove('env');
|
||||
}
|
||||
}).addBatch({
|
||||
// Threw this in it's own batch to make sure it's run separately from the
|
||||
// sync check
|
||||
"When using env with a transform:fn that return an undefined value": {
|
||||
topic: function () {
|
||||
|
||||
function testTransform(obj) {
|
||||
if (obj.key === 'FOO') {
|
||||
return {key: 'FOO', value: undefined};
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
var that = this;
|
||||
helpers.cp(complete, completeTest, function () {
|
||||
nconf.env({ transform: testTransform });
|
||||
that.callback();
|
||||
});
|
||||
}, "env vars": {
|
||||
"port key/value properly transformed": function() {
|
||||
assert.equal(typeof nconf.get('FOO'), 'undefined');
|
||||
}
|
||||
}
|
||||
},
|
||||
teardown: function () {
|
||||
nconf.remove('env');
|
||||
}
|
||||
}).addBatch({
|
||||
// Threw this in it's own batch to make sure it's run separately from the
|
||||
// sync check
|
||||
|
|
Loading…
Reference in a new issue