mirror of
https://github.com/Sosokker/B2D-Ventures.git
synced 2025-12-18 13:34:06 +01:00
fix error page test
This commit is contained in:
parent
8a65012044
commit
aff0bad8bb
@ -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(<Error error={mockError} reset={mockReset} />);
|
||||
});
|
||||
|
||||
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());
|
||||
});
|
||||
});
|
||||
4
__tests__/page/utils.ts
Normal file
4
__tests__/page/utils.ts
Normal file
@ -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 = () => {};
|
||||
@ -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());
|
||||
// });
|
||||
// });
|
||||
describe("Verification Pages", () => {
|
||||
it("Verify Page should render without crashing", () => {
|
||||
jest.spyOn(React, 'useEffect').mockImplementation((f) => f());
|
||||
render(VerifyPage());
|
||||
});
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user