mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Fix existing unit tests
This commit is contained in:
parent
a2d9c43fba
commit
7d691c7398
27
package-lock.json
generated
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,74 +1,54 @@
|
|||||||
// 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'
|
||||||
|
|
||||||
|
const actions = require(path.join(__dirname, '../../../ui/app/actions.js'))
|
||||||
|
|
||||||
|
const middlewares = [thunk]
|
||||||
|
const mockStore = configureMockStore(middlewares)
|
||||||
|
|
||||||
describe('tx confirmation screen', function () {
|
describe('tx confirmation screen', function () {
|
||||||
beforeEach(function () {
|
const txId = 1457634084250832
|
||||||
this.sinon = sinon.createSandbox()
|
const initialState = {
|
||||||
})
|
appState: {
|
||||||
|
currentView: {
|
||||||
afterEach(function () {
|
name: 'confTx',
|
||||||
this.sinon.restore()
|
},
|
||||||
})
|
},
|
||||||
|
metamask: {
|
||||||
var initialState, result
|
unapprovedTxs: {
|
||||||
|
[txId]: {
|
||||||
describe('when there is only one tx', function () {
|
id: txId,
|
||||||
var firstTxId = 1457634084250832
|
status: 'unconfirmed',
|
||||||
|
time: 1457634084250,
|
||||||
beforeEach(function () {
|
|
||||||
initialState = {
|
|
||||||
appState: {
|
|
||||||
currentView: {
|
|
||||||
name: 'confTx',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
metamask: {
|
},
|
||||||
unapprovedTxs: {
|
},
|
||||||
'1457634084250832': {
|
}
|
||||||
id: 1457634084250832,
|
|
||||||
status: 'unconfirmed',
|
const store = mockStore(initialState)
|
||||||
time: 1457634084250,
|
|
||||||
},
|
describe('cancelTx', function () {
|
||||||
},
|
before(function (done) {
|
||||||
},
|
actions._setBackgroundConnection({
|
||||||
}
|
approveTransaction (txId, cb) { cb('An error!') },
|
||||||
freeze(initialState)
|
cancelTransaction (txId, cb) { cb() },
|
||||||
|
clearSeedWordCache (cb) { cb() },
|
||||||
|
getState (cb) { cb() },
|
||||||
|
})
|
||||||
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('cancelTx', function () {
|
it('creates COMPLETED_TX with the cancelled transaction ID', function (done) {
|
||||||
before(function (done) {
|
store.dispatch(actions.cancelTx({ id: txId }))
|
||||||
actions._setBackgroundConnection({
|
.then(() => {
|
||||||
approveTransaction (txId, cb) { cb('An error!') },
|
const storeActions = store.getActions()
|
||||||
cancelTransaction (txId, cb) { cb() },
|
const completedTxAction = storeActions.find(({ type }) => type === actions.COMPLETED_TX)
|
||||||
clearSeedWordCache (cb) { cb() },
|
assert.equal(completedTxAction.value, txId)
|
||||||
|
done()
|
||||||
})
|
})
|
||||||
|
|
||||||
actions.cancelTx({value: firstTxId})((action) => {
|
|
||||||
result = reducers(initialState, action)
|
|
||||||
})
|
|
||||||
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)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
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))
|
||||||
assert.equal(historySpies.push.callCount, 1)
|
.then(() => {
|
||||||
assert.equal(historySpies.push.getCall(0).args[0], CONFIRM_TRANSACTION_ROUTE)
|
assert.equal(historySpies.push.callCount, 1)
|
||||||
|
assert.equal(historySpies.push.getCall(0).args[0], CONFIRM_TRANSACTION_ROUTE)
|
||||||
|
done()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user