Revert to updating amount on blur of input change; update gas on blur of amount input change; validate onchange.

feature/default_network_editable
Dan 7 years ago
parent adb71073c8
commit 347d1984cf
  1. 8
      ui/app/components/send_/send-content/send-amount-row/send-amount-row.component.js
  2. 8
      ui/app/components/send_/send-content/send-amount-row/tests/send-amount-row-component.test.js

@ -55,7 +55,6 @@ export default class SendAmountRow extends Component {
setMaxModeTo(false) setMaxModeTo(false)
updateSendAmount(amount) updateSendAmount(amount)
this.validateAmount(amount)
} }
updateGas (amount) { updateGas (amount) {
@ -87,8 +86,11 @@ export default class SendAmountRow extends Component {
<CurrencyDisplay <CurrencyDisplay
conversionRate={amountConversionRate} conversionRate={amountConversionRate}
convertedCurrency={convertedCurrency} convertedCurrency={convertedCurrency}
onBlur={newAmount => this.updateGas(newAmount)} onBlur={newAmount => {
onChange={newAmount => this.updateAmount(newAmount)} this.updateGas(newAmount)
this.updateAmount(newAmount)
}}
onChange={newAmount => this.validateAmount(newAmount)}
inError={inError} inError={inError}
primaryCurrency={primaryCurrency || 'ETH'} primaryCurrency={primaryCurrency || 'ETH'}
selectedToken={selectedToken} selectedToken={selectedToken}

@ -143,16 +143,20 @@ describe('SendAmountRow Component', function () {
assert.deepEqual(selectedToken, { address: 'mockTokenAddress' }) assert.deepEqual(selectedToken, { address: 'mockTokenAddress' })
assert.equal(value, 'mockAmount') assert.equal(value, 'mockAmount')
assert.equal(SendAmountRow.prototype.updateGas.callCount, 0) assert.equal(SendAmountRow.prototype.updateGas.callCount, 0)
assert.equal(SendAmountRow.prototype.updateAmount.callCount, 0)
onBlur('mockNewAmount') onBlur('mockNewAmount')
assert.equal(SendAmountRow.prototype.updateGas.callCount, 1) assert.equal(SendAmountRow.prototype.updateGas.callCount, 1)
assert.deepEqual( assert.deepEqual(
SendAmountRow.prototype.updateGas.getCall(0).args, SendAmountRow.prototype.updateGas.getCall(0).args,
['mockNewAmount'] ['mockNewAmount']
) )
assert.equal(SendAmountRow.prototype.updateAmount.callCount, 0) assert.equal(SendAmountRow.prototype.updateAmount.callCount, 1)
assert.deepEqual(
SendAmountRow.prototype.updateAmount.getCall(0).args,
['mockNewAmount']
)
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,

Loading…
Cancel
Save