diff --git a/src/components/PageLayout/__test__/PageLayout.spec.tsx b/src/components/PageLayout/__test__/PageLayout.spec.tsx
index 569b2573..7f44bd1a 100644
--- a/src/components/PageLayout/__test__/PageLayout.spec.tsx
+++ b/src/components/PageLayout/__test__/PageLayout.spec.tsx
@@ -1,42 +1,47 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import { PageLayout } from "..";
-import * as hooks from "../../../hooks"
+import * as hooks from "../../../hooks";
// Mocking the useDevice hook
jest.mock("../../../hooks", () => ({
- useDevice: jest.fn().mockReturnValue({isMobile:false}),
+ useDevice: jest.fn().mockReturnValue({ isMobile: false }),
}));
describe("PageLayout Component", () => {
- it("renders children correctly", () => {
- render(
-
- Content
-
- );
- const content =screen.getByText("Content")
- expect(content).toBeInTheDocument();
- });
+ it("renders children correctly", () => {
+ render(
+
+ Content
+ ,
+ );
+ const content = screen.getByText("Content");
+ expect(content).toBeInTheDocument();
+ });
- it("renders sidebar when provided and not on mobile", () => {
- const sidebar =
Sidebar
;
- render();
- const sidebarContent =screen.getByText("Sidebar")
- expect(sidebarContent).toBeInTheDocument();
- });
+ it("renders sidebar when provided and not on mobile", () => {
+ const sidebar = Sidebar
;
+ render();
+ const sidebarContent = screen.getByText("Sidebar");
+ expect(sidebarContent).toBeInTheDocument();
+ });
- it("does not render sidebar on mobile", () => {
- jest.spyOn(hooks,'useDevice').mockImplementation(()=>({isMobile:true, isDesktop:false, isTablet:false}))
- const sidebar = Sidebar
;
- render();
- const sidebarContent =screen.queryByText("Sidebar")
- expect(sidebarContent).not.toBeInTheDocument()
- });
+ it("does not render sidebar on mobile", () => {
+ jest.spyOn(hooks, "useDevice").mockImplementation(() => ({
+ isMobile: true,
+ isDesktop: false,
+ isTablet: false,
+ isTabletPortrait: false,
+ }));
+ const sidebar = Sidebar
;
+ render();
+ const sidebarContent = screen.queryByText("Sidebar");
+ expect(sidebarContent).not.toBeInTheDocument();
+ });
- it("does not render sidebar when not provided", () => {
- render();
- const sidebarContent=screen.queryByTestId("sidebar")
- expect(sidebarContent).toBeNull();
- });
+ it("does not render sidebar when not provided", () => {
+ render();
+ const sidebarContent = screen.queryByTestId("sidebar");
+ expect(sidebarContent).toBeNull();
+ });
});
diff --git a/src/hooks/useDevice.ts b/src/hooks/useDevice.ts
index 92cb487d..e6f10968 100644
--- a/src/hooks/useDevice.ts
+++ b/src/hooks/useDevice.ts
@@ -7,6 +7,9 @@ export const useDevice = () => {
const isTablet = useMediaQuery(
`(min-width: 601px) and (max-width: 1279px)`,
);
+ const isTabletPortrait = useMediaQuery(
+ `(min-width: 601px) and (max-width: 1279px) and (orientation: portrait)`,
+ );
return {
/** returns Larger screen tablets [min-width: 1280px] */
isDesktop,
@@ -14,5 +17,7 @@ export const useDevice = () => {
isMobile,
/** returns Larger screen phones and smaller screen desktop [min-width: 601px and max-width: 1279px] */
isTablet,
+ /** returns tablet screen with portrait orientation [min-width: 601px and max-width: 1279px and orientation: portrait] */
+ isTabletPortrait,
};
};