Skip to content

Commit

Permalink
test(modal): update test and remove close test
Browse files Browse the repository at this point in the history
functionality is covered by next-ui modal
  • Loading branch information
escapedcat committed Sep 29, 2024
1 parent 51e282f commit ca92c11
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
6 changes: 3 additions & 3 deletions src/pages/Home/ReceiveModal/__tests__/ReceiveModal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ReceiveModal from "../ReceiveModal";
import { http, server, HttpResponse } from "@/testServer";
import userEvent from "@testing-library/user-event";
import { render, screen } from "test-utils";
import { render, screen, mockedDisclosure } from "test-utils";

beforeEach(() => {
server.use(
Expand All @@ -16,7 +16,7 @@ beforeEach(() => {
describe("ReceiveModal", () => {
test("Retrieves new on-chain address on click of on-chain button", async () => {
const user = userEvent.setup();
render(<ReceiveModal onClose={() => {}} />);
render(<ReceiveModal disclosure={mockedDisclosure} />);

const onChainBtn = await screen.findByText("wallet.on_chain");

Expand All @@ -27,7 +27,7 @@ describe("ReceiveModal", () => {

test("Retrieves a new address upon clicking the refresh button", async () => {
const user = userEvent.setup();
render(<ReceiveModal onClose={() => {}} />);
render(<ReceiveModal disclosure={mockedDisclosure} />);

const onChainBtn = screen.getByRole("button", { name: "wallet.on_chain" });

Expand Down
15 changes: 3 additions & 12 deletions src/pages/Home/SendModal/__tests__/SendModal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import SendModal, { Props } from "../SendModal";
import SendModal, { type Props } from "../SendModal";

Check failure on line 1 in src/pages/Home/SendModal/__tests__/SendModal.test.tsx

View workflow job for this annotation

GitHub Actions / build (20.x)

Module '"../SendModal"' has no exported member 'Props'. Did you mean to use 'import Props from "../SendModal"' instead?
import { HttpResponse, http, server } from "@/testServer";
import userEvent from "@testing-library/user-event";
import type { UserEvent } from "@testing-library/user-event/dist/types/setup/setup";
import { render, screen } from "test-utils";
import { render, screen, mockedDisclosure } from "test-utils";

const handleClose = vi.fn();
const basicProps: Props = {
lnBalance: 0,
onchainBalance: 0,
onClose: handleClose,
disclosure: mockedDisclosure,
};

const setup = () => {
Expand All @@ -32,14 +31,6 @@ describe("SendModal", () => {
expect(onChainBtn).not.toBeDisabled();
});

it("should close on click of X button", async () => {
const user = userEvent.setup();
setup();
const closeBtn = screen.getByRole("button", { name: "" });
await user.click(closeBtn);
expect(handleClose).toHaveBeenCalled();
});

describe("SendLN", () => {
it("enables the send button on valid input", async () => {
const user = userEvent.setup();
Expand Down
12 changes: 1 addition & 11 deletions src/pages/Home/__tests__/UnlockModal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import UnlockModal from "../UnlockModal";
import { http, server, HttpResponse } from "@/testServer";
import userEvent from "@testing-library/user-event";
import { render, screen } from "test-utils";

const mockedDisclosure = {
isOpen: true,
onOpen: vi.fn(),
onClose: vi.fn(),
onOpenChange: vi.fn(),
isControlled: false,
getButtonProps: vi.fn(),
getDisclosureProps: vi.fn(),
};
import { render, screen, mockedDisclosure } from "test-utils";

describe("UnlockModal", () => {
const setup = () => {
Expand Down
10 changes: 10 additions & 0 deletions src/utils/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,13 @@ const customRender = (

export * from "@testing-library/react";
export { customRender as render };

export const mockedDisclosure = {
isOpen: true,
onOpen: vi.fn(),
onClose: vi.fn(),
onOpenChange: vi.fn(),
isControlled: false,
getButtonProps: vi.fn(),
getDisclosureProps: vi.fn(),
};

0 comments on commit ca92c11

Please sign in to comment.