aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorfrankiebee <frankie.diamond@gmail.com>2017-05-12 01:47:58 +0800
committerfrankiebee <frankie.diamond@gmail.com>2017-05-12 05:25:34 +0800
commit8421cf9ccea80e4958a1a70d068bbffa57577390 (patch)
treee9e5a91f86abfa0d848dabdf757a133cc5d92740 /test
parent6c01b26845cfb8e113d3016ebd595a9098623f62 (diff)
downloadtangerine-wallet-browser-8421cf9ccea80e4958a1a70d068bbffa57577390.tar
tangerine-wallet-browser-8421cf9ccea80e4958a1a70d068bbffa57577390.tar.gz
tangerine-wallet-browser-8421cf9ccea80e4958a1a70d068bbffa57577390.tar.bz2
tangerine-wallet-browser-8421cf9ccea80e4958a1a70d068bbffa57577390.tar.lz
tangerine-wallet-browser-8421cf9ccea80e4958a1a70d068bbffa57577390.tar.xz
tangerine-wallet-browser-8421cf9ccea80e4958a1a70d068bbffa57577390.tar.zst
tangerine-wallet-browser-8421cf9ccea80e4958a1a70d068bbffa57577390.zip
Create test for Migrator
Diffstat (limited to 'test')
-rw-r--r--test/unit/migrator-test.js41
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)
+ })
+})