Skip to content

Commit 2b848f6

Browse files
committed
test(Page): add unit test for content.__error rendering
1 parent 001c29c commit 2b848f6

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/components/Page/__tests__/Page.test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@ import { render, screen } from "@testing-library/react";
77
import { MemoryRouter } from "react-router";
88
import Page from "../Page";
99

10-
// mock components that break tests
10+
// Mock components that cause unrelated failures
1111
jest.mock("../../Contributors/Contributors.jsx", () => () => <div />);
1212
jest.mock("../../PageLinks/PageLinks.jsx", () => () => <div />);
1313

14+
// Mock react-router hook used inside Page
15+
jest.mock("react-router", () => ({
16+
...jest.requireActual("react-router"),
17+
useLocation: () => ({ pathname: "/test", hash: "" }),
18+
}));
19+
1420
describe("Page component", () => {
1521
it("renders error message when content.__error exists", () => {
1622
const content = {

0 commit comments

Comments
 (0)