aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-05-16 06:36:03 +0800
committerDan Finlay <dan@danfinlay.com>2017-05-16 06:36:03 +0800
commit6abdec608efadb99be96be498a7c706ec8503342 (patch)
tree674481221d80122521d3ec820d24f8158c6f9993 /test
parentf9c0fc0e8cb04f371ce8e99c41c74989841c2c24 (diff)
parentfe3e943169ec32cf6b1db3f9469855cbf8b51403 (diff)
downloadtangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.tar
tangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.tar.gz
tangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.tar.bz2
tangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.tar.lz
tangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.tar.xz
tangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.tar.zst
tangerine-wallet-browser-6abdec608efadb99be96be498a7c706ec8503342.zip
Merge branch 'master' into i1407-FixNonEditingTxForm
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)
+ })
+})