Skip to content

Commit

Permalink
Add TransactionsList test
Browse files Browse the repository at this point in the history
  • Loading branch information
arhtudormorar committed May 26, 2021
1 parent 5dd9ff7 commit efb1b41
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/pages/Dashboard/TopInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const TopInfo = () => {
</div>
<div className="mb-4">
<span className="opacity-6 mr-1">Contract address:</span>
<span>{contractAddress}</span>
<span data-testid="contractAddress">{contractAddress}</span>
</div>
<div>
<h3 className="py-2">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Dashboard/Transactions/TransactionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const TransactionList = ({
<th className="border-0 font-weight-normal">Amount</th>
</tr>
</thead>
<tbody>
<tbody data-testid="transactionsList">
{sortedTransactions.map((tx: TransactionType, i) => {
const incomingTransaction = incoming(tx.sender);
return (
Expand Down
12 changes: 11 additions & 1 deletion src/pages/Dashboard/tests/Dashboard.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { routeNames } from "routes";
import { renderWithRouter, testAddress } from "testUtils";
import { contractAddress as configContractAddress } from "config";

jest.mock("@elrondnetwork/dapp", () => {
const dapp = jest.requireActual("@elrondnetwork/dapp");
Expand Down Expand Up @@ -34,11 +35,20 @@ describe("Dashboard page", () => {
const screen = renderWithRouter({
route: `${routeNames.dashboard}?address=${testAddress}`,
});
expect(screen.history.location.pathname).toBe(routeNames.dashboard);
const topInfo = await screen.findByTestId("topInfo");
expect(topInfo).toBeDefined();

const accountAddress = screen.getByTestId("accountAddress");
expect(accountAddress.innerHTML).toBe(testAddress);

const contractAddress = screen.getByTestId("contractAddress");
expect(contractAddress.innerHTML).toBe(configContractAddress);
});
it("shows transactions list", async () => {
const screen = renderWithRouter({
route: `${routeNames.dashboard}?address=${testAddress}`,
});
const transactionsList = await screen.findByTestId("transactionsList");
expect(transactionsList.childElementCount).toBe(6);
});
});

0 comments on commit efb1b41

Please sign in to comment.