diff options
author | Mike Gerwitz <gerwitzm@lovullo.com> | 2017-01-30 00:30:12 -0500 |
---|---|---|
committer | Mike Gerwitz <gerwitzm@lovullo.com> | 2017-01-30 00:43:13 -0500 |
commit | 61a59db4e0e10a4bb3c6f2347192280c351e47b7 (patch) | |
tree | 7c0ef8ce017058ddfe71cde54d41f7640489a32b /test | |
parent | 0dcbd3220250ab889472d92433b24470d8a5e051 (diff) | |
download | liza-61a59db4e0e10a4bb3c6f2347192280c351e47b7.tar.gz liza-61a59db4e0e10a4bb3c6f2347192280c351e47b7.tar.bz2 liza-61a59db4e0e10a4bb3c6f2347192280c351e47b7.zip |
system.client: working data.diffStore
* src/system/client.js (data.diffStore): Compose all stores.
* test/system/clientTest.js: Update test case.
DEV-2296
Diffstat (limited to 'test')
-rw-r--r-- | test/system/clientTest.js | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/test/system/clientTest.js b/test/system/clientTest.js index 0b18838..1b52185 100644 --- a/test/system/clientTest.js +++ b/test/system/clientTest.js @@ -27,20 +27,49 @@ const root = require( '../../' ); const sut = root.system.client; const expect = require( 'chai' ).expect; -const Store = root.store.Store; const Class = require( 'easejs' ).Class; +const { Store, DiffStore } = root.store; + describe( 'client', () => { describe( 'data.diffStore', () => { - it( 'produces Store', () => + it( 'produces proper Stores', () => { - const result = sut.data.diffStore(); + const { store, cstore, bstore } = sut.data.diffStore(); + + // we don't care what type of store these two are + expect( Class.isA( Store, store ) ) + .to.be.true; + expect( Class.isA( Store, bstore ) ) + .to.be.true; - expect( Class.isA( Store, result ) ) + // but it's essential that this is a DiffStore + expect( Class.isA( DiffStore, cstore ) ) .to.be.true; } ); + + + it( 'proxies c:* to cstore, others to bstore', () => + { + const { store, cstore, bstore } = sut.data.diffStore(); + + const cname = 'c:foo'; // Master Shifu + const cval = 'panda'; + + const bname = 'henry'; + const bval = 'liza'; + + return expect( + store.add( cname, cval ) + .then( () => store.add( bname, bval ) ) + .then( () => Promise.all( [ + cstore.get( cname.replace( /^c:/, '' ) ), + bstore.get( bname ) + ] ) ) + ).to.eventually.deep.equal( [ cval, bval ] ); + } ); } ); } ); |