aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components
diff options
context:
space:
mode:
Diffstat (limited to 'ui/app/components')
-rw-r--r--ui/app/components/send_/send.component.js37
-rw-r--r--ui/app/components/send_/send.utils.js4
-rw-r--r--ui/app/components/send_/tests/send-component.test.js12
3 files changed, 30 insertions, 23 deletions
diff --git a/ui/app/components/send_/send.component.js b/ui/app/components/send_/send.component.js
index 8b0a41f9e..21e1de09b 100644
--- a/ui/app/components/send_/send.component.js
+++ b/ui/app/components/send_/send.component.js
@@ -83,30 +83,31 @@ export default class SendTransactionScreen extends PersistentForm {
const uninitialized = [prevBalance, prevGasTotal].every(n => n === null)
- if (!uninitialized) {
- const amountErrorRequiresUpdate = doesAmountErrorRequireUpdate({
+ const amountErrorRequiresUpdate = doesAmountErrorRequireUpdate({
+ balance,
+ gasTotal,
+ prevBalance,
+ prevGasTotal,
+ prevTokenBalance,
+ selectedToken,
+ tokenBalance,
+ })
+
+ if (amountErrorRequiresUpdate) {
+ const amountErrorObject = getAmountErrorObject({
+ amount,
+ amountConversionRate,
balance,
+ conversionRate,
gasTotal,
- prevBalance,
- prevGasTotal,
- prevTokenBalance,
+ primaryCurrency,
selectedToken,
tokenBalance,
})
+ updateSendErrors(amountErrorObject)
+ }
- if (amountErrorRequiresUpdate) {
- const amountErrorObject = getAmountErrorObject({
- amount,
- amountConversionRate,
- balance,
- conversionRate,
- gasTotal,
- primaryCurrency,
- selectedToken,
- tokenBalance,
- })
- updateSendErrors(amountErrorObject)
- }
+ if (!uninitialized) {
if (network !== prevNetwork && network !== 'loading') {
updateSendTokenBalance({
diff --git a/ui/app/components/send_/send.utils.js b/ui/app/components/send_/send.utils.js
index 71a8a35c4..a35a55bf8 100644
--- a/ui/app/components/send_/send.utils.js
+++ b/ui/app/components/send_/send.utils.js
@@ -36,7 +36,7 @@ function calcGasTotal (gasLimit, gasPrice) {
function isBalanceSufficient ({
amount = '0x0',
- amountConversionRate,
+ amountConversionRate = 0,
balance,
conversionRate,
gasTotal = '0x0',
@@ -58,7 +58,7 @@ function isBalanceSufficient ({
{
value: totalAmount,
fromNumericBase: 'hex',
- conversionRate: amountConversionRate || conversionRate,
+ conversionRate: Number(amountConversionRate) || conversionRate,
fromCurrency: primaryCurrency,
},
)
diff --git a/ui/app/components/send_/tests/send-component.test.js b/ui/app/components/send_/tests/send-component.test.js
index 8aeab36b4..4aa1978e4 100644
--- a/ui/app/components/send_/tests/send-component.test.js
+++ b/ui/app/components/send_/tests/send-component.test.js
@@ -25,7 +25,7 @@ const SendTransactionScreen = proxyquire('../send.component.js', {
sinon.spy(SendTransactionScreen.prototype, 'componentDidMount')
sinon.spy(SendTransactionScreen.prototype, 'updateGas')
-describe('Send Component', function () {
+describe.only('Send Component', function () {
let wrapper
beforeEach(() => {
@@ -68,14 +68,17 @@ describe('Send Component', function () {
describe('componentWillMount', () => {
it('should call this.updateGas', () => {
- assert(SendTransactionScreen.prototype.updateGas.calledOnce)
+ SendTransactionScreen.prototype.updateGas.resetHistory()
+ propsMethodSpies.updateSendErrors.resetHistory()
+ assert.equal(SendTransactionScreen.prototype.updateGas.callCount, 0)
wrapper.instance().componentWillMount()
- assert(SendTransactionScreen.prototype.updateGas.calledTwice)
+ assert.equal(SendTransactionScreen.prototype.updateGas.callCount, 1)
})
})
describe('componentDidUpdate', () => {
it('should call doesAmountErrorRequireUpdate with the expected params', () => {
+ utilsMethodStubs.getAmountErrorObject.resetHistory()
wrapper.instance().componentDidUpdate({
from: {
balance: '',
@@ -97,6 +100,7 @@ describe('Send Component', function () {
})
it('should not call getAmountErrorObject if doesAmountErrorRequireUpdate returns false', () => {
+ utilsMethodStubs.getAmountErrorObject.resetHistory()
wrapper.instance().componentDidUpdate({
from: {
balance: 'mockBalance',
@@ -106,6 +110,7 @@ describe('Send Component', function () {
})
it('should call getAmountErrorObject if doesAmountErrorRequireUpdate returns true', () => {
+ utilsMethodStubs.getAmountErrorObject.resetHistory()
wrapper.instance().componentDidUpdate({
from: {
balance: 'balanceChanged',
@@ -128,6 +133,7 @@ describe('Send Component', function () {
})
it('should call updateSendErrors with the expected params', () => {
+ propsMethodSpies.updateSendErrors.resetHistory()
wrapper.instance().componentDidUpdate({
from: {
balance: 'balanceChanged',