diff options
Merge branch 'kumavis-patch-1' of github.com:MetaMask/metamask-plugin into kumavis-patch-1
Diffstat (limited to 'test/lib/mock-config-manager.js')
-rw-r--r-- | test/lib/mock-config-manager.js | 63 |
1 files changed, 8 insertions, 55 deletions
diff --git a/test/lib/mock-config-manager.js b/test/lib/mock-config-manager.js index fe841f455..72be86ed1 100644 --- a/test/lib/mock-config-manager.js +++ b/test/lib/mock-config-manager.js @@ -1,57 +1,10 @@ -var ConfigManager = require('../../app/scripts/lib/config-manager') -const STORAGE_KEY = 'metamask-persistance-key' -const extend = require('xtend') +const ObservableStore = require('obs-store') +const clone = require('clone') +const ConfigManager = require('../../app/scripts/lib/config-manager') +const firstTimeState = require('../../app/scripts/first-time-state') +const STORAGE_KEY = 'metamask-config' module.exports = function() { - return new ConfigManager({ loadData, setData }) -} - -function loadData () { - var oldData = getOldStyleData() - var newData - try { - newData = JSON.parse(window.localStorage[STORAGE_KEY]) - } catch (e) {} - - var data = extend({ - meta: { - version: 0, - }, - data: { - config: { - provider: { - type: 'testnet', - }, - }, - }, - }, oldData || null, newData || null) - return data -} - -function getOldStyleData () { - var config, wallet, seedWords - - var result = { - meta: { version: 0 }, - data: {}, - } - - try { - config = JSON.parse(window.localStorage['config']) - result.data.config = config - } catch (e) {} - try { - wallet = JSON.parse(window.localStorage['lightwallet']) - result.data.wallet = wallet - } catch (e) {} - try { - seedWords = window.localStorage['seedWords'] - result.data.seedWords = seedWords - } catch (e) {} - - return result -} - -function setData (data) { - window.localStorage[STORAGE_KEY] = JSON.stringify(data) -} + let store = new ObservableStore(clone(firstTimeState)) + return new ConfigManager({ store }) +}
\ No newline at end of file |