mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 20:39:08 +01:00
4f3fc95d50
* Use @metamask/eslint-config@1.1.0 * Use eslint-plugin-mocha@6.2.2 * Mark root ESLint config as root * Update Mocha ESLint rules with shared ESLint config
49 lines
1.2 KiB
JavaScript
49 lines
1.2 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'
|
|
|
|
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('An error!')
|
|
},
|
|
cancelTransaction (_, cb) {
|
|
cb()
|
|
},
|
|
getState (cb) {
|
|
cb()
|
|
},
|
|
})
|
|
|
|
await store.dispatch(actions.cancelTx({ id: txId }))
|
|
const storeActions = store.getActions()
|
|
const completedTxAction = storeActions.find(({ type }) => type === actions.actionConstants.COMPLETED_TX)
|
|
const { id } = completedTxAction.value
|
|
assert.equal(id, txId)
|
|
})
|
|
})
|
|
})
|