diff options
author | Dan Finlay <flyswatter@users.noreply.github.com> | 2017-05-13 03:55:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-13 03:55:16 +0800 |
commit | 117cf9c331468390867323000a233b510c47fee1 (patch) | |
tree | 17624f4475c561345a08750543684987f5434f95 /test/unit | |
parent | 154eac4a3aed91bf63146601d0850e2ac2d4cfc5 (diff) | |
parent | dde3beb0446a64ab9348c75386c2e7ab0641d828 (diff) | |
download | tangerine-wallet-browser-117cf9c331468390867323000a233b510c47fee1.tar tangerine-wallet-browser-117cf9c331468390867323000a233b510c47fee1.tar.gz tangerine-wallet-browser-117cf9c331468390867323000a233b510c47fee1.tar.bz2 tangerine-wallet-browser-117cf9c331468390867323000a233b510c47fee1.tar.lz tangerine-wallet-browser-117cf9c331468390867323000a233b510c47fee1.tar.xz tangerine-wallet-browser-117cf9c331468390867323000a233b510c47fee1.tar.zst tangerine-wallet-browser-117cf9c331468390867323000a233b510c47fee1.zip |
Merge pull request #1417 from MetaMask/fixMigrator2
Fix and simplify migrator with es7
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/migrator-test.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/unit/migrator-test.js b/test/unit/migrator-test.js new file mode 100644 index 000000000..ece95b9f6 --- /dev/null +++ b/test/unit/migrator-test.js @@ -0,0 +1,41 @@ +const assert = require('assert') +const clone = require('clone') +const Migrator = require('../../app/scripts/lib/migrator/') +const migrations = [ + { + version: 1, + migrate: (data) => { + // clone the data just like we do in migrations + const clonedData = clone(data) + clonedData.meta.version = 1 + return Promise.resolve(clonedData) + }, + }, + { + version: 2, + migrate: (data) => { + const clonedData = clone(data) + clonedData.meta.version = 2 + return Promise.resolve(clonedData) + }, + }, + { + version: 3, + migrate: (data) => { + const clonedData = clone(data) + clonedData.meta.version = 3 + return Promise.resolve(clonedData) + }, + }, +] +const versionedData = {meta: {version: 0}, data:{hello:'world'}} +describe('Migrator', () => { + const migrator = new Migrator({ migrations }) + it('migratedData version should be version 3', (done) => { + migrator.migrateData(versionedData) + .then((migratedData) => { + assert.equal(migratedData.meta.version, migrations[2].version) + done() + }).catch(done) + }) +}) |