1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-25 21:00:23 +02:00
metamask-extension/test/unit/actions/tx_test.js
Mark Stacey 7d0a7ab301
Update @metamask/eslint-config to v4.1.0 (#9663)
`@metamask/eslint-config` has been updated to v4.1.0. This update
requires that we update `eslint` to v7 as well, which in turn requires
updating most `eslint`-related packages.

Most notably, `babel-eslint` was replaced with `@babel/eslint-parser`,
and `babel-eslint-plugin` was replaced by `@babel/eslint-plugin`. This
required renaming all the `babel/*` rules to `@babel/*`.

Most new or updated rules that resulted in lint errors have been
temporarily disabled. They will be fixed and re-enabled in subsequent
PRs.
2020-10-21 14:01:03 -02:30

50 lines
1.3 KiB
JavaScript

import assert from 'assert'
import configureMockStore from 'redux-mock-store'
import thunk from 'redux-thunk'
import * as actions from '../../../ui/app/store/actions'
import * as actionConstants from '../../../ui/app/store/actionConstants'
const middlewares = [thunk]
const mockStore = configureMockStore(middlewares)
describe('tx confirmation screen', function () {
const txId = 1457634084250832
const initialState = {
appState: {
},
metamask: {
unapprovedTxs: {
[txId]: {
id: txId,
status: 'unconfirmed',
time: 1457634084250,
},
},
},
}
const store = mockStore(initialState)
describe('cancelTx', function () {
it('creates COMPLETED_TX with the cancelled transaction ID', async function () {
actions._setBackgroundConnection({
approveTransaction (_, cb) {
cb(new Error('An error!'))
},
cancelTransaction (_, cb) {
cb()
},
getState (cb) {
cb(null, {})
},
})
await store.dispatch(actions.cancelTx({ id: txId }))
const storeActions = store.getActions()
const completedTxAction = storeActions.find(({ type }) => type === actionConstants.COMPLETED_TX)
const { id } = completedTxAction.value
assert.equal(id, txId)
})
})
})