Fix existing unit tests

feature/default_network_editable
Alexander Tseung 6 years ago
parent a2d9c43fba
commit 7d691c7398
  1. 27
      package-lock.json
  2. 1
      package.json
  3. 60
      test/unit/actions/tx_test.js
  4. 7
      ui/app/components/send_/send-footer/tests/send-footer-component.test.js

27
package-lock.json generated

@ -8650,12 +8650,13 @@
"resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz", "resolved": "https://registry.npmjs.org/eth-sig-util/-/eth-sig-util-1.4.2.tgz",
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=", "integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
"requires": { "requires": {
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"ethereumjs-util": "^5.1.1" "ethereumjs-util": "^5.1.1"
}, },
"dependencies": { "dependencies": {
"ethereumjs-abi": { "ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#4ea2fdfed09e8f99117d9362d17c6b01b64a2bcf", "version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git#4ea2fdfed09e8f99117d9362d17c6b01b64a2bcf", "from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"requires": { "requires": {
"bn.js": "^4.10.0", "bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0" "ethereumjs-util": "^5.0.0"
@ -26586,6 +26587,15 @@
"deep-diff": "^0.3.5" "deep-diff": "^0.3.5"
} }
}, },
"redux-mock-store": {
"version": "1.5.3",
"resolved": "https://registry.npmjs.org/redux-mock-store/-/redux-mock-store-1.5.3.tgz",
"integrity": "sha512-ryhkkb/4D4CUGpAV2ln1GOY/uh51aczjcRz9k2L2bPx/Xja3c5pSGJJPyR25GNVRXtKIExScdAgFdiXp68GmJA==",
"dev": true,
"requires": {
"lodash.isplainobject": "^4.0.6"
}
},
"redux-test-utils": { "redux-test-utils": {
"version": "0.2.2", "version": "0.2.2",
"resolved": "https://registry.npmjs.org/redux-test-utils/-/redux-test-utils-0.2.2.tgz", "resolved": "https://registry.npmjs.org/redux-test-utils/-/redux-test-utils-0.2.2.tgz",
@ -30754,6 +30764,7 @@
"version": "3.1.5", "version": "3.1.5",
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
"dev": true,
"requires": { "requires": {
"is-typedarray": "^1.0.0" "is-typedarray": "^1.0.0"
} }
@ -31777,6 +31788,7 @@
"resolved": "https://registry.npmjs.org/web3/-/web3-0.20.3.tgz", "resolved": "https://registry.npmjs.org/web3/-/web3-0.20.3.tgz",
"integrity": "sha1-yqRDc9yIFayHZ73ba6cwc5ZMqos=", "integrity": "sha1-yqRDc9yIFayHZ73ba6cwc5ZMqos=",
"requires": { "requires": {
"bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
"crypto-js": "^3.1.4", "crypto-js": "^3.1.4",
"utf8": "^2.1.1", "utf8": "^2.1.1",
"xhr2": "*", "xhr2": "*",
@ -31785,7 +31797,7 @@
"dependencies": { "dependencies": {
"bignumber.js": { "bignumber.js": {
"version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934", "version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
"from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934" "from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git"
} }
} }
}, },
@ -32284,7 +32296,8 @@
"dev": true, "dev": true,
"requires": { "requires": {
"underscore": "1.8.3", "underscore": "1.8.3",
"web3-core-helpers": "1.0.0-beta.34" "web3-core-helpers": "1.0.0-beta.34",
"websocket": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2"
}, },
"dependencies": { "dependencies": {
"underscore": { "underscore": {
@ -32295,7 +32308,8 @@
}, },
"websocket": { "websocket": {
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2", "version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"from": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2", "from": "git://github.com/frozeman/WebSocket-Node.git#browserifyCompatible",
"dev": true,
"requires": { "requires": {
"debug": "^2.2.0", "debug": "^2.2.0",
"nan": "^2.3.3", "nan": "^2.3.3",
@ -33651,7 +33665,8 @@
"yaeti": { "yaeti": {
"version": "0.0.6", "version": "0.0.6",
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz", "resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=" "integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=",
"dev": true
}, },
"yallist": { "yallist": {
"version": "2.1.2", "version": "2.1.2",

@ -287,6 +287,7 @@
"react-addons-test-utils": "^15.5.1", "react-addons-test-utils": "^15.5.1",
"react-test-renderer": "^15.6.2", "react-test-renderer": "^15.6.2",
"react-testutils-additions": "^15.2.0", "react-testutils-additions": "^15.2.0",
"redux-mock-store": "^1.5.3",
"redux-test-utils": "^0.2.2", "redux-test-utils": "^0.2.2",
"resolve-url-loader": "^2.3.0", "resolve-url-loader": "^2.3.0",
"rimraf": "^2.6.2", "rimraf": "^2.6.2",

@ -1,28 +1,17 @@
// var jsdom = require('mocha-jsdom')
var assert = require('assert') var assert = require('assert')
var freeze = require('deep-freeze-strict')
var path = require('path') var path = require('path')
var sinon = require('sinon')
var actions = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'actions.js')) import configureMockStore from 'redux-mock-store'
var reducers = require(path.join(__dirname, '..', '..', '..', 'ui', 'app', 'reducers.js')) import thunk from 'redux-thunk'
describe('tx confirmation screen', function () { const actions = require(path.join(__dirname, '../../../ui/app/actions.js'))
beforeEach(function () {
this.sinon = sinon.createSandbox()
})
afterEach(function () {
this.sinon.restore()
})
var initialState, result const middlewares = [thunk]
const mockStore = configureMockStore(middlewares)
describe('when there is only one tx', function () { describe('tx confirmation screen', function () {
var firstTxId = 1457634084250832 const txId = 1457634084250832
const initialState = {
beforeEach(function () {
initialState = {
appState: { appState: {
currentView: { currentView: {
name: 'confTx', name: 'confTx',
@ -30,16 +19,16 @@ describe('tx confirmation screen', function () {
}, },
metamask: { metamask: {
unapprovedTxs: { unapprovedTxs: {
'1457634084250832': { [txId]: {
id: 1457634084250832, id: txId,
status: 'unconfirmed', status: 'unconfirmed',
time: 1457634084250, time: 1457634084250,
}, },
}, },
}, },
} }
freeze(initialState)
}) const store = mockStore(initialState)
describe('cancelTx', function () { describe('cancelTx', function () {
before(function (done) { before(function (done) {
@ -47,28 +36,19 @@ describe('tx confirmation screen', function () {
approveTransaction (txId, cb) { cb('An error!') }, approveTransaction (txId, cb) { cb('An error!') },
cancelTransaction (txId, cb) { cb() }, cancelTransaction (txId, cb) { cb() },
clearSeedWordCache (cb) { cb() }, clearSeedWordCache (cb) { cb() },
}) getState (cb) { cb() },
actions.cancelTx({value: firstTxId})((action) => {
result = reducers(initialState, action)
}) })
done() done()
}) })
it('should transition to the account detail view', function () { it('creates COMPLETED_TX with the cancelled transaction ID', function (done) {
assert.equal(result.appState.currentView.name, 'accountDetail') store.dispatch(actions.cancelTx({ id: txId }))
}) .then(() => {
const storeActions = store.getActions()
it('should have no unconfirmed txs remaining', function () { const completedTxAction = storeActions.find(({ type }) => type === actions.COMPLETED_TX)
var count = getUnconfirmedTxCount(result) assert.equal(completedTxAction.value, txId)
assert.equal(count, 0) done()
}) })
}) })
}) })
}) })
function getUnconfirmedTxCount (state) {
var txs = state.metamask.unapprovedTxs
var count = Object.keys(txs).length
return count
}

@ -166,10 +166,13 @@ describe('SendFooter Component', function () {
assert.equal(propsMethodSpies.update.callCount, 0) assert.equal(propsMethodSpies.update.callCount, 0)
}) })
it('should call history.push', () => { it('should call history.push', done => {
wrapper.instance().onSubmit(MOCK_EVENT) Promise.resolve(wrapper.instance().onSubmit(MOCK_EVENT))
.then(() => {
assert.equal(historySpies.push.callCount, 1) assert.equal(historySpies.push.callCount, 1)
assert.equal(historySpies.push.getCall(0).args[0], CONFIRM_TRANSACTION_ROUTE) assert.equal(historySpies.push.getCall(0).args[0], CONFIRM_TRANSACTION_ROUTE)
done()
})
}) })
}) })

Loading…
Cancel
Save