1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Fix unit tests

This commit is contained in:
Alexander Tseung 2018-06-15 15:31:16 -07:00
parent 5685c4bafe
commit adb71073c8

View File

@ -12,10 +12,12 @@ const propsMethodSpies = {
setMaxModeTo: sinon.spy(), setMaxModeTo: sinon.spy(),
updateSendAmount: sinon.spy(), updateSendAmount: sinon.spy(),
updateSendAmountError: sinon.spy(), updateSendAmountError: sinon.spy(),
updateGas: sinon.spy(),
} }
sinon.spy(SendAmountRow.prototype, 'updateAmount') sinon.spy(SendAmountRow.prototype, 'updateAmount')
sinon.spy(SendAmountRow.prototype, 'validateAmount') sinon.spy(SendAmountRow.prototype, 'validateAmount')
sinon.spy(SendAmountRow.prototype, 'updateGas')
describe('SendAmountRow Component', function () { describe('SendAmountRow Component', function () {
let wrapper let wrapper
@ -36,6 +38,7 @@ describe('SendAmountRow Component', function () {
tokenBalance={'mockTokenBalance'} tokenBalance={'mockTokenBalance'}
updateSendAmount={propsMethodSpies.updateSendAmount} updateSendAmount={propsMethodSpies.updateSendAmount}
updateSendAmountError={propsMethodSpies.updateSendAmountError} updateSendAmountError={propsMethodSpies.updateSendAmountError}
updateGas={propsMethodSpies.updateGas}
/>, { context: { t: str => str + '_t' } }) />, { context: { t: str => str + '_t' } })
instance = wrapper.instance() instance = wrapper.instance()
}) })
@ -139,15 +142,17 @@ describe('SendAmountRow Component', function () {
assert.equal(primaryCurrency, 'mockPrimaryCurrency') assert.equal(primaryCurrency, 'mockPrimaryCurrency')
assert.deepEqual(selectedToken, { address: 'mockTokenAddress' }) assert.deepEqual(selectedToken, { address: 'mockTokenAddress' })
assert.equal(value, 'mockAmount') assert.equal(value, 'mockAmount')
assert.equal(SendAmountRow.prototype.updateAmount.callCount, 0) assert.equal(SendAmountRow.prototype.updateGas.callCount, 0)
onBlur('mockNewAmount') onBlur('mockNewAmount')
assert.equal(SendAmountRow.prototype.updateAmount.callCount, 1) assert.equal(SendAmountRow.prototype.updateGas.callCount, 1)
assert.deepEqual( assert.deepEqual(
SendAmountRow.prototype.updateAmount.getCall(0).args, SendAmountRow.prototype.updateGas.getCall(0).args,
['mockNewAmount'] ['mockNewAmount']
) )
assert.equal(SendAmountRow.prototype.updateAmount.callCount, 0)
assert.equal(SendAmountRow.prototype.validateAmount.callCount, 0) assert.equal(SendAmountRow.prototype.validateAmount.callCount, 0)
onChange('mockNewAmount') onChange('mockNewAmount')
assert.equal(SendAmountRow.prototype.updateAmount.callCount, 1)
assert.equal(SendAmountRow.prototype.validateAmount.callCount, 1) assert.equal(SendAmountRow.prototype.validateAmount.callCount, 1)
assert.deepEqual( assert.deepEqual(
SendAmountRow.prototype.validateAmount.getCall(0).args, SendAmountRow.prototype.validateAmount.getCall(0).args,