aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorbitpshr <mail@bitpshr.net>2018-04-14 01:13:36 +0800
committerbitpshr <mail@bitpshr.net>2018-04-14 02:32:58 +0800
commit8974f933fc97a37f5cd8dcd510ff0e6dc21d6751 (patch)
tree83534cc83c316c10d9ed195f1c31bec869eaadf3 /test
parent4780f825b1bfb33f03c60133f293b122b8b43be4 (diff)
downloadtangerine-wallet-browser-8974f933fc97a37f5cd8dcd510ff0e6dc21d6751.tar
tangerine-wallet-browser-8974f933fc97a37f5cd8dcd510ff0e6dc21d6751.tar.gz
tangerine-wallet-browser-8974f933fc97a37f5cd8dcd510ff0e6dc21d6751.tar.bz2
tangerine-wallet-browser-8974f933fc97a37f5cd8dcd510ff0e6dc21d6751.tar.lz
tangerine-wallet-browser-8974f933fc97a37f5cd8dcd510ff0e6dc21d6751.tar.xz
tangerine-wallet-browser-8974f933fc97a37f5cd8dcd510ff0e6dc21d6751.tar.zst
tangerine-wallet-browser-8974f933fc97a37f5cd8dcd510ff0e6dc21d6751.zip
Add tests for ComposableObservableStore
Diffstat (limited to 'test')
-rw-r--r--test/unit/ComposableObservableStore.js35
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' })
+ })
+})