From 0d795ecf81613bd66229410395b2b4affc9a034d Mon Sep 17 00:00:00 2001 From: indexzero Date: Thu, 20 Dec 2012 14:08:36 -0500 Subject: [PATCH] [test] Better tests to show #65 --- test/stores/memory-store-test.js | 47 ++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/test/stores/memory-store-test.js b/test/stores/memory-store-test.js index 61b07ec..f79fd50 100644 --- a/test/stores/memory-store-test.js +++ b/test/stores/memory-store-test.js @@ -17,7 +17,8 @@ vows.describe('nconf/stores/memory').addBatch({ "should respond with true": function (store) { 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:string:empty', '')); + assert.isTrue(store.set('falsy:string:value', 'value')); assert.isTrue(store.set('falsy:boolean', false)); assert.isTrue(store.set('falsy:object', null)); } @@ -25,21 +26,43 @@ vows.describe('nconf/stores/memory').addBatch({ "the get() method": { "should respond with the correct value": function (store) { 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: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:object'), null); }, - "should not fail when retrieving non-existent keys": function (store) { - assert.doesNotThrow(function() { - assert.equal(store.get('this:key:does:not:exist'), undefined); - }, TypeError); - }, - "should not fail when drilling into non-objects": function (store) { - assert.doesNotThrow(function() { - assert.equal(store.get('falsy:number:uh:oh'), undefined); - }, TypeError); + "should not fail when retrieving non-existent keys": { + "at the root level": function (store) { + assert.doesNotThrow(function() { + assert.equal(store.get('this:key:does:not:exist'), undefined); + }, TypeError); + }, + "within numbers": function (store) { + assert.doesNotThrow(function() { + 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": {