From 2019c02fc0fc33d4bd98416654370250d7aa0ca6 Mon Sep 17 00:00:00 2001 From: kumavis Date: Wed, 11 Jan 2017 19:26:56 -0800 Subject: test - fix tests from obs-store --- test/lib/mock-config-manager.js | 7 +++++-- test/unit/idStore-migration-test.js | 8 ++++---- test/unit/metamask-controller-test.js | 6 ++++-- 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/lib/mock-config-manager.js b/test/lib/mock-config-manager.js index b79f63090..0e84aa001 100644 --- a/test/lib/mock-config-manager.js +++ b/test/lib/mock-config-manager.js @@ -1,9 +1,12 @@ -var ConfigManager = require('../../app/scripts/lib/config-manager') +const ConfigManager = require('../../app/scripts/lib/config-manager') +const ObservableStore = require('../../app/scripts/lib/observable/') const STORAGE_KEY = 'metamask-config' const extend = require('xtend') module.exports = function() { - return new ConfigManager({ loadData, setData }) + let store = new ObservableStore(loadData()) + store.subscribe(setData) + return new ConfigManager({ store }) } function loadData () { diff --git a/test/unit/idStore-migration-test.js b/test/unit/idStore-migration-test.js index 54f38fb2f..4adbef740 100644 --- a/test/unit/idStore-migration-test.js +++ b/test/unit/idStore-migration-test.js @@ -3,6 +3,7 @@ const assert = require('assert') const ethUtil = require('ethereumjs-util') const BN = ethUtil.BN const ConfigManager = require('../../app/scripts/lib/config-manager') +const ObservableStore = require('../../app/scripts/lib/observable/') const delegateCallCode = require('../lib/example-code.json').delegateCallCode // The old way: @@ -42,10 +43,9 @@ describe('IdentityStore to KeyringController migration', function() { beforeEach(function(done) { this.sinon = sinon.sandbox.create() window.localStorage = {} // Hacking localStorage support into JSDom - configManager = new ConfigManager({ - loadData, - setData: (d) => { window.localStorage = d } - }) + let store = new ObservableStore(loadData()) + store.subscribe(setData) + configManager = new ConfigManager({ store }) idStore = new IdentityStore({ diff --git a/test/unit/metamask-controller-test.js b/test/unit/metamask-controller-test.js index 414610404..e648ebd1d 100644 --- a/test/unit/metamask-controller-test.js +++ b/test/unit/metamask-controller-test.js @@ -10,9 +10,11 @@ describe('MetaMaskController', function() { showUnconfirmedMessage: noop, unlockAccountMessage: noop, showUnapprovedTx: noop, - setData, - loadData, + // initial state + initState: loadData(), }) + // setup state persistence + controller.store.subscribe(setData) beforeEach(function() { // sinon allows stubbing methods that are easily verified -- cgit v1.2.3