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

75 lines
1.9 KiB

8 years ago
// var jsdom = require('mocha-jsdom')
var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path')
var sinon = require('sinon')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actions.js'))
8 years ago
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
8 years ago
describe('tx confirmation screen', function () {
beforeEach(function () {
this.sinon = sinon.createSandbox()
8 years ago
})
8 years ago
afterEach(function () {
this.sinon.restore()
})
var initialState, result
8 years ago
describe('when there is only one tx', function () {
var firstTxId = 1457634084250832
8 years ago
beforeEach(function () {
initialState = {
appState: {
currentView: {
name: 'confTx',
},
},
metamask: {
unapprovedTxs: {
'1457634084250832': {
id: 1457634084250832,
8 years ago
status: 'unconfirmed',
time: 1457634084250,
8 years ago
},
},
8 years ago
},
}
freeze(initialState)
})
8 years ago
describe('cancelTx', function () {
before(function (done) {
8 years ago
actions._setBackgroundConnection({
8 years ago
approveTransaction (txId, cb) { cb('An error!') },
7 years ago
cancelTransaction (txId, cb) { cb() },
8 years ago
clearSeedWordCache (cb) { cb() },
})
actions.cancelTx({value: firstTxId})((action) => {
result = reducers(initialState, action)
7 years ago
})
done()
})
8 years ago
it('should transition to the account detail view', function () {
assert.equal(result.appState.currentView.name, 'accountDetail')
})
8 years ago
it('should have no unconfirmed txs remaining', function () {
var count = getUnconfirmedTxCount(result)
assert.equal(count, 0)
})
})
})
8 years ago
})
8 years ago
function getUnconfirmedTxCount (state) {
var txs = state.metamask.unapprovedTxs
var count = Object.keys(txs).length
return count
}