From 7d3da0ae96a761461ee12bf20d8386a5ba7aade2 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Mon, 25 Jun 2018 11:45:00 -0700 Subject: migration 27 - remove rejected transactions from state --- test/unit/migrations/027-test.js | 50 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 test/unit/migrations/027-test.js (limited to 'test/unit/migrations/027-test.js') diff --git a/test/unit/migrations/027-test.js b/test/unit/migrations/027-test.js new file mode 100644 index 000000000..77c0bbee6 --- /dev/null +++ b/test/unit/migrations/027-test.js @@ -0,0 +1,50 @@ +const assert = require('assert') +const migration27 = require('../../../app/scripts/migrations/027') + +const oldStorage = { + "meta": {}, + "data": { + "TransactionController": { + "transactions": [ + ] + }, + }, +} + +const transactions = [] + + +while (transactions.length < 9) { + transactions.push({status: 'rejected'}) + transactions.push({status: 'unapproved'}) + transactions.push({status: 'approved'}) +} + + +oldStorage.data.TransactionController.transactions = transactions + +describe('migration #27', () => { + it('should remove rejected transactions', (done) => { + migration27.migrate(oldStorage) + .then((newStorage) => { + const newTransactions = newStorage.data.TransactionController.transactions + assert.equal(newTransactions.length, 6, 'transactions is expected to have the length of 6') + newTransactions.forEach((txMeta) => { + if (txMeta.status === 'rejected') done(new Error('transaction was found with a status of rejected')) + }) + done() + }) + .catch(done) + }) + + it('should successfully migrate first time state', (done) => { + migration27.migrate({ + meta: {}, + data: require('../../../app/scripts/first-time-state'), + }) + .then((migratedData) => { + assert.equal(migratedData.meta.version, migration27.version) + done() + }).catch(done) + }) +}) -- cgit v1.2.3 From 8a678001a959b5cb3d6b1d50920882c8f9b58043 Mon Sep 17 00:00:00 2001 From: frankiebee Date: Tue, 10 Jul 2018 11:43:00 -0700 Subject: test - fix for lint --- test/unit/migrations/027-test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'test/unit/migrations/027-test.js') diff --git a/test/unit/migrations/027-test.js b/test/unit/migrations/027-test.js index 77c0bbee6..3ec9f0c0e 100644 --- a/test/unit/migrations/027-test.js +++ b/test/unit/migrations/027-test.js @@ -2,11 +2,11 @@ const assert = require('assert') const migration27 = require('../../../app/scripts/migrations/027') const oldStorage = { - "meta": {}, - "data": { - "TransactionController": { - "transactions": [ - ] + 'meta': {}, + 'data': { + 'TransactionController': { + 'transactions': [ + ], }, }, } -- cgit v1.2.3