aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/idStore-migration-test.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-01-28 15:04:34 +0800
committerkumavis <aaron@kumavis.me>2017-01-28 15:04:34 +0800
commit3afd0ef27d69ed5d130f4ea37e3e856cadba34d9 (patch)
tree5814f405217375ce3897eea90be556a809e6a4e0 /test/unit/idStore-migration-test.js
parentad9531d521057da3540a47bfa592dee6fd225d2e (diff)
downloadtangerine-wallet-browser-3afd0ef27d69ed5d130f4ea37e3e856cadba34d9.tar
tangerine-wallet-browser-3afd0ef27d69ed5d130f4ea37e3e856cadba34d9.tar.gz
tangerine-wallet-browser-3afd0ef27d69ed5d130f4ea37e3e856cadba34d9.tar.bz2
tangerine-wallet-browser-3afd0ef27d69ed5d130f4ea37e3e856cadba34d9.tar.lz
tangerine-wallet-browser-3afd0ef27d69ed5d130f4ea37e3e856cadba34d9.tar.xz
tangerine-wallet-browser-3afd0ef27d69ed5d130f4ea37e3e856cadba34d9.tar.zst
tangerine-wallet-browser-3afd0ef27d69ed5d130f4ea37e3e856cadba34d9.zip
tests - remove persistence and start with initial state
Diffstat (limited to 'test/unit/idStore-migration-test.js')
-rw-r--r--test/unit/idStore-migration-test.js58
1 files changed, 3 insertions, 55 deletions
diff --git a/test/unit/idStore-migration-test.js b/test/unit/idStore-migration-test.js
index 38667fc3e..47894a458 100644
--- a/test/unit/idStore-migration-test.js
+++ b/test/unit/idStore-migration-test.js
@@ -4,12 +4,13 @@ const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util')
const BN = ethUtil.BN
const ConfigManager = require('../../app/scripts/lib/config-manager')
+const firstTimeState = require('../../app/scripts/first-time-state')
const delegateCallCode = require('../lib/example-code.json').delegateCallCode
+const clone = require('clone')
// The old way:
const IdentityStore = require('../../app/scripts/lib/idStore')
const STORAGE_KEY = 'metamask-config'
-const extend = require('xtend')
// The new ways:
var KeyringController = require('../../app/scripts/keyring-controller')
@@ -42,12 +43,9 @@ describe('IdentityStore to KeyringController migration', function() {
// and THEN create a new one, before we can run tests on it.
beforeEach(function(done) {
this.sinon = sinon.sandbox.create()
- window.localStorage = {} // Hacking localStorage support into JSDom
- let store = new ObservableStore(loadData())
- store.subscribe(setData)
+ let store = new ObservableStore(clone(firstTimeState))
configManager = new ConfigManager({ store })
-
idStore = new IdentityStore({
configManager: configManager,
ethStore: {
@@ -94,53 +92,3 @@ describe('IdentityStore to KeyringController migration', function() {
})
})
})
-
-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 setData (data) {
- window.localStorage[STORAGE_KEY] = JSON.stringify(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
-}