Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/refactor/multipay-recipients-rev…
Browse files Browse the repository at this point in the history
…iew' into refactor/multipay-recipients-review
  • Loading branch information
shahin-hq committed Oct 22, 2024
2 parents 7e74901 + 85d8af4 commit e1948e1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import {RecipientsList} from "./RecipientsList";
import {RecipientItem} from "./RecipientsModal.contracts";
import {render, screen} from "@testing-library/react";
import { RecipientsList } from "./RecipientsList";
import { RecipientItem } from "./RecipientsModal.contracts";
import { render, screen } from "@testing-library/react";

const recipients: RecipientItem[] = [
{
Expand All @@ -22,7 +22,7 @@ describe("RecipientsList", () => {

render(<RecipientsList recipients={recipients} ticker={ticker} />);

expect(screen.getAllByTestId("RecipientsListItem").length).toBe(recipients.length)
expect(screen.getAllByTestId("RecipientsListItem").length).toBe(recipients.length);
expect(screen.getByText(recipients[0].alias)).toBeInTheDocument();
expect(screen.getByText(recipients[0].amount + ` ${ticker}`)).toBeInTheDocument();
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import {RecipientItem} from "./RecipientsModal.contracts";
import {screen} from "@testing-library/react";
import {RecipientsModal} from "./RecipientsModal";
import { RecipientItem } from "./RecipientsModal.contracts";
import { screen } from "@testing-library/react";
import { RecipientsModal } from "./RecipientsModal";
import { renderResponsive } from "@/utils/testing-library";

const recipients: RecipientItem[] = [
Expand All @@ -19,22 +19,31 @@ const recipients: RecipientItem[] = [

describe("RecipientsModal", () => {
it("should render `RecipientsLists` in `sm` screen", () => {
renderResponsive(<RecipientsModal recipients={recipients} ticker="DARK" isOpen={true} onClose={vi.fn()}/>, "sm");
renderResponsive(
<RecipientsModal recipients={recipients} ticker="DARK" isOpen={true} onClose={vi.fn()} />,
"sm",
);

expect(screen.getAllByTestId("RecipientsListItem").length).toBeTruthy();
expect(screen.queryByTestId("TableWrapper")).not.toBeInTheDocument();
});

it("should render `RecipientsTable` in `lg` screen", () => {
renderResponsive(<RecipientsModal recipients={recipients} ticker="DARK" isOpen={true} onClose={vi.fn()}/>, "lg");
renderResponsive(
<RecipientsModal recipients={recipients} ticker="DARK" isOpen={true} onClose={vi.fn()} />,
"lg",
);

expect(screen.getByTestId("TableWrapper")).toBeInTheDocument();
expect(screen.queryAllByTestId("RecipientsListItem").length).toBe(0);
});

it("should show number of recipients in the modal title", () => {
renderResponsive(<RecipientsModal recipients={recipients} ticker="DARK" isOpen={true} onClose={vi.fn()}/>, "sm");
renderResponsive(
<RecipientsModal recipients={recipients} ticker="DARK" isOpen={true} onClose={vi.fn()} />,
"sm",
);

expect(screen.getByTestId('RecipientsModal--RecipientsCount')).toHaveTextContent(recipients.length)
expect(screen.getByTestId("RecipientsModal--RecipientsCount")).toHaveTextContent(recipients.length);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ const ModalTitle = ({ count }: { count: number }) => {
<span
className="text-theme-secondary-500 dark:text-theme-secondary-500"
data-testid="RecipientsModal--RecipientsCount"
>({count})
>
({count})
</span>
</span>
);
Expand Down

0 comments on commit e1948e1

Please sign in to comment.