diff --git a/src/renderer/components/cluster-manager/active-hotbar-name.tsx b/src/renderer/components/cluster-manager/active-hotbar-name.tsx index be9f2254eb..29e750d59f 100644 --- a/src/renderer/components/cluster-manager/active-hotbar-name.tsx +++ b/src/renderer/components/cluster-manager/active-hotbar-name.tsx @@ -26,7 +26,7 @@ import { HotbarStore } from "../../../common/hotbar-store"; export const ActiveHotbarName = observer(() => { return ( -
+
{" "} {HotbarStore.getInstance().getActive()?.name}
diff --git a/src/renderer/components/cluster-manager/bottom-bar.test.tsx b/src/renderer/components/cluster-manager/bottom-bar.test.tsx index d9f683fe66..6eba477bcb 100644 --- a/src/renderer/components/cluster-manager/bottom-bar.test.tsx +++ b/src/renderer/components/cluster-manager/bottom-bar.test.tsx @@ -20,25 +20,49 @@ */ import React from "react"; +import mockFs from "mock-fs"; import { render } from "@testing-library/react"; import "@testing-library/jest-dom/extend-expect"; +import { BottomBar } from "./bottom-bar"; +import { StatusBarRegistry } from "../../../extensions/registries"; +import { HotbarStore } from "../../../common/hotbar-store"; +import { AppPaths } from "../../../common/app-paths"; + +AppPaths.init(); jest.mock("electron", () => ({ app: { - getPath: () => "/foo", + getName: () => "lens", + setName: jest.fn(), + setPath: jest.fn(), + getPath: () => "tmp", + }, + ipcMain: { + handle: jest.fn(), + on: jest.fn(), + removeAllListeners: jest.fn(), + off: jest.fn(), + send: jest.fn(), }, })); -import { BottomBar } from "./bottom-bar"; -import { StatusBarRegistry } from "../../../extensions/registries"; - describe("", () => { beforeEach(() => { + const mockOpts = { + "tmp": { + "test-store.json": JSON.stringify({}), + }, + }; + + mockFs(mockOpts); StatusBarRegistry.createInstance(); + HotbarStore.createInstance(); }); afterEach(() => { StatusBarRegistry.resetInstance(); + HotbarStore.resetInstance(); + mockFs.restore(); }); it("renders w/o errors", () => { @@ -87,4 +111,21 @@ describe("", () => { expect(await getByTestId(testId)).toHaveTextContent(text); }); + + it("show default hotbar name", () => { + const { getByTestId } = render(); + + expect(getByTestId("current-hotbar-name")).toHaveTextContent("default"); + }); + + it("show active hotbar name", () => { + const { getByTestId } = render(); + + HotbarStore.getInstance().add({ + id: "new", + name: "new", + }, { setActive: true }); + + expect(getByTestId("current-hotbar-name")).toHaveTextContent("new"); + }); });