1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

test - fix tests from obs-store

This commit is contained in:
kumavis 2017-01-11 19:26:56 -08:00
parent 8012ede126
commit 2019c02fc0
3 changed files with 13 additions and 8 deletions

View File

@ -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 STORAGE_KEY = 'metamask-config'
const extend = require('xtend') const extend = require('xtend')
module.exports = function() { module.exports = function() {
return new ConfigManager({ loadData, setData }) let store = new ObservableStore(loadData())
store.subscribe(setData)
return new ConfigManager({ store })
} }
function loadData () { function loadData () {

View File

@ -3,6 +3,7 @@ const assert = require('assert')
const ethUtil = require('ethereumjs-util') const ethUtil = require('ethereumjs-util')
const BN = ethUtil.BN const BN = ethUtil.BN
const ConfigManager = require('../../app/scripts/lib/config-manager') const ConfigManager = require('../../app/scripts/lib/config-manager')
const ObservableStore = require('../../app/scripts/lib/observable/')
const delegateCallCode = require('../lib/example-code.json').delegateCallCode const delegateCallCode = require('../lib/example-code.json').delegateCallCode
// The old way: // The old way:
@ -42,10 +43,9 @@ describe('IdentityStore to KeyringController migration', function() {
beforeEach(function(done) { beforeEach(function(done) {
this.sinon = sinon.sandbox.create() this.sinon = sinon.sandbox.create()
window.localStorage = {} // Hacking localStorage support into JSDom window.localStorage = {} // Hacking localStorage support into JSDom
configManager = new ConfigManager({ let store = new ObservableStore(loadData())
loadData, store.subscribe(setData)
setData: (d) => { window.localStorage = d } configManager = new ConfigManager({ store })
})
idStore = new IdentityStore({ idStore = new IdentityStore({

View File

@ -10,9 +10,11 @@ describe('MetaMaskController', function() {
showUnconfirmedMessage: noop, showUnconfirmedMessage: noop,
unlockAccountMessage: noop, unlockAccountMessage: noop,
showUnapprovedTx: noop, showUnapprovedTx: noop,
setData, // initial state
loadData, initState: loadData(),
}) })
// setup state persistence
controller.store.subscribe(setData)
beforeEach(function() { beforeEach(function() {
// sinon allows stubbing methods that are easily verified // sinon allows stubbing methods that are easily verified