Creation dialog with redux-form validation
[arvados-workbench2.git] / src / components / context-menu / context-menu.test.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from "react";
6 import { mount, configure, shallow } from "enzyme";
7 import * as Adapter from "enzyme-adapter-react-16";
8 import ContextMenu from "./context-menu";
9 import { ListItem } from "@material-ui/core";
10
11 configure({ adapter: new Adapter() });
12
13 describe("<ContextMenu />", () => {
14     const actions = [[{
15         icon: "",
16         name: "Action 1.1"
17     }, {
18         icon: "",
19         name: "Action 1.2"
20     },], [{
21         icon: "",
22         name: "Action 2.1"
23     }]];
24
25     it("calls onActionClick with clicked action", () => {
26         const onActionClick = jest.fn();
27         const contextMenu = mount(<ContextMenu
28             anchorEl={document.createElement("div")}
29             onClose={jest.fn()}
30             onActionClick={onActionClick}
31             actions={actions} />);
32         contextMenu.find(ListItem).at(2).simulate("click");
33         expect(onActionClick).toHaveBeenCalledWith(actions[1][0]);
34     });
35 });