diff options
author | Dan Finlay <542863+danfinlay@users.noreply.github.com> | 2018-04-18 04:36:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-18 04:36:21 +0800 |
commit | 6ee57dcad70057b1f71b9abe53d9d4965cbbe3e8 (patch) | |
tree | 096c6a8f7e12c5ece8bb64af1466bb2d94b6e5d3 /test/unit/ComposableObservableStore.js | |
parent | f15b81089e86dc095983faeba4a97209ddd670ce (diff) | |
parent | 7b70804aa0d74120098a4bcb2c375d29080e8368 (diff) | |
download | tangerine-wallet-browser-6ee57dcad70057b1f71b9abe53d9d4965cbbe3e8.tar tangerine-wallet-browser-6ee57dcad70057b1f71b9abe53d9d4965cbbe3e8.tar.gz tangerine-wallet-browser-6ee57dcad70057b1f71b9abe53d9d4965cbbe3e8.tar.bz2 tangerine-wallet-browser-6ee57dcad70057b1f71b9abe53d9d4965cbbe3e8.tar.lz tangerine-wallet-browser-6ee57dcad70057b1f71b9abe53d9d4965cbbe3e8.tar.xz tangerine-wallet-browser-6ee57dcad70057b1f71b9abe53d9d4965cbbe3e8.tar.zst tangerine-wallet-browser-6ee57dcad70057b1f71b9abe53d9d4965cbbe3e8.zip |
Merge branch 'master' into i3580-InternationalizeCurrency
Diffstat (limited to 'test/unit/ComposableObservableStore.js')
-rw-r--r-- | test/unit/ComposableObservableStore.js | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/test/unit/ComposableObservableStore.js b/test/unit/ComposableObservableStore.js new file mode 100644 index 000000000..3fba200c1 --- /dev/null +++ b/test/unit/ComposableObservableStore.js @@ -0,0 +1,35 @@ +const assert = require('assert') +const ComposableObservableStore = require('../../app/scripts/lib/ComposableObservableStore') +const ObservableStore = require('obs-store') + +describe('ComposableObservableStore', () => { + it('should register initial state', () => { + const store = new ComposableObservableStore('state') + assert.strictEqual(store.getState(), 'state') + }) + + it('should register initial structure', () => { + const testStore = new ObservableStore() + const store = new ComposableObservableStore(null, { TestStore: testStore }) + testStore.putState('state') + assert.deepEqual(store.getState(), { TestStore: 'state' }) + }) + + it('should update structure', () => { + const testStore = new ObservableStore() + const store = new ComposableObservableStore() + store.updateStructure({ TestStore: testStore }) + testStore.putState('state') + assert.deepEqual(store.getState(), { TestStore: 'state' }) + }) + + it('should return flattened state', () => { + const fooStore = new ObservableStore({ foo: 'foo' }) + const barStore = new ObservableStore({ bar: 'bar' }) + const store = new ComposableObservableStore(null, { + FooStore: fooStore, + BarStore: barStore, + }) + assert.deepEqual(store.getFlatState(), { foo: 'foo', bar: 'bar' }) + }) +}) |