[test] Better tests to show #65
This commit is contained in:
parent
f19f0b6c39
commit
0d795ecf81
1 changed files with 35 additions and 12 deletions
|
@ -17,7 +17,8 @@ vows.describe('nconf/stores/memory').addBatch({
|
||||||
"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:number', 0));
|
||||||
assert.isTrue(store.set('falsy:string', ''));
|
assert.isTrue(store.set('falsy:string:empty', ''));
|
||||||
|
assert.isTrue(store.set('falsy:string:value', 'value'));
|
||||||
assert.isTrue(store.set('falsy:boolean', false));
|
assert.isTrue(store.set('falsy:boolean', false));
|
||||||
assert.isTrue(store.set('falsy:object', null));
|
assert.isTrue(store.set('falsy:object', null));
|
||||||
}
|
}
|
||||||
|
@ -25,21 +26,43 @@ vows.describe('nconf/stores/memory').addBatch({
|
||||||
"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.isUndefined(store.get('foo:bar:bazz:buzz:bizz'));
|
|
||||||
assert.equal(store.get('falsy:number'), 0);
|
assert.equal(store.get('falsy:number'), 0);
|
||||||
assert.equal(store.get('falsy:string'), '');
|
assert.equal(store.get('falsy:string:empty'), '');
|
||||||
|
assert.equal(store.get('falsy:string:value'), 'value');
|
||||||
assert.equal(store.get('falsy:boolean'), false);
|
assert.equal(store.get('falsy:boolean'), false);
|
||||||
assert.equal(store.get('falsy:object'), null);
|
assert.equal(store.get('falsy:object'), null);
|
||||||
},
|
},
|
||||||
"should not fail when retrieving non-existent keys": function (store) {
|
"should not fail when retrieving non-existent keys": {
|
||||||
assert.doesNotThrow(function() {
|
"at the root level": function (store) {
|
||||||
assert.equal(store.get('this:key:does:not:exist'), undefined);
|
assert.doesNotThrow(function() {
|
||||||
}, TypeError);
|
assert.equal(store.get('this:key:does:not:exist'), undefined);
|
||||||
},
|
}, TypeError);
|
||||||
"should not fail when drilling into non-objects": function (store) {
|
},
|
||||||
assert.doesNotThrow(function() {
|
"within numbers": function (store) {
|
||||||
assert.equal(store.get('falsy:number:uh:oh'), undefined);
|
assert.doesNotThrow(function() {
|
||||||
}, TypeError);
|
assert.equal(store.get('falsy:number:not:exist'), undefined);
|
||||||
|
}, TypeError);
|
||||||
|
},
|
||||||
|
"within booleans": function (store) {
|
||||||
|
assert.doesNotThrow(function() {
|
||||||
|
assert.equal(store.get('falsy:boolean:not:exist'), undefined);
|
||||||
|
}, TypeError);
|
||||||
|
},
|
||||||
|
"within objects": function (store) {
|
||||||
|
assert.doesNotThrow(function() {
|
||||||
|
assert.equal(store.get('falsy:object:not:exist'), undefined);
|
||||||
|
}, TypeError);
|
||||||
|
},
|
||||||
|
"within empty strings": function (store) {
|
||||||
|
assert.doesNotThrow(function() {
|
||||||
|
assert.equal(store.get('falsy:string:empty:not:exist'), undefined);
|
||||||
|
}, TypeError);
|
||||||
|
},
|
||||||
|
"within empty strings": function (store) {
|
||||||
|
assert.doesNotThrow(function() {
|
||||||
|
assert.equal(store.get('falsy:string:value:not:exist'), undefined);
|
||||||
|
}, TypeError);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"the clear() method": {
|
"the clear() method": {
|
||||||
|
|
Loading…
Reference in a new issue