]> git.arvados.org - arvados.git/blob - services/workbench2/src/components/context-menu/context-menu.cy.js
Merge branch '22130-no-wb-fed-login' refs #22130
[arvados.git] / services / workbench2 / src / components / context-menu / context-menu.cy.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from "react";
6 import { ContextMenu } from "./context-menu";
7 import { ShareIcon } from "../icon/icon";
8
9 describe("<ContextMenu />", () => {
10     const items = [[{
11         icon: ShareIcon,
12         name: "Action 1.1"
13     }, {
14         icon: ShareIcon,
15         name: "Action 1.2"
16     },], [{
17         icon: ShareIcon,
18         name: "Action 2.1"
19     }]];
20
21     it("calls onItemClick with clicked action", () => {
22         const onItemClick = cy.spy().as("onItemClick")
23         cy.mount(<ContextMenu
24             anchorEl={document.createElement("div")}
25             open={true}
26             onClose={cy.stub()}
27             onItemClick={onItemClick}
28             items={items} />);
29         cy.get('div[role=button]').eq(2).click();
30         cy.get('@onItemClick').should('have.been.calledWith', items[1][0]);
31     });
32 });