Skip to content

Commit

Permalink
adds token amount dom test
Browse files Browse the repository at this point in the history
  • Loading branch information
aristidesstaffieri committed Aug 21, 2023
1 parent a27fd26 commit 01b4947
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
32 changes: 10 additions & 22 deletions extension/src/popup/__testHelpers__/index.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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,
Expand Down Expand Up @@ -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,
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export const AccountAssets = ({
<ScamAssetIcon isScamAsset={isScamAsset} />
</div>
<div className="AccountAssets__copy-right">
<div className="asset-amount">
<div className="asset-amount" data-testid="asset-amount">
{formatAmount(amountVal)} <span>{amountUnit}</span>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe("SendTokenPayment", () => {
mockHistoryGetter.mockReturnValue(history);

const asset = "DT:CCXVDIGMR6WTXZQX2OEVD6YM6AYCYPXPQ7YYH6OZMRS7U6VD3AVHNGBJ";
render(
const { container } = render(
<Wrapper
history={history}
state={{
Expand Down Expand Up @@ -178,6 +178,7 @@ describe("SendTokenPayment", () => {
});

await waitFor(async () => {
expect(container).toHaveTextContent("5 DT");
const sendBtn = screen.getByTestId("transaction-details-btn-send");
await fireEvent.click(sendBtn);
});
Expand Down

0 comments on commit 01b4947

Please sign in to comment.