test - run live migrations over first time state

feature/default_network_editable
frankiebee 7 years ago
parent b8efe120a9
commit 1ba74c1566
  1. 29
      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)
})
})

Loading…
Cancel
Save