diff --git a/src/store/Cascading.js b/src/store/Cascading.js index 5e6c55d..70155a7 100644 --- a/src/store/Cascading.js +++ b/src/store/Cascading.js @@ -72,7 +72,8 @@ module.exports = Trait( 'Cascading' ) * @param {string} key store key * @param {Store} value Store to attach * - * @return {Promise} promise to add item to store + * @return {Promise.} promise to add item to store, resolving to + * self (for chaining) */ 'virtual abstract override public add': function( key, value ) { diff --git a/src/store/MemoryStore.js b/src/store/MemoryStore.js index d4b92da..a055b9f 100644 --- a/src/store/MemoryStore.js +++ b/src/store/MemoryStore.js @@ -75,23 +75,17 @@ module.exports = Class( 'MemoryStore' ) /** * Add item to store under `key` with value `value` * - * The promise will be fulfilled with an object containing the - * `key` and `value` added to the store; this is convenient for - * promises. - * * @param {string} key store key * @param {*} value value for key * - * @return {Promise} promise to add item to store + * @return {Promise.} promise to add item to store, resolving to + * self (for chaining) */ 'virtual public add': function( key, value ) { this._store[ key ] = value; - return Promise.resolve( { - key: key, - value: value, - } ); + return Promise.resolve( this.__inst ); }, diff --git a/src/store/Store.js b/src/store/Store.js index 3daf69b..acd96c4 100644 --- a/src/store/Store.js +++ b/src/store/Store.js @@ -44,7 +44,8 @@ module.exports = Interface( 'Store', * @param {string} key store key * @param {*} value value for key * - * @return {Promise} promise to add item to store + * @return {Promise.} promise to add item to store, resolving to + * self (for chaining) */ 'public add': [ 'key', 'value' ], diff --git a/test/store/MemoryStoreTest.js b/test/store/MemoryStoreTest.js index 7d47bc2..452dbbb 100644 --- a/test/store/MemoryStoreTest.js +++ b/test/store/MemoryStoreTest.js @@ -60,14 +60,13 @@ describe( 'store.MemoryStore', () => } ); - it( 'provides the key and value of the added item', () => + it( 'returns self with promise', () => { - const key = 'key'; - const value = 'val'; + const sut = Sut(); return expect( - Sut().add( key, value ) - ).to.eventually.deep.equal( { key: key, value: value } ); + sut.add( 'foo', 'bar' ) + ).to.eventually.equal( sut ); } ); } );