aboutsummaryrefslogtreecommitdiffstats
path: root/test/lib
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-06-25 07:13:27 +0800
committerDan Finlay <dan@danfinlay.com>2016-06-25 07:13:27 +0800
commit122018a96a1b2b6d9b7eefe150ff76a9de69bdd7 (patch)
treecc72b18de256dad9db7055b4c4631cfa9d192347 /test/lib
parentfa7e4665594525256b846de93bdd46115a3a53a7 (diff)
downloadtangerine-wallet-browser-122018a96a1b2b6d9b7eefe150ff76a9de69bdd7.tar
tangerine-wallet-browser-122018a96a1b2b6d9b7eefe150ff76a9de69bdd7.tar.gz
tangerine-wallet-browser-122018a96a1b2b6d9b7eefe150ff76a9de69bdd7.tar.bz2
tangerine-wallet-browser-122018a96a1b2b6d9b7eefe150ff76a9de69bdd7.tar.lz
tangerine-wallet-browser-122018a96a1b2b6d9b7eefe150ff76a9de69bdd7.tar.xz
tangerine-wallet-browser-122018a96a1b2b6d9b7eefe150ff76a9de69bdd7.tar.zst
tangerine-wallet-browser-122018a96a1b2b6d9b7eefe150ff76a9de69bdd7.zip
Fixed tests
Diffstat (limited to 'test/lib')
-rw-r--r--test/lib/mock-config-manager.js57
1 files changed, 57 insertions, 0 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)
+}