diff --git a/__tests__/page/errorLoadingPage.test.ts b/__tests__/page/errorLoadingPage.test.tsx similarity index 60% rename from __tests__/page/errorLoadingPage.test.ts rename to __tests__/page/errorLoadingPage.test.tsx index 75b2cb2..f32eff7 100644 --- a/__tests__/page/errorLoadingPage.test.ts +++ b/__tests__/page/errorLoadingPage.test.tsx @@ -5,6 +5,8 @@ import Error from "@/app/error"; import Loading from "@/app/loading"; import NotFound from "@/app/not-found"; +import { mockError, mockReset } from "./utils"; + // Mock Cookies jest.mock("next/headers", () => ({ cookies: jest.fn(() => ({ @@ -15,15 +17,15 @@ jest.mock("next/headers", () => ({ // Error and Loading Pages describe("Error and Loading Pages", () => { - // it("Error Page should render without crashing", async () => { - // render(await Error()); - // }); - - it("Loading Page should render without crashing", async () => { - render(await Loading()); + it("Error Page should render without crashing", () => { + render(); }); - it("Not Found Page should render without crashing", async () => { - render(await NotFound()); + it("Loading Page should render without crashing", () => { + render(Loading()); + }); + + it("Not Found Page should render without crashing", () => { + render(NotFound()); }); }); \ No newline at end of file diff --git a/__tests__/page/utils.ts b/__tests__/page/utils.ts new file mode 100644 index 0000000..3087c90 --- /dev/null +++ b/__tests__/page/utils.ts @@ -0,0 +1,4 @@ +// #TODO move mock functions here +// Circumvent naming conflict, don't delete/move form this file +export const mockError = new Error(); +export const mockReset = () => {}; \ No newline at end of file diff --git a/__tests__/page/verificationPage.test.ts b/__tests__/page/verificationPage.test.ts index 6cf99c3..fdae27f 100644 --- a/__tests__/page/verificationPage.test.ts +++ b/__tests__/page/verificationPage.test.ts @@ -2,26 +2,13 @@ import { render } from "@testing-library/react"; // Pages - Verification import VerifyPage from "@/app/verify/page"; - -// Mock Cookies -jest.mock("next/headers", () => ({ - cookies: jest.fn(() => ({ - getAll: jest.fn(() => [{ name: "test", value: "cookieValue" }]), // Simulate returning cookies - setAll: jest.fn(), // Simulate setAll method - })), -})); +import React from "react"; // Mock Router jest.mock('next/navigation', () => ({ useRouter: jest.fn().mockReturnValue({ push: jest.fn(), - replace: jest.fn(), - prefetch: jest.fn(), - pathname: '/', - query: {}, - asPath: '/', }), - usePathname: jest.fn(() => '/'), useSearchParams: jest.fn(() => ({ get: jest.fn((key) => { if (key === 'email') return 'test@example.com'; // Mock behavior for 'email' query param @@ -31,8 +18,9 @@ jest.mock('next/navigation', () => ({ })); // Verification Pages -// describe("Verification Pages", () => { -// it("Verify Page should render without crashing", () => { -// render(VerifyPage()); -// }); -// }); \ No newline at end of file +describe("Verification Pages", () => { + it("Verify Page should render without crashing", () => { + jest.spyOn(React, 'useEffect').mockImplementation((f) => f()); + render(VerifyPage()); + }); +}); \ No newline at end of file