1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
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";
11 configure({ adapter: new Adapter() });
13 describe("<ContextMenu />", () => {
23 onAddToFavourite: jest.fn(),
25 onDownload: jest.fn(),
32 it("calls provided actions with provided item", () => {
33 const contextMenu = mount(<ContextMenu
34 anchorEl={document.createElement("div")}
36 {...{ actions, item }} />);
38 for (let index = 0; index < Object.keys(actions).length; index++) {
39 contextMenu.find(ListItem).at(index).simulate("click");
42 Object.keys(actions).forEach(key => {
43 expect(actions[key]).toHaveBeenCalledWith(item);