X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/1cc633c7a6ad9609424580973da06c92839489e2..2f39812f57c2acbc20a6292964b0a6b3512a9870:/src/components/context-menu/context-menu.test.tsx?ds=sidebyside

diff --git a/src/components/context-menu/context-menu.test.tsx b/src/components/context-menu/context-menu.test.tsx
index 9e4a9a47..faf05f1f 100644
--- a/src/components/context-menu/context-menu.test.tsx
+++ b/src/components/context-menu/context-menu.test.tsx
@@ -3,49 +3,35 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from "react";
-import { mount, configure, shallow } from "enzyme";
+import { mount, configure } 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";
+import { ShareIcon } from "../icon/icon";
 
 configure({ adapter: new Adapter() });
 
 describe("<ContextMenu />", () => {
-
-    const item = {
-        name: "",
-        owner: "",
-        lastModified: "",
-        type: ""
-    };
-
-    const actions = [[{
-        icon: "",
-        name: "Action 1.1",
-        onClick: jest.fn()
-    },
-    {
-        icon: "",
-        name: "Action 1.2",
-        onClick: jest.fn()
+    const items = [[{
+        icon: ShareIcon,
+        name: "Action 1.1"
+    }, {
+        icon: ShareIcon,
+        name: "Action 1.2"
     },], [{
-        icon: "",
-        name: "Action 2.1",
-        onClick: jest.fn()
+        icon: ShareIcon,
+        name: "Action 2.1"
     }]];
 
-    it("calls provided actions with provided item", () => {
+    it("calls onItemClick with clicked action", () => {
+        const onItemClick = jest.fn();
         const contextMenu = mount(<ContextMenu
             anchorEl={document.createElement("div")}
+            open={true}
             onClose={jest.fn()}
-            {...{ actions, item }} />);
-
-        contextMenu.find(ListItem).at(0).simulate("click");
-        contextMenu.find(ListItem).at(1).simulate("click");
+            onItemClick={onItemClick}
+            items={items} />);
         contextMenu.find(ListItem).at(2).simulate("click");
-
-        expect(actions[0][0].onClick).toHaveBeenCalledWith(item);
-        expect(actions[0][1].onClick).toHaveBeenCalledWith(item);
-        expect(actions[1][0].onClick).toHaveBeenCalledWith(item);
+        expect(onItemClick).toHaveBeenCalledWith(items[1][0]);
     });
-});
\ No newline at end of file
+});
