1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-12 20:57:12 +01:00
metamask-extension/app/scripts/migrations/025.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

69 lines
1.7 KiB
JavaScript

import { strict as assert } from 'assert';
import data from '../first-time-state';
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction';
import migration25 from './025';
const firstTimeState = {
meta: {},
data,
};
const storage = {
meta: {},
data: {
TransactionController: {
transactions: [],
},
},
};
const transactions = [];
while (transactions.length <= 10) {
transactions.push({
txParams: {
from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675',
random: 'stuff',
chainId: 2,
},
status: TRANSACTION_STATUSES.UNAPPROVED,
});
transactions.push({
txParams: { from: '0x8aCce2391c0d510a6c5E5d8f819a678f79b7e675' },
status: TRANSACTION_STATUSES.CONFIRMED,
});
}
storage.data.TransactionController.transactions = transactions;
describe('storage is migrated successfully and the txParams.from are lowercase', function () {
it('should lowercase the from for unapproved txs', function (done) {
migration25
.migrate(storage)
.then((migratedData) => {
const migratedTransactions =
migratedData.data.TransactionController.transactions;
migratedTransactions.forEach((tx) => {
if (tx.status === TRANSACTION_STATUSES.UNAPPROVED) {
assert(!tx.txParams.random);
}
if (tx.status === TRANSACTION_STATUSES.UNAPPROVED) {
assert(!tx.txParams.chainId);
}
});
done();
})
.catch(done);
});
it('should migrate first time state', function (done) {
migration25
.migrate(firstTimeState)
.then((migratedData) => {
assert.equal(migratedData.meta.version, 25);
done();
})
.catch(done);
});
});