X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/a93f9562ce74d8cfb1cb7a5808e2b355e8e370c2:/src/components/data-explorer/context-menu.test.tsx..04895cf6825dab872f91bf86941b51d5b00cb39a:/src/components/context-menu/context-menu.test.tsx diff --git a/src/components/data-explorer/context-menu.test.tsx b/src/components/context-menu/context-menu.test.tsx similarity index 50% rename from src/components/data-explorer/context-menu.test.tsx rename to src/components/context-menu/context-menu.test.tsx index 89218089..9e4a9a47 100644 --- a/src/components/data-explorer/context-menu.test.tsx +++ b/src/components/context-menu/context-menu.test.tsx @@ -5,7 +5,7 @@ import * as React from "react"; import { mount, configure, shallow } from "enzyme"; import * as Adapter from "enzyme-adapter-react-16"; -import { ContextMenu } from "./context-menu"; +import ContextMenu from "./context-menu"; import { ListItem } from "@material-ui/core"; configure({ adapter: new Adapter() }); @@ -19,15 +19,20 @@ describe("", () => { type: "" }; - const actions = { - onAddToFavourite: jest.fn(), - onCopy: jest.fn(), - onDownload: jest.fn(), - onMoveTo: jest.fn(), - onRemove: jest.fn(), - onRename: jest.fn(), - onShare: jest.fn() - }; + const actions = [[{ + icon: "", + name: "Action 1.1", + onClick: jest.fn() + }, + { + icon: "", + name: "Action 1.2", + onClick: jest.fn() + },], [{ + icon: "", + name: "Action 2.1", + onClick: jest.fn() + }]]; it("calls provided actions with provided item", () => { const contextMenu = mount(", () => { onClose={jest.fn()} {...{ actions, item }} />); - for (let index = 0; index < Object.keys(actions).length; index++) { - contextMenu.find(ListItem).at(index).simulate("click"); - } + contextMenu.find(ListItem).at(0).simulate("click"); + contextMenu.find(ListItem).at(1).simulate("click"); + contextMenu.find(ListItem).at(2).simulate("click"); - Object.keys(actions).forEach(key => { - expect(actions[key]).toHaveBeenCalledWith(item); - }); + expect(actions[0][0].onClick).toHaveBeenCalledWith(item); + expect(actions[0][1].onClick).toHaveBeenCalledWith(item); + expect(actions[1][0].onClick).toHaveBeenCalledWith(item); }); }); \ No newline at end of file