Skip to content

Commit

Permalink
mock store correctly for Sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
Rocio De Santiago authored and Rocio De Santiago committed Nov 22, 2024
1 parent 3a7139f commit 6c6064f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions services/ui-src/src/components/report/Sidebar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
useParams,
} from "react-router-dom";
import { Sidebar } from "./Sidebar";
import { useStore } from "../../utils/state/useStore";
import { useStore } from "utils";

jest.mock("../../utils/state/useStore", () => ({
jest.mock("utils", () => ({
useStore: jest.fn(),
}));

Expand Down Expand Up @@ -38,21 +38,21 @@ const report = {

describe("Sidebar", () => {
beforeEach(() => {
useStore.mockReturnValue({
(useStore as unknown as jest.Mock).mockReturnValue({
pageMap: mockPageMap,
report,
currentPageId: "id-1",
setCurrentPageId,
});
useNavigate.mockReturnValue(mockNavigate);
useParams.mockReturnValue({
(useNavigate as jest.Mock).mockReturnValue(mockNavigate);
(useParams as jest.Mock).mockReturnValue({
reportType: "exampleReport",
state: "exampleState",
reportId: "123",
});
});
test("should not render if missing details from the store", () => {
useStore.mockReturnValueOnce({
(useStore as unknown as jest.Mock).mockReturnValueOnce({
pageMap: undefined,
report: undefined,
currentPageId: undefined,
Expand Down

0 comments on commit 6c6064f

Please sign in to comment.