18169: Fixed upload cancelation on a single file
[arvados.git] / src / components / breadcrumbs / breadcrumbs.test.tsx
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 { configure, shallow } from "enzyme";
7
8 import 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';
12
13 configure({ adapter: new Adapter() });
14
15 describe("<Breadcrumbs />", () => {
16
17     let onClick: () => void;
18
19     beforeEach(() => {
20         onClick = jest.fn();
21     });
22
23     it("renders one item", () => {
24         const items = [
25             { label: 'breadcrumb 1' }
26         ];
27         const breadcrumbs = shallow(<Breadcrumbs items={items} onClick={onClick} onContextMenu={jest.fn()} />).dive();
28         expect(breadcrumbs.find(Button)).toHaveLength(1);
29         expect(breadcrumbs.find(ChevronRightIcon)).toHaveLength(0);
30     });
31
32     it("renders multiple items", () => {
33         const items = [
34             { label: 'breadcrumb 1' },
35             { label: 'breadcrumb 2' }
36         ];
37         const breadcrumbs = shallow(<Breadcrumbs items={items} onClick={onClick} onContextMenu={jest.fn()} />).dive();
38         expect(breadcrumbs.find(Button)).toHaveLength(2);
39         expect(breadcrumbs.find(ChevronRightIcon)).toHaveLength(1);
40     });
41
42     it("calls onClick with clicked item", () => {
43         const items = [
44             { label: 'breadcrumb 1' },
45             { label: 'breadcrumb 2' }
46         ];
47         const breadcrumbs = shallow(<Breadcrumbs items={items} onClick={onClick} onContextMenu={jest.fn()} />).dive();
48         breadcrumbs.find(Button).at(1).simulate('click');
49         expect(onClick).toBeCalledWith(items[1]);
50     });
51
52 });