aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorEsteban MIno <efmino@uc.cl>2018-08-10 04:41:16 +0800
committerEsteban MIno <efmino@uc.cl>2018-08-10 04:41:16 +0800
commitd263d60b4c37bca5f95253965999d541375cc04b (patch)
tree0f7a9a06b069b9fc0eafcb459ae65455465a14c8 /test
parent8df3f2696c4c5aad4e0e929e0a8a38e8c7135f72 (diff)
downloadtangerine-wallet-browser-d263d60b4c37bca5f95253965999d541375cc04b.tar
tangerine-wallet-browser-d263d60b4c37bca5f95253965999d541375cc04b.tar.gz
tangerine-wallet-browser-d263d60b4c37bca5f95253965999d541375cc04b.tar.bz2
tangerine-wallet-browser-d263d60b4c37bca5f95253965999d541375cc04b.tar.lz
tangerine-wallet-browser-d263d60b4c37bca5f95253965999d541375cc04b.tar.xz
tangerine-wallet-browser-d263d60b4c37bca5f95253965999d541375cc04b.tar.zst
tangerine-wallet-browser-d263d60b4c37bca5f95253965999d541375cc04b.zip
tests for migration 28
Diffstat (limited to 'test')
-rw-r--r--test/unit/migrations/028-test.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/unit/migrations/028-test.js b/test/unit/migrations/028-test.js
new file mode 100644
index 000000000..a9c7dcdf1
--- /dev/null
+++ b/test/unit/migrations/028-test.js
@@ -0,0 +1,46 @@
+const assert = require('assert')
+const migration28 = require('../../../app/scripts/migrations/028')
+
+const oldStorage = {
+ 'meta': {},
+ 'data': {
+ 'PreferencesController': {
+ 'tokens': [{address: '0xa', symbol: 'A', decimals: 4}, {address: '0xb', symbol: 'B', decimals: 4}],
+ 'identities': {
+ '0x6d14': {},
+ '0x3695': {},
+ },
+ },
+ },
+}
+
+describe('migration #28', () => {
+ it('should add corresponding tokens to accountTokens', (done) => {
+ migration28.migrate(oldStorage)
+ .then((newStorage) => {
+ const newTokens = newStorage.data.PreferencesController.tokens
+ const newAccountTokens = newStorage.data.PreferencesController.accountTokens
+
+ const testTokens = [{address: '0xa', symbol: 'A', decimals: 4}, {address: '0xb', symbol: 'B', decimals: 4}]
+ assert.equal(newTokens.length, 0, 'tokens is expected to have the length of 0')
+ assert.equal(newAccountTokens['0x6d14']['mainnet'].length, 2, 'tokens for address is expected to have the length of 2')
+ assert.equal(newAccountTokens['0x3695']['mainnet'].length, 2, 'tokens for address is expected to have the length of 2')
+ assert.equal(Object.keys(newAccountTokens).length, 2, 'account tokens should be created for all identities')
+ assert.deepEqual(newAccountTokens['0x6d14']['mainnet'], testTokens, 'tokens for address should be the same than before')
+ assert.deepEqual(newAccountTokens['0x3695']['mainnet'], testTokens, 'tokens for address should be the same than before')
+ done()
+ })
+ .catch(done)
+ })
+
+ it('should successfully migrate first time state', (done) => {
+ migration28.migrate({
+ meta: {},
+ data: require('../../../app/scripts/first-time-state'),
+ })
+ .then((migratedData) => {
+ assert.equal(migratedData.meta.version, migration28.version)
+ done()
+ }).catch(done)
+ })
+})