2016-04-14 00:28:44 +02:00
|
|
|
var assert = require('assert')
|
|
|
|
var path = require('path')
|
|
|
|
|
2018-07-08 03:53:00 +02:00
|
|
|
import configureMockStore from 'redux-mock-store'
|
|
|
|
import thunk from 'redux-thunk'
|
2016-04-14 00:28:44 +02:00
|
|
|
|
2018-07-08 03:53:00 +02:00
|
|
|
const actions = require(path.join(__dirname, '../../../ui/app/actions.js'))
|
2016-04-30 00:53:29 +02:00
|
|
|
|
2018-07-08 03:53:00 +02:00
|
|
|
const middlewares = [thunk]
|
|
|
|
const mockStore = configureMockStore(middlewares)
|
2016-04-14 00:28:44 +02:00
|
|
|
|
2018-07-08 03:53:00 +02:00
|
|
|
describe('tx confirmation screen', function () {
|
|
|
|
const txId = 1457634084250832
|
|
|
|
const initialState = {
|
|
|
|
appState: {
|
|
|
|
currentView: {
|
|
|
|
name: 'confTx',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
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 () {
|
|
|
|
before(function (done) {
|
|
|
|
actions._setBackgroundConnection({
|
|
|
|
approveTransaction (txId, cb) { cb('An error!') },
|
|
|
|
cancelTransaction (txId, cb) { cb() },
|
|
|
|
clearSeedWordCache (cb) { cb() },
|
|
|
|
getState (cb) { cb() },
|
|
|
|
})
|
|
|
|
done()
|
2016-04-14 00:28:44 +02:00
|
|
|
})
|
|
|
|
|
2018-07-08 03:53:00 +02:00
|
|
|
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.COMPLETED_TX)
|
|
|
|
assert.equal(completedTxAction.value, txId)
|
|
|
|
done()
|
2016-04-14 00:28:44 +02:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
2017-05-04 23:35:10 +02:00
|
|
|
})
|