From 01b4947dcf915527cf3e43aa353f091dfbaf27a9 Mon Sep 17 00:00:00 2001 From: Aristides Staffieri Date: Mon, 21 Aug 2023 13:54:29 -0600 Subject: [PATCH] adds token amount dom test --- extension/src/popup/__testHelpers__/index.tsx | 32 ++++++------------- .../account/AccountAssets/index.tsx | 2 +- .../components/sendPayment/SendTo/index.tsx | 1 - .../views/__tests__/SendTokenPayment.test.tsx | 3 +- 4 files changed, 13 insertions(+), 25 deletions(-) diff --git a/extension/src/popup/__testHelpers__/index.tsx b/extension/src/popup/__testHelpers__/index.tsx index c8c7f96e17..80f774431d 100644 --- a/extension/src/popup/__testHelpers__/index.tsx +++ b/extension/src/popup/__testHelpers__/index.tsx @@ -1,5 +1,5 @@ import React from "react"; -import { useSelector, Provider } from "react-redux"; +import { Provider } from "react-redux"; import * as SorobanClient from "soroban-client"; import BigNumber from "bignumber.js"; import { createMemoryHistory } from "history"; @@ -10,17 +10,11 @@ import { } from "@reduxjs/toolkit"; import { APPLICATION_STATE } from "@shared/constants/applicationState"; import { Balances } from "@shared/api/types"; -import { - SOROBAN_RPC_URLS, - FUTURENET_NETWORK_DETAILS, -} from "@shared/constants/stellar"; +import { FUTURENET_NETWORK_DETAILS } from "@shared/constants/stellar"; import { isSerializable } from "helpers/stellar"; import { reducer as auth } from "popup/ducks/accountServices"; -import { - reducer as settings, - settingsNetworkDetailsSelector, -} from "popup/ducks/settings"; +import { reducer as settings } from "popup/ducks/settings"; import { reducer as transactionSubmission, initialState as transactionSubmissionInitialState, @@ -60,24 +54,18 @@ const MockSorobanProvider = ({ children: React.ReactNode; pubKey: string; }) => { - const networkDetails = useSelector(settingsNetworkDetailsSelector); - - const serverUrl = - networkDetails.networkPassphrase === - "Test SDF Future Network ; October 2022" && - networkDetails.networkUrl === FUTURENET_NETWORK_DETAILS.networkUrl - ? SOROBAN_RPC_URLS.FUTURENET - : networkDetails.networkUrl; - - const server = new SorobanClient.Server(serverUrl, { - allowHttp: networkDetails.networkUrl.startsWith("http://"), - }); + const server = new SorobanClient.Server( + FUTURENET_NETWORK_DETAILS.networkUrl, + { + allowHttp: FUTURENET_NETWORK_DETAILS.networkUrl.startsWith("http://"), + }, + ); const newTxBuilder = async (fee = SorobanClient.BASE_FEE) => { const sourceAccount = new SorobanClient.Account(pubKey, "0"); return new SorobanClient.TransactionBuilder(sourceAccount, { fee, - networkPassphrase: networkDetails.networkPassphrase, + networkPassphrase: FUTURENET_NETWORK_DETAILS.networkPassphrase, }); }; diff --git a/extension/src/popup/components/account/AccountAssets/index.tsx b/extension/src/popup/components/account/AccountAssets/index.tsx index 67e35a228f..088c290341 100644 --- a/extension/src/popup/components/account/AccountAssets/index.tsx +++ b/extension/src/popup/components/account/AccountAssets/index.tsx @@ -241,7 +241,7 @@ export const AccountAssets = ({
-
+
{formatAmount(amountVal)} {amountUnit}
diff --git a/extension/src/popup/components/sendPayment/SendTo/index.tsx b/extension/src/popup/components/sendPayment/SendTo/index.tsx index 409540741b..a3181affc0 100644 --- a/extension/src/popup/components/sendPayment/SendTo/index.tsx +++ b/extension/src/popup/components/sendPayment/SendTo/index.tsx @@ -143,7 +143,6 @@ export const SendTo = ({ previous }: { previous: ROUTES }) => { const db = useCallback( debounce(async (inputDest) => { const errors = await formik.validateForm(); - if (Object.keys(errors).length !== 0) { setIsLoading(false); return; diff --git a/extension/src/popup/views/__tests__/SendTokenPayment.test.tsx b/extension/src/popup/views/__tests__/SendTokenPayment.test.tsx index 547ee07792..38114680b3 100644 --- a/extension/src/popup/views/__tests__/SendTokenPayment.test.tsx +++ b/extension/src/popup/views/__tests__/SendTokenPayment.test.tsx @@ -112,7 +112,7 @@ describe("SendTokenPayment", () => { mockHistoryGetter.mockReturnValue(history); const asset = "DT:CCXVDIGMR6WTXZQX2OEVD6YM6AYCYPXPQ7YYH6OZMRS7U6VD3AVHNGBJ"; - render( + const { container } = render( { }); await waitFor(async () => { + expect(container).toHaveTextContent("5 DT"); const sendBtn = screen.getByTestId("transaction-details-btn-send"); await fireEvent.click(sendBtn); });