1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 08:09:15 +01:00
metamask-extension/test/unit/migrations/022-test.js
Brad Decker a49a4a066c
expand transaction constants coverage (#9790)
* expand transaction constants coverage

* touchups

* dont import inside of e2e

* Update app/scripts/controllers/transactions/tx-state-manager.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Update test/unit/app/controllers/transactions/tx-controller-test.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2020-11-07 01:38:12 -06:00

41 lines
1.3 KiB
JavaScript

import assert from 'assert'
import migration22 from '../../../app/scripts/migrations/022'
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'
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)
})
})