A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ciphermask/test/unit/actions/tx_test.js

49 lines
1.3 KiB

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)
})
})
})