aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2016-04-30 06:53:29 +0800
committerDan Finlay <dan@danfinlay.com>2016-04-30 08:02:36 +0800
commit988165224b41c1eb3fe1b639b5801204936000e1 (patch)
tree2ee46ca24e9aa6ee399a45192ed0a46c59dd6a13 /test/unit
parent8421c97db21af0bc616fa6c0671f6f1a3b60b815 (diff)
downloadtangerine-wallet-browser-988165224b41c1eb3fe1b639b5801204936000e1.tar
tangerine-wallet-browser-988165224b41c1eb3fe1b639b5801204936000e1.tar.gz
tangerine-wallet-browser-988165224b41c1eb3fe1b639b5801204936000e1.tar.bz2
tangerine-wallet-browser-988165224b41c1eb3fe1b639b5801204936000e1.tar.lz
tangerine-wallet-browser-988165224b41c1eb3fe1b639b5801204936000e1.tar.xz
tangerine-wallet-browser-988165224b41c1eb3fe1b639b5801204936000e1.tar.zst
tangerine-wallet-browser-988165224b41c1eb3fe1b639b5801204936000e1.zip
Fix outdated transitions
Fixes #151 - Cancelling or completing a tx now goes back to account detail view. - Restoring a vault now does not select an unloaded account, shows account list. - Account list now never selects an item only uses the cells as buttons.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/actions/tx_test.js46
1 files changed, 23 insertions, 23 deletions
diff --git a/test/unit/actions/tx_test.js b/test/unit/actions/tx_test.js
index b15bee393..1eb759511 100644
--- a/test/unit/actions/tx_test.js
+++ b/test/unit/actions/tx_test.js
@@ -2,11 +2,21 @@ 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'))
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js'))
-describe('tx confirmation screen', function() {
+describe.only('tx confirmation screen', function() {
+
+ beforeEach(function() {
+ this.sinon = sinon.sandbox.create();
+ });
+
+ afterEach(function(){
+ this.sinon.restore();
+ });
+
var initialState, result
describe('when there is only one tx', function() {
@@ -42,14 +52,13 @@ describe('tx confirmation screen', function() {
clearSeedWordCache(cb) { cb() },
})
- actions.cancelTx({id: firstTxId})(function(action) {
- result = reducers(initialState, action)
- done()
- })
+ let action = actions.cancelTx({id: firstTxId})
+ result = reducers(initialState, action)
+ done()
})
- it('should transition to the accounts list', function() {
- assert.equal(result.appState.currentView.name, 'accounts')
+ it('should transition to the account detail view', function() {
+ assert.equal(result.appState.currentView.name, 'accountDetail')
})
it('should have no unconfirmed txs remaining', function() {
@@ -67,7 +76,7 @@ describe('tx confirmation screen', function() {
alert = () => {/* noop */}
actions._setAccountManager({
- approveTransaction(txId, cb) { cb('An error!') },
+ approveTransaction(txId, cb) { cb({message: 'An error!'}) },
})
actions.sendTx({id: firstTxId})(function(action) {
@@ -86,23 +95,15 @@ describe('tx confirmation screen', function() {
})
describe('when there is success', function() {
- before(function(done) {
+ it('should complete tx and go home', function() {
actions._setAccountManager({
approveTransaction(txId, cb) { cb() },
})
- actions.sendTx({id: firstTxId})(function(action) {
- result = reducers(initialState, action)
- done()
- })
- })
-
- it('should navigate away from the tx page', function() {
- assert.equal(result.appState.currentView.name, 'accounts')
- })
+ var dispatchExpect = sinon.mock()
+ dispatchExpect.twice()
- it('should clear the tx from the unconfirmed transactions', function() {
- assert(!(firstTxId in result.metamask.unconfTxs), 'tx is cleared')
+ actions.sendTx({id: firstTxId})(dispatchExpect)
})
})
})
@@ -134,15 +135,14 @@ describe('tx confirmation screen', function() {
}
freeze(initialState)
-
actions._setAccountManager({
approveTransaction(txId, cb) { cb() },
})
- actions.sendTx({id: firstTxId})(function(action) {
+ let action = actions.sendTx({id: firstTxId})(function(action) {
result = reducers(initialState, action)
- done()
})
+ done()
})
it('should stay on the confTx view', function() {