correctly retrieve falsy values from memory (hence file)
This commit is contained in:
parent
e26bbe25f2
commit
faa8ab9486
3 changed files with 17 additions and 1 deletions
|
@ -36,7 +36,7 @@ Memory.prototype.get = function (key) {
|
||||||
//
|
//
|
||||||
while (path.length > 0) {
|
while (path.length > 0) {
|
||||||
key = path.shift();
|
key = path.shift();
|
||||||
if (!target[key]) {
|
if (!(target && key in target)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,11 +63,19 @@ vows.describe('nconf/stores/file').addBatch({
|
||||||
"the set() method": {
|
"the set() method": {
|
||||||
"should respond with true": function () {
|
"should respond with true": function () {
|
||||||
assert.isTrue(store.set('foo:bar:bazz', 'buzz'));
|
assert.isTrue(store.set('foo:bar:bazz', 'buzz'));
|
||||||
|
assert.isTrue(store.set('falsy:number', 0));
|
||||||
|
assert.isTrue(store.set('falsy:string', ''));
|
||||||
|
assert.isTrue(store.set('falsy:boolean', false));
|
||||||
|
assert.isTrue(store.set('falsy:object', null));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"the get() method": {
|
"the get() method": {
|
||||||
"should respond with the correct value": function () {
|
"should respond with the correct value": function () {
|
||||||
assert.equal(store.get('foo:bar:bazz'), 'buzz');
|
assert.equal(store.get('foo:bar:bazz'), 'buzz');
|
||||||
|
assert.equal(store.get('falsy:number'), 0);
|
||||||
|
assert.equal(store.get('falsy:string'), '');
|
||||||
|
assert.equal(store.get('falsy:boolean'), false);
|
||||||
|
assert.equal(store.get('falsy:object'), null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"the clear() method": {
|
"the clear() method": {
|
||||||
|
|
|
@ -15,11 +15,19 @@ vows.describe('nconf/stores/memory').addBatch({
|
||||||
"the set() method": {
|
"the set() method": {
|
||||||
"should respond with true": function (store) {
|
"should respond with true": function (store) {
|
||||||
assert.isTrue(store.set('foo:bar:bazz', 'buzz'));
|
assert.isTrue(store.set('foo:bar:bazz', 'buzz'));
|
||||||
|
assert.isTrue(store.set('falsy:number', 0));
|
||||||
|
assert.isTrue(store.set('falsy:string', ''));
|
||||||
|
assert.isTrue(store.set('falsy:boolean', false));
|
||||||
|
assert.isTrue(store.set('falsy:object', null));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"the get() method": {
|
"the get() method": {
|
||||||
"should respond with the correct value": function (store) {
|
"should respond with the correct value": function (store) {
|
||||||
assert.equal(store.get('foo:bar:bazz'), 'buzz');
|
assert.equal(store.get('foo:bar:bazz'), 'buzz');
|
||||||
|
assert.equal(store.get('falsy:number'), 0);
|
||||||
|
assert.equal(store.get('falsy:string'), '');
|
||||||
|
assert.equal(store.get('falsy:boolean'), false);
|
||||||
|
assert.equal(store.get('falsy:object'), null);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"the clear() method": {
|
"the clear() method": {
|
||||||
|
|
Loading…
Reference in a new issue