mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Open CommandPalette on hotbar name click
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
3b5f619dbc
commit
dc8b01b2ee
@ -23,11 +23,17 @@ import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { Icon } from "../icon";
|
||||
import { HotbarStore } from "../../../common/hotbar-store";
|
||||
import { CommandOverlay } from "../command-palette";
|
||||
import { HotbarSwitchCommand } from "../hotbar/hotbar-switch-command";
|
||||
|
||||
export const ActiveHotbarName = observer(() => {
|
||||
return (
|
||||
<div className="flex items-center" data-testid="current-hotbar-name">
|
||||
<Icon material="bookmarks" smallest className="mr-2"/>{" "}
|
||||
<div
|
||||
className="flex items-center"
|
||||
data-testid="current-hotbar-name"
|
||||
onClick={() => CommandOverlay.open(<HotbarSwitchCommand />)}
|
||||
>
|
||||
<Icon material="bookmarks" className="mr-2" style={{ "--size": "14px" } as React.CSSProperties}/>
|
||||
{HotbarStore.getInstance().getActive()?.name}
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -21,12 +21,20 @@
|
||||
|
||||
import React from "react";
|
||||
import mockFs from "mock-fs";
|
||||
import { render } from "@testing-library/react";
|
||||
import { render, fireEvent } 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";
|
||||
import { CommandOverlay } from "../command-palette";
|
||||
import { HotbarSwitchCommand } from "../hotbar/hotbar-switch-command";
|
||||
|
||||
jest.mock("../command-palette", () => ({
|
||||
CommandOverlay: {
|
||||
open: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
AppPaths.init();
|
||||
|
||||
@ -128,4 +136,13 @@ describe("<BottomBar />", () => {
|
||||
|
||||
expect(getByTestId("current-hotbar-name")).toHaveTextContent("new");
|
||||
});
|
||||
|
||||
it("opens command palette on click", () => {
|
||||
const { getByTestId } = render(<BottomBar />);
|
||||
const activeHotbar = getByTestId("current-hotbar-name");
|
||||
|
||||
fireEvent.click(activeHotbar);
|
||||
|
||||
expect(CommandOverlay.open).toHaveBeenCalledWith(<HotbarSwitchCommand />);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user