|
1 | | -import { beforeEach, describe, it, vi } from "vitest"; |
2 | | -import { render } from "../../../../../test/src/react-render.js"; |
| 1 | +import { beforeEach, describe, expect, it, vi } from "vitest"; |
| 2 | +import { |
| 3 | + fireEvent, |
| 4 | + render, |
| 5 | + screen, |
| 6 | + waitFor, |
| 7 | +} from "../../../../../test/src/react-render.js"; |
3 | 8 | import { TEST_CLIENT } from "../../../../../test/src/test-clients.js"; |
4 | 9 | import { useActiveAccount } from "../../../core/hooks/wallets/useActiveAccount.js"; |
5 | 10 | import { DetailsModal } from "./Details.js"; |
@@ -50,5 +55,53 @@ describe("Details Component", () => { |
50 | 55 | assetTabs={mockAssetTabs} |
51 | 56 | />, |
52 | 57 | ); |
| 58 | + |
| 59 | + await waitFor(() => { |
| 60 | + expect(closeModalMock).toHaveBeenCalled(); |
| 61 | + }); |
| 62 | + }); |
| 63 | + |
| 64 | + it("should render the DetailsModal with default props", async () => { |
| 65 | + const closeModalMock = vi.fn(); |
| 66 | + const locale = await getConnectLocale("en_US"); |
| 67 | + |
| 68 | + render( |
| 69 | + <DetailsModal |
| 70 | + client={TEST_CLIENT} |
| 71 | + locale={locale} |
| 72 | + theme="light" |
| 73 | + closeModal={closeModalMock} |
| 74 | + onDisconnect={mockOnDisconnect} |
| 75 | + chains={mockChains} |
| 76 | + connectOptions={mockConnectOptions} |
| 77 | + />, |
| 78 | + ); |
| 79 | + |
| 80 | + // Add assertions to check if the modal is rendered correctly |
| 81 | + expect(screen.getByText("Connect Modal")).toBeInTheDocument(); |
| 82 | + }); |
| 83 | + |
| 84 | + it("should call closeModal when the close button is clicked", async () => { |
| 85 | + const closeModalMock = vi.fn(); |
| 86 | + const locale = await getConnectLocale("en_US"); |
| 87 | + |
| 88 | + render( |
| 89 | + <DetailsModal |
| 90 | + client={TEST_CLIENT} |
| 91 | + locale={locale} |
| 92 | + theme="light" |
| 93 | + closeModal={closeModalMock} |
| 94 | + onDisconnect={mockOnDisconnect} |
| 95 | + chains={mockChains} |
| 96 | + connectOptions={mockConnectOptions} |
| 97 | + />, |
| 98 | + ); |
| 99 | + |
| 100 | + // Simulate clicking the close button |
| 101 | + fireEvent.click(screen.getByRole("button", { name: /close/i })); |
| 102 | + |
| 103 | + await waitFor(() => { |
| 104 | + expect(closeModalMock).toHaveBeenCalled(); |
| 105 | + }); |
53 | 106 | }); |
54 | 107 | }); |
0 commit comments