From 44448465ed96bcf7a41fdfb539a5757977734be6 Mon Sep 17 00:00:00 2001 From: Thomas Huang Date: Thu, 19 Nov 2020 07:35:42 -0800 Subject: [PATCH] Validate sendToken address when component updates (#9907) * Validate sendToken address when component updates On a reproduction of trying to get the error message it seems that if an token address is provided in the address form with ETH selected then changing to a token address, the error message won't show. This will validate the sendtoken address on prop change to properly update the warning message. * Update test to include second doesAmountErrorRequireUpdate call when state is updated and component is updated --- ui/app/pages/send/send.component.js | 1 + ui/app/pages/send/tests/send-component.test.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/app/pages/send/send.component.js b/ui/app/pages/send/send.component.js index b5865c4ba..727c213af 100644 --- a/ui/app/pages/send/send.component.js +++ b/ui/app/pages/send/send.component.js @@ -154,6 +154,7 @@ export default class SendTransactionScreen extends Component { if (sendTokenAddress && prevTokenAddress !== sendTokenAddress) { this.updateSendToken() + this.validate(sendTokenAddress) updateGas = true } diff --git a/ui/app/pages/send/tests/send-component.test.js b/ui/app/pages/send/tests/send-component.test.js index 42a3dc504..4c5cd04e3 100644 --- a/ui/app/pages/send/tests/send-component.test.js +++ b/ui/app/pages/send/tests/send-component.test.js @@ -138,7 +138,7 @@ describe('Send Component', function () { balance: '', }, }) - assert(utilsMethodStubs.doesAmountErrorRequireUpdate.calledOnce) + assert(utilsMethodStubs.doesAmountErrorRequireUpdate.calledTwice) assert.deepEqual( utilsMethodStubs.doesAmountErrorRequireUpdate.getCall(0).args[0], {