From ce80c0e8be84def35a07a12f42a8c467bf29500f Mon Sep 17 00:00:00 2001 From: Filip Sekulic Date: Wed, 1 Mar 2023 17:05:11 +0100 Subject: [PATCH] Added tests --- .../token-allowance/token-allowance.test.js | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/ui/pages/token-allowance/token-allowance.test.js b/ui/pages/token-allowance/token-allowance.test.js index 313bbe3e09d1..66d88c21faab 100644 --- a/ui/pages/token-allowance/token-allowance.test.js +++ b/ui/pages/token-allowance/token-allowance.test.js @@ -2,6 +2,7 @@ import React from 'react'; import configureMockStore from 'redux-mock-store'; import { fireEvent } from '@testing-library/react'; import { renderWithProvider } from '../../../test/lib/render-helpers'; +import { HardwareKeyringTypes } from '../../../shared/constants/hardware-wallets'; import TokenAllowance from './token-allowance'; const testTokenAddress = '0xC011a73ee8576Fb46F5E1c5751cA3B9Fe0af2a6F'; @@ -11,17 +12,17 @@ const state = { }, metamask: { accounts: { - '0xAddress': { - address: '0xAddress', - balance: '0x1F4', + '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': { + address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', + balance: '0x0', }, }, gasEstimateType: 'none', - selectedAddress: '0xAddress', + selectedAddress: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', identities: { - '0xAddress': { + '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': { + address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', name: 'Account 1', - address: '0xAddress', }, }, frequentRpcListDetail: [], @@ -65,6 +66,13 @@ const state = { }, ], unapprovedTxs: {}, + keyringTypes: [HardwareKeyringTypes.ledger], + keyrings: [ + { + type: HardwareKeyringTypes.ledger, + accounts: ['0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc'], + }, + ], }, history: { mostRecentOverviewPage: '/', @@ -245,4 +253,28 @@ describe('TokenAllowancePage', () => { fireEvent.click(gotIt); expect(gotIt).not.toBeInTheDocument(); }); + + it('should show hardware wallet info text', () => { + const { queryByText, getByText, getByTestId } = renderWithProvider( + , + store, + ); + + const textField = getByTestId('custom-spending-cap-input'); + fireEvent.change(textField, { target: { value: '1' } }); + + const nextButton = getByText('Next'); + fireEvent.click(nextButton); + + expect(queryByText('Prior to clicking confirm:')).toBeInTheDocument(); + }); + + it('should not show hardware wallet info text', () => { + const { queryByText } = renderWithProvider( + , + store, + ); + + expect(queryByText('Prior to clicking confirm:')).toBeNull(); + }); });