Add typescript paths to top level folders
[arvados-workbench2.git] / src / components / dropdown-menu / dropdown-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 { shallow, configure } from "enzyme";
7 import { DropdownMenu } from "./dropdown-menu";
8 import * as Adapter from 'enzyme-adapter-react-16';
9 import { MenuItem, IconButton, Menu } from "@material-ui/core";
10 import { PaginationRightArrowIcon } from "../icon/icon";
11
12 configure({ adapter: new Adapter() });
13
14 describe("<DropdownMenu />", () => {
15     it("renders menu icon", () => {
16         const dropdownMenu = shallow(<DropdownMenu id="test-menu" icon={<PaginationRightArrowIcon />} />);
17         expect(dropdownMenu.find(PaginationRightArrowIcon)).toHaveLength(1);
18     });
19
20     it("render menu items", () => {
21         const dropdownMenu = shallow(
22             <DropdownMenu id="test-menu" icon={<PaginationRightArrowIcon />}>
23                 <MenuItem>Item 1</MenuItem>
24                 <MenuItem>Item 2</MenuItem>
25             </DropdownMenu>
26         );
27         expect(dropdownMenu.find(MenuItem)).toHaveLength(2);
28     });
29
30     it("opens on menu icon click", () => {
31         const dropdownMenu = shallow(<DropdownMenu id="test-menu" icon={<PaginationRightArrowIcon />} />);
32         dropdownMenu.find(IconButton).simulate("click", {currentTarget: {}});
33         expect((dropdownMenu.state() as any).anchorEl).toBeDefined();
34     });
35
36     it("closes on menu click", () => {
37         const dropdownMenu = shallow(<DropdownMenu id="test-menu" icon={<PaginationRightArrowIcon />} />);
38         dropdownMenu.find(Menu).simulate("click", {currentTarget: {}});
39         expect((dropdownMenu.state() as any).anchorEl).toBeUndefined();
40     });
41
42 });