diff options
author | frankiebee <frankie.diamond@gmail.com> | 2018-04-06 08:49:50 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2018-04-06 08:49:50 +0800 |
commit | 1ba74c1566fe67f610a730c362b3989e63787d4c (patch) | |
tree | f608984483ee3d890a6884a1f40318f67baa5bac | |
parent | b8efe120a9ff21aa4b9762dbd72de9a65a0d768d (diff) | |
download | tangerine-wallet-browser-1ba74c1566fe67f610a730c362b3989e63787d4c.tar tangerine-wallet-browser-1ba74c1566fe67f610a730c362b3989e63787d4c.tar.gz tangerine-wallet-browser-1ba74c1566fe67f610a730c362b3989e63787d4c.tar.bz2 tangerine-wallet-browser-1ba74c1566fe67f610a730c362b3989e63787d4c.tar.lz tangerine-wallet-browser-1ba74c1566fe67f610a730c362b3989e63787d4c.tar.xz tangerine-wallet-browser-1ba74c1566fe67f610a730c362b3989e63787d4c.tar.zst tangerine-wallet-browser-1ba74c1566fe67f610a730c362b3989e63787d4c.zip |
test - run live migrations over first time state
-rw-r--r-- | test/unit/migrator-test.js | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/test/unit/migrator-test.js b/test/unit/migrator-test.js index 16066fefe..9e8b59958 100644 --- a/test/unit/migrator-test.js +++ b/test/unit/migrator-test.js @@ -1,7 +1,8 @@ const assert = require('assert') const clone = require('clone') const Migrator = require('../../app/scripts/lib/migrator/') -const migrations = [ +const liveMigrations = require('../../app/scripts/migrations/') +const stubMigrations = [ { version: 1, migrate: (data) => { @@ -29,13 +30,33 @@ const migrations = [ }, ] const versionedData = {meta: {version: 0}, data: {hello: 'world'}} -describe('Migrator', () => { - const migrator = new Migrator({ migrations }) + +const firstTimeState = { + meta: { version: 0 }, + data: require('../../app/scripts/first-time-state'), +} + +describe.only('Migrator', () => { + const migrator = new Migrator({ migrations: stubMigrations }) it('migratedData version should be version 3', (done) => { + migrator.on('error', console.log) migrator.migrateData(versionedData) .then((migratedData) => { - assert.equal(migratedData.meta.version, migrations[2].version) + assert.equal(migratedData.meta.version, stubMigrations[2].version) done() }).catch(done) }) + + it('should match the last version in live migrations', (done) => { + const migrator = new Migrator({ migrations: liveMigrations }) + migrator.on('error', console.log) + migrator.migrateData(firstTimeState) + .then((migratedData) => { + console.log(migratedData) + const last = liveMigrations.length - 1 + assert.equal(migratedData.meta.version, liveMigrations[last].version) + done() + }).catch(done) + }) + }) |