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.
41 lines
1.3 KiB
41 lines
1.3 KiB
4 years ago
|
import assert from 'assert';
|
||
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
|
||
4 years ago
|
import migration22 from './022';
|
||
5 years ago
|
|
||
4 years ago
|
const properTime = new Date().getTime();
|
||
7 years ago
|
const storage = {
|
||
4 years ago
|
meta: {},
|
||
|
data: {
|
||
|
TransactionController: {
|
||
|
transactions: [
|
||
4 years ago
|
{ status: TRANSACTION_STATUSES.SUBMITTED },
|
||
|
{ status: TRANSACTION_STATUSES.SUBMITTED, submittedTime: properTime },
|
||
|
{ status: TRANSACTION_STATUSES.CONFIRMED },
|
||
7 years ago
|
],
|
||
7 years ago
|
},
|
||
|
},
|
||
4 years ago
|
};
|
||
7 years ago
|
|
||
5 years ago
|
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', function () {
|
||
|
it('should add submittedTime key on the txMeta if appropriate', function (done) {
|
||
4 years ago
|
migration22
|
||
|
.migrate(storage)
|
||
5 years ago
|
.then((migratedData) => {
|
||
4 years ago
|
const [
|
||
|
txMeta1,
|
||
|
txMeta2,
|
||
|
txMeta3,
|
||
4 years ago
|
] = migratedData.data.TransactionController.transactions;
|
||
|
assert.equal(migratedData.meta.version, 22);
|
||
5 years ago
|
// should have written a submitted time
|
||
4 years ago
|
assert(txMeta1.submittedTime);
|
||
5 years ago
|
// should not have written a submitted time because it already has one
|
||
4 years ago
|
assert.equal(txMeta2.submittedTime, properTime);
|
||
5 years ago
|
// should not have written a submitted time
|
||
4 years ago
|
assert(!txMeta3.submittedTime);
|
||
|
done();
|
||
4 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
|
});
|