mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-01 21:57:06 +01:00
76a2a9bb8b
* @metamask/eslint-config@5.0.0 * Update eslintrc and prettierrc * yarn lint:fix
36 lines
1.3 KiB
JavaScript
36 lines
1.3 KiB
JavaScript
import assert from 'assert';
|
|
import { ObservableStore } from '@metamask/obs-store';
|
|
import ComposableObservableStore from '../../../app/scripts/lib/ComposableObservableStore';
|
|
|
|
describe('ComposableObservableStore', function () {
|
|
it('should register initial state', function () {
|
|
const store = new ComposableObservableStore('state');
|
|
assert.strictEqual(store.getState(), 'state');
|
|
});
|
|
|
|
it('should register initial structure', function () {
|
|
const testStore = new ObservableStore();
|
|
const store = new ComposableObservableStore(null, { TestStore: testStore });
|
|
testStore.putState('state');
|
|
assert.deepEqual(store.getState(), { TestStore: 'state' });
|
|
});
|
|
|
|
it('should update structure', function () {
|
|
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', function () {
|
|
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' });
|
|
});
|
|
});
|