diff options
author | Frankie <frankie.pangilinan@consensys.net> | 2016-06-25 09:02:28 +0800 |
---|---|---|
committer | Frankie <frankie.pangilinan@consensys.net> | 2016-06-25 09:02:28 +0800 |
commit | ab55fefa1a4ebeaa9a42756a72d49b63f036b946 (patch) | |
tree | f30f51dd7dbe413b8944b230d14660a4c1a2fd61 /test | |
parent | ef743499cb93dc8360be20db03c4ab0676aa57bb (diff) | |
parent | 36a183db94e66999421980f50c2ab2e8d1ce2c3b (diff) | |
download | tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.tar tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.tar.gz tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.tar.bz2 tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.tar.lz tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.tar.xz tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.tar.zst tangerine-wallet-browser-ab55fefa1a4ebeaa9a42756a72d49b63f036b946.zip |
Merge branch 'master' into uiFixes
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/mock-config-manager.js | 57 | ||||
-rw-r--r-- | test/unit/config-manager-test.js | 7 | ||||
-rw-r--r-- | test/unit/idStore-test.js | 4 |
3 files changed, 66 insertions, 2 deletions
diff --git a/test/lib/mock-config-manager.js b/test/lib/mock-config-manager.js new file mode 100644 index 000000000..fe841f455 --- /dev/null +++ b/test/lib/mock-config-manager.js @@ -0,0 +1,57 @@ +var ConfigManager = require('../../app/scripts/lib/config-manager') +const STORAGE_KEY = 'metamask-persistance-key' +const extend = require('xtend') + +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) +} diff --git a/test/unit/config-manager-test.js b/test/unit/config-manager-test.js index 130bde2ff..7891c5c9e 100644 --- a/test/unit/config-manager-test.js +++ b/test/unit/config-manager-test.js @@ -1,12 +1,14 @@ var assert = require('assert') -var ConfigManager = require('../../app/scripts/lib/config-manager') +const extend = require('xtend') +const STORAGE_KEY = 'metamask-persistance-key' +var configManagerGen = require('../lib/mock-config-manager') var configManager describe('config-manager', function() { beforeEach(function() { window.localStorage = {} // Hacking localStorage support into JSDom - configManager = new ConfigManager() + configManager = configManagerGen() }) describe('confirmation', function() { @@ -209,3 +211,4 @@ describe('config-manager', function() { }) }) }) + diff --git a/test/unit/idStore-test.js b/test/unit/idStore-test.js index e9611d7e8..ee4613236 100644 --- a/test/unit/idStore-test.js +++ b/test/unit/idStore-test.js @@ -1,5 +1,6 @@ var assert = require('assert') var IdentityStore = require('../../app/scripts/lib/idStore') +var configManagerGen = require('../lib/mock-config-manager') describe('IdentityStore', function() { @@ -15,6 +16,7 @@ describe('IdentityStore', function() { window.localStorage = {} // Hacking localStorage support into JSDom idStore = new IdentityStore({ + configManager: configManagerGen(), ethStore: { addAccount(acct) { accounts.push(acct) }, }, @@ -34,6 +36,7 @@ describe('IdentityStore', function() { window.localStorage = {} // Hacking localStorage support into JSDom idStore = new IdentityStore({ + configManager: configManagerGen(), ethStore: { addAccount(acct) { newAccounts.push(acct) }, }, @@ -65,6 +68,7 @@ describe('IdentityStore', function() { window.localStorage = {} // Hacking localStorage support into JSDom idStore = new IdentityStore({ + configManager: configManagerGen(), ethStore: { addAccount(acct) { accounts.push(acct) }, }, |