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 } from "enzyme";
8 import * as Adapter from "enzyme-adapter-react-16";
9 import { Breadcrumbs } from "./breadcrumbs";
10 import { Button } from "@material-ui/core";
11 import ChevronRightIcon from '@material-ui/icons/ChevronRight';
13 configure({ adapter: new Adapter() });
15 describe("<Breadcrumbs />", () => {
17 let onClick: () => void;
23 it("renders one item", () => {
25 { label: 'breadcrumb 1' }
27 const breadcrumbs = mount(<Breadcrumbs items={items} onClick={onClick} onContextMenu={jest.fn()} />);
28 expect(breadcrumbs.find(Button)).toHaveLength(1);
29 expect(breadcrumbs.find(ChevronRightIcon)).toHaveLength(0);
32 it("renders multiple items", () => {
34 { label: 'breadcrumb 1' },
35 { label: 'breadcrumb 2' }
37 const breadcrumbs = mount(<Breadcrumbs items={items} onClick={onClick} onContextMenu={jest.fn()} />);
38 expect(breadcrumbs.find(Button)).toHaveLength(2);
39 expect(breadcrumbs.find(ChevronRightIcon)).toHaveLength(1);
42 it("calls onClick with clicked item", () => {
44 { label: 'breadcrumb 1' },
45 { label: 'breadcrumb 2' }
47 const breadcrumbs = mount(<Breadcrumbs items={items} onClick={onClick} onContextMenu={jest.fn()} />);
48 breadcrumbs.find(Button).at(1).simulate('click');
49 expect(onClick).toBeCalledWith(items[1]);