diff options
author | kumavis <kumavis@users.noreply.github.com> | 2017-08-04 12:01:13 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-04 12:01:13 +0800 |
commit | c4cb371ce8ddad10d575b4ddb6cb85fe4689ca59 (patch) | |
tree | 7dfa4391e05630d04b1903b69f9ca2fff43715c7 | |
parent | fea03ad82ef7bdf2b903922ec8b4a50453974b71 (diff) | |
parent | d526f68c8e7d613ad79ec9383d6709651e5af77e (diff) | |
download | tangerine-wallet-browser-c4cb371ce8ddad10d575b4ddb6cb85fe4689ca59.tar tangerine-wallet-browser-c4cb371ce8ddad10d575b4ddb6cb85fe4689ca59.tar.gz tangerine-wallet-browser-c4cb371ce8ddad10d575b4ddb6cb85fe4689ca59.tar.bz2 tangerine-wallet-browser-c4cb371ce8ddad10d575b4ddb6cb85fe4689ca59.tar.lz tangerine-wallet-browser-c4cb371ce8ddad10d575b4ddb6cb85fe4689ca59.tar.xz tangerine-wallet-browser-c4cb371ce8ddad10d575b4ddb6cb85fe4689ca59.tar.zst tangerine-wallet-browser-c4cb371ce8ddad10d575b4ddb6cb85fe4689ca59.zip |
Merge pull request #1857 from MetaMask/hotFixCancleTx
fix cancelTransaction not receiving a callback
-rw-r--r-- | app/scripts/lib/nodeify.js | 3 | ||||
-rw-r--r-- | test/unit/actions/tx_test.js | 10 | ||||
-rw-r--r-- | test/unit/nodeify-test.js | 11 | ||||
-rw-r--r-- | ui/app/actions.js | 9 |
4 files changed, 25 insertions, 8 deletions
diff --git a/app/scripts/lib/nodeify.js b/app/scripts/lib/nodeify.js index 299bfe624..832d6c6d3 100644 --- a/app/scripts/lib/nodeify.js +++ b/app/scripts/lib/nodeify.js @@ -1,9 +1,10 @@ const promiseToCallback = require('promise-to-callback') -module.exports = function(fn, context) { +module.exports = function nodeify (fn, context) { return function(){ const args = [].slice.call(arguments) const callback = args.pop() + if (typeof callback !== 'function') throw new Error('callback is not a function') promiseToCallback(fn.apply(context, args))(callback) } } diff --git a/test/unit/actions/tx_test.js b/test/unit/actions/tx_test.js index 0ea1bfdc7..67c72e9a5 100644 --- a/test/unit/actions/tx_test.js +++ b/test/unit/actions/tx_test.js @@ -45,13 +45,15 @@ describe('tx confirmation screen', function () { before(function (done) { actions._setBackgroundConnection({ approveTransaction (txId, cb) { cb('An error!') }, - cancelTransaction (txId) { /* noop */ }, + cancelTransaction (txId, cb) { cb() }, clearSeedWordCache (cb) { cb() }, }) - const action = actions.cancelTx({value: firstTxId}) - result = reducers(initialState, action) - done() + actions.cancelTx({value: firstTxId})((action) => { + result = reducers(initialState, action) + done() + }) + }) it('should transition to the account detail view', function () { diff --git a/test/unit/nodeify-test.js b/test/unit/nodeify-test.js index 06241334d..537dae605 100644 --- a/test/unit/nodeify-test.js +++ b/test/unit/nodeify-test.js @@ -17,4 +17,15 @@ describe('nodeify', function () { done() }) }) + + it('should throw if the last argument is not a function', function (done) { + const nodified = nodeify(obj.promiseFunc, obj) + try { + nodified('baz') + done(new Error('should have thrown if the last argument is not a function')) + } catch (err) { + assert.equal(err.message, 'callback is not a function') + done() + } + }) }) diff --git a/ui/app/actions.js b/ui/app/actions.js index d99291e46..8ff8bbbdd 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -462,9 +462,12 @@ function cancelPersonalMsg (msgData) { } function cancelTx (txData) { - log.debug(`background.cancelTransaction`) - background.cancelTransaction(txData.id) - return actions.completedTx(txData.id) + return (dispatch) => { + log.debug(`background.cancelTransaction`) + background.cancelTransaction(txData.id, () => { + dispatch(actions.completedTx(txData.id)) + }) + } } // |