mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 10:30:04 +01:00
92971d3c87
* Update eslint-plugin-import version * Convert JS files to use ESM * Update ESLint rules to check imports * Fix test:unit:global command env * Cleanup mock-dev script
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
import assert from 'assert'
|
|
import ComposableObservableStore from '../../../app/scripts/lib/ComposableObservableStore'
|
|
import ObservableStore from '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' })
|
|
})
|
|
})
|