1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Mocking HotbarToggleMenuItem

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-10-18 10:22:07 +03:00
parent 62b45875c4
commit 07cda6d4ea
2 changed files with 9 additions and 3 deletions

View File

@ -46,6 +46,12 @@ jest.mock("@electron/remote", () => {
};
});
jest.mock("./hotbar-toggle-menu-item", () => {
return {
HotbarToggleMenuItem: () => <div>menu item</div>
};
});
describe("<Catalog />", () => {
const history = createMemoryHistory();
const mockLocation = {

View File

@ -27,9 +27,9 @@ import type { CatalogEntity } from "../../api/catalog-entity";
export function HotbarToggleMenuItem(props: { entity: CatalogEntity, addContent: ReactNode, removeContent: ReactNode }) {
const store = HotbarStore.getInstance(false);
const add = () => store?.addToHotbar(props.entity);
const remove = () => store?.removeFromHotbar(props.entity.getId());
const [itemInHotbar, setItemInHotbar] = useState(store?.isAddedToActive(props.entity));
const add = () => store.addToHotbar(props.entity);
const remove = () => store.removeFromHotbar(props.entity.getId());
const [itemInHotbar, setItemInHotbar] = useState(store.isAddedToActive(props.entity));
return (
<MenuItem onClick={() => {