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",
"integrity": "sha1-jZWCAsftuq6Dlwf7pvCf8ydgYhA=",
"requires": {
"ethereumjs-abi": "git+https://github.com/ethereumjs/ethereumjs-abi.git#00ba8463a7f7a67fcad737ff9c2ebd95643427f7",
"ethereumjs-util": "^5.1.1"
},
"dependencies": {
"ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#4ea2fdfed09e8f99117d9362d17c6b01b64a2bcf",
"from": "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",
"requires": {
"bn.js": "^4.10.0",
"ethereumjs-util": "^5.0.0"
@ -26586,6 +26587,15 @@
"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": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/redux-test-utils/-/redux-test-utils-0.2.2.tgz",
@ -30754,6 +30764,7 @@
"version": "3.1.5",
"resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz",
"integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==",
"dev": true,
"requires": {
"is-typedarray": "^1.0.0"
}
@ -31777,6 +31788,7 @@
"resolved": "https://registry.npmjs.org/web3/-/web3-0.20.3.tgz",
"integrity": "sha1-yqRDc9yIFayHZ73ba6cwc5ZMqos=",
"requires": {
"bignumber.js": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
"crypto-js": "^3.1.4",
"utf8": "^2.1.1",
"xhr2": "*",
@ -31785,7 +31797,7 @@
"dependencies": {
"bignumber.js": {
"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,
"requires": {
"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": {
"underscore": {
@ -32295,7 +32308,8 @@
},
"websocket": {
"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": {
"debug": "^2.2.0",
"nan": "^2.3.3",
@ -33651,7 +33665,8 @@
"yaeti": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/yaeti/-/yaeti-0.0.6.tgz",
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc="
"integrity": "sha1-8m9ITXJoTPQr7ft2lwqhYI+/lXc=",
"dev": true
},
"yallist": {
"version": "2.1.2",

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

@ -1,28 +1,17 @@
// 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'))
import configureMockStore from 'redux-mock-store'
import thunk from 'redux-thunk'
describe('tx confirmation screen', function () {
beforeEach(function () {
this.sinon = sinon.createSandbox()
})
afterEach(function () {
this.sinon.restore()
})
const actions = require(path.join(__dirname, '../../../ui/app/actions.js'))
var initialState, result
const middlewares = [thunk]
const mockStore = configureMockStore(middlewares)
describe('when there is only one tx', function () {
var firstTxId = 1457634084250832
beforeEach(function () {
initialState = {
describe('tx confirmation screen', function () {
const txId = 1457634084250832
const initialState = {
appState: {
currentView: {
name: 'confTx',
@ -30,16 +19,16 @@ describe('tx confirmation screen', function () {
},
metamask: {
unapprovedTxs: {
'1457634084250832': {
id: 1457634084250832,
[txId]: {
id: txId,
status: 'unconfirmed',
time: 1457634084250,
},
},
},
}
freeze(initialState)
})
const store = mockStore(initialState)
describe('cancelTx', function () {
before(function (done) {
@ -47,28 +36,19 @@ describe('tx confirmation screen', function () {
approveTransaction (txId, cb) { cb('An error!') },
cancelTransaction (txId, cb) { cb() },
clearSeedWordCache (cb) { cb() },
})
actions.cancelTx({value: firstTxId})((action) => {
result = reducers(initialState, action)
getState (cb) { cb() },
})
done()
})
it('should transition to the account detail view', function () {
assert.equal(result.appState.currentView.name, 'accountDetail')
})
it('should have no unconfirmed txs remaining', function () {
var count = getUnconfirmedTxCount(result)
assert.equal(count, 0)
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()
})
})
})
})
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)
})
it('should call history.push', () => {
wrapper.instance().onSubmit(MOCK_EVENT)
it('should call history.push', done => {
Promise.resolve(wrapper.instance().onSubmit(MOCK_EVENT))
.then(() => {
assert.equal(historySpies.push.callCount, 1)
assert.equal(historySpies.push.getCall(0).args[0], CONFIRM_TRANSACTION_ROUTE)
done()
})
})
})

Loading…
Cancel
Save