mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
92971d3c87
* Update eslint-plugin-import version * Convert JS files to use ESM * Update ESLint rules to check imports * Fix test:unit:global command env * Cleanup mock-dev script
57 lines
1.4 KiB
JavaScript
57 lines
1.4 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: {
|
|
currentView: {
|
|
name: 'confTx',
|
|
},
|
|
},
|
|
metamask: {
|
|
unapprovedTxs: {
|
|
[txId]: {
|
|
id: txId,
|
|
status: 'unconfirmed',
|
|
time: 1457634084250,
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
const store = mockStore(initialState)
|
|
|
|
describe('cancelTx', function () {
|
|
before(function (done) {
|
|
actions._setBackgroundConnection({
|
|
approveTransaction (_, cb) {
|
|
cb('An error!')
|
|
},
|
|
cancelTransaction (_, cb) {
|
|
cb()
|
|
},
|
|
getState (cb) {
|
|
cb()
|
|
},
|
|
})
|
|
done()
|
|
})
|
|
|
|
it('creates COMPLETED_TX with the cancelled transaction ID', function (done) {
|
|
store.dispatch(actions.cancelTx({ id: txId }))
|
|
.then(() => {
|
|
const storeActions = store.getActions()
|
|
const completedTxAction = storeActions.find(({ type }) => type === actions.actionConstants.COMPLETED_TX)
|
|
assert.equal(completedTxAction.value, txId)
|
|
done()
|
|
})
|
|
})
|
|
})
|
|
})
|