1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00
metamask-extension/test/unit/actions/tx_test.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

import assert from 'assert'
2018-07-08 03:53:00 +02:00
import configureMockStore from 'redux-mock-store'
import thunk from 'redux-thunk'
import * as actions from '../../../ui/app/store/actions'
2018-07-08 03:53:00 +02:00
const middlewares = [thunk]
const mockStore = configureMockStore(middlewares)
2018-07-08 03:53:00 +02:00
describe('tx confirmation screen', function () {
const txId = 1457634084250832
const initialState = {
appState: {
},
metamask: {
unapprovedTxs: {
[txId]: {
id: txId,
status: 'unconfirmed',
time: 1457634084250,
2017-05-04 23:35:10 +02:00
},
2018-07-08 03:53:00 +02:00
},
},
}
const store = mockStore(initialState)
describe('cancelTx', function () {
it('creates COMPLETED_TX with the cancelled transaction ID', async function () {
2018-07-08 03:53:00 +02:00
actions._setBackgroundConnection({
approveTransaction (_, cb) {
cb('An error!')
},
cancelTransaction (_, cb) {
cb()
},
getState (cb) {
cb()
},
2018-07-08 03:53:00 +02:00
})
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)
})
})
2017-05-04 23:35:10 +02:00
})