2021-02-04 19:15:23 +01:00
|
|
|
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
|
2021-03-16 22:00:08 +01:00
|
|
|
import migration22 from './022';
|
2020-01-09 04:34:58 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
const properTime = new Date().getTime();
|
2018-03-26 23:24:12 +02:00
|
|
|
const storage = {
|
2020-11-03 00:41:28 +01:00
|
|
|
meta: {},
|
|
|
|
data: {
|
|
|
|
TransactionController: {
|
|
|
|
transactions: [
|
2020-11-07 08:38:12 +01:00
|
|
|
{ status: TRANSACTION_STATUSES.SUBMITTED },
|
|
|
|
{ status: TRANSACTION_STATUSES.SUBMITTED, submittedTime: properTime },
|
|
|
|
{ status: TRANSACTION_STATUSES.CONFIRMED },
|
2018-07-03 00:49:33 +02:00
|
|
|
],
|
2018-03-26 23:24:12 +02:00
|
|
|
},
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2018-03-26 23:24:12 +02:00
|
|
|
|
2021-09-21 18:28:13 +02:00
|
|
|
describe('storage is migrated successfully where transactions that are submitted have submittedTimes', () => {
|
|
|
|
it('should add submittedTime key on the txMeta if appropriate', async () => {
|
|
|
|
const migratedData = await migration22.migrate(storage);
|
|
|
|
const [
|
|
|
|
txMeta1,
|
|
|
|
txMeta2,
|
|
|
|
txMeta3,
|
|
|
|
] = migratedData.data.TransactionController.transactions;
|
|
|
|
|
|
|
|
expect(migratedData.meta.version).toStrictEqual(22);
|
|
|
|
// should have written a submitted time
|
|
|
|
expect.anything(txMeta1.submittedTime);
|
|
|
|
// should not have written a submitted time because it already has one
|
|
|
|
expect(txMeta2.submittedTime).toStrictEqual(properTime);
|
|
|
|
// should not have written a submitted time
|
|
|
|
expect(!txMeta3.submittedTime).toStrictEqual(true);
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|