1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-26 20:39:08 +01:00
metamask-extension/app/scripts/migrations/022.test.js
Mark Stacey f47cfbbb3e
Use strict assertion mode everywhere (#11012)
The `assert` module has two modes: "Legacy" and "strict". When using
strict mode, the "strict" version of each assertion method is implied.
Whereas in legacy mode, by default it will use the deprecated, "loose"
version of each assertion.

We now use strict mode everywhere. A few tests required updates where
they were asserting the wrong thing, and it was passing beforehand due
to the loose matching.
2021-05-07 17:08:24 -02:30

41 lines
1.3 KiB
JavaScript

import { strict as assert } from 'assert';
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
import migration22 from './022';
const properTime = new Date().getTime();
const storage = {
meta: {},
data: {
TransactionController: {
transactions: [
{ status: TRANSACTION_STATUSES.SUBMITTED },
{ status: TRANSACTION_STATUSES.SUBMITTED, submittedTime: properTime },
{ status: TRANSACTION_STATUSES.CONFIRMED },
],
},
},
};
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) {
migration22
.migrate(storage)
.then((migratedData) => {
const [
txMeta1,
txMeta2,
txMeta3,
] = migratedData.data.TransactionController.transactions;
assert.equal(migratedData.meta.version, 22);
// should have written a submitted time
assert(txMeta1.submittedTime);
// should not have written a submitted time because it already has one
assert.equal(txMeta2.submittedTime, properTime);
// should not have written a submitted time
assert(!txMeta3.submittedTime);
done();
})
.catch(done);
});
});