Skip to content

Commit 617f163

Browse files
committed
fix: testcase
1 parent 20f0cf3 commit 617f163

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed
Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,47 @@
11
import React from "react";
22
import { render, screen } from "@testing-library/react";
33
import { PageLayout } from "..";
4-
import * as hooks from "../../../hooks"
4+
import * as hooks from "../../../hooks";
55

66
// Mocking the useDevice hook
77
jest.mock("../../../hooks", () => ({
8-
useDevice: jest.fn().mockReturnValue({isMobile:false}),
8+
useDevice: jest.fn().mockReturnValue({ isMobile: false }),
99
}));
1010

1111
describe("PageLayout Component", () => {
12-
it("renders children correctly", () => {
13-
render(
14-
<PageLayout>
15-
<div>Content</div>
16-
</PageLayout>
17-
);
18-
const content =screen.getByText("Content")
19-
expect(content).toBeInTheDocument();
20-
});
12+
it("renders children correctly", () => {
13+
render(
14+
<PageLayout>
15+
<div>Content</div>
16+
</PageLayout>,
17+
);
18+
const content = screen.getByText("Content");
19+
expect(content).toBeInTheDocument();
20+
});
2121

22-
it("renders sidebar when provided and not on mobile", () => {
23-
const sidebar = <div>Sidebar</div>;
24-
render(<PageLayout sidebar={sidebar} />);
25-
const sidebarContent =screen.getByText("Sidebar")
26-
expect(sidebarContent).toBeInTheDocument();
27-
});
22+
it("renders sidebar when provided and not on mobile", () => {
23+
const sidebar = <div>Sidebar</div>;
24+
render(<PageLayout sidebar={sidebar} />);
25+
const sidebarContent = screen.getByText("Sidebar");
26+
expect(sidebarContent).toBeInTheDocument();
27+
});
2828

29-
it("does not render sidebar on mobile", () => {
30-
jest.spyOn(hooks,'useDevice').mockImplementation(()=>({isMobile:true, isDesktop:false, isTablet:false}))
31-
const sidebar = <div>Sidebar</div>;
32-
render(<PageLayout sidebar={sidebar} />);
33-
const sidebarContent =screen.queryByText("Sidebar")
34-
expect(sidebarContent).not.toBeInTheDocument()
35-
});
29+
it("does not render sidebar on mobile", () => {
30+
jest.spyOn(hooks, "useDevice").mockImplementation(() => ({
31+
isMobile: true,
32+
isDesktop: false,
33+
isTablet: false,
34+
isTabletPortrait: false,
35+
}));
36+
const sidebar = <div>Sidebar</div>;
37+
render(<PageLayout sidebar={sidebar} />);
38+
const sidebarContent = screen.queryByText("Sidebar");
39+
expect(sidebarContent).not.toBeInTheDocument();
40+
});
3641

37-
it("does not render sidebar when not provided", () => {
38-
render(<PageLayout />);
39-
const sidebarContent=screen.queryByTestId("sidebar")
40-
expect(sidebarContent).toBeNull();
41-
});
42+
it("does not render sidebar when not provided", () => {
43+
render(<PageLayout />);
44+
const sidebarContent = screen.queryByTestId("sidebar");
45+
expect(sidebarContent).toBeNull();
46+
});
4247
});

0 commit comments

Comments
 (0)