You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.6 KiB
60 lines
1.6 KiB
4 years ago
|
import assert from 'assert';
|
||
4 years ago
|
import firstTimeState from '../first-time-state';
|
||
4 years ago
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
|
||
4 years ago
|
import migration27 from './027';
|
||
7 years ago
|
|
||
|
const oldStorage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
TransactionController: {
|
||
|
transactions: [],
|
||
7 years ago
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
7 years ago
|
|
||
4 years ago
|
const transactions = [];
|
||
7 years ago
|
|
||
|
while (transactions.length < 9) {
|
||
4 years ago
|
transactions.push({ status: TRANSACTION_STATUSES.REJECTED });
|
||
|
transactions.push({ status: TRANSACTION_STATUSES.UNAPPROVED });
|
||
|
transactions.push({ status: TRANSACTION_STATUSES.APPROVED });
|
||
7 years ago
|
}
|
||
|
|
||
4 years ago
|
oldStorage.data.TransactionController.transactions = transactions;
|
||
7 years ago
|
|
||
5 years ago
|
describe('migration #27', function () {
|
||
|
it('should remove rejected transactions', function (done) {
|
||
4 years ago
|
migration27
|
||
|
.migrate(oldStorage)
|
||
7 years ago
|
.then((newStorage) => {
|
||
4 years ago
|
const newTransactions =
|
||
4 years ago
|
newStorage.data.TransactionController.transactions;
|
||
4 years ago
|
assert.equal(
|
||
|
newTransactions.length,
|
||
|
6,
|
||
|
'transactions is expected to have the length of 6',
|
||
4 years ago
|
);
|
||
7 years ago
|
newTransactions.forEach((txMeta) => {
|
||
4 years ago
|
if (txMeta.status === TRANSACTION_STATUSES.REJECTED) {
|
||
4 years ago
|
done(new Error('transaction was found with a status of rejected'));
|
||
5 years ago
|
}
|
||
4 years ago
|
});
|
||
|
done();
|
||
7 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
7 years ago
|
|
||
5 years ago
|
it('should successfully migrate first time state', function (done) {
|
||
4 years ago
|
migration27
|
||
|
.migrate({
|
||
|
meta: {},
|
||
|
data: firstTimeState,
|
||
|
})
|
||
7 years ago
|
.then((migratedData) => {
|
||
4 years ago
|
assert.equal(migratedData.meta.version, migration27.version);
|
||
|
done();
|
||
4 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
|
});
|