temp-icons
[arvados.git] / src / views-components / project-tree / project-tree.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 * as Enzyme from 'enzyme';
7 import { mount } from 'enzyme';
8 import * as Adapter from 'enzyme-adapter-react-16';
9 import ListItemIcon from '@material-ui/core/ListItemIcon';
10 import { Collapse } from '@material-ui/core';
11 import CircularProgress from '@material-ui/core/CircularProgress';
12
13 import { ProjectTree } from './project-tree';
14 import { TreeItem, TreeItemStatus } from '../../components/tree/tree';
15 import { ProjectResource } from '../../models/project';
16 import { mockProjectResource } from '../../models/test-utils';
17
18 Enzyme.configure({ adapter: new Adapter() });
19
20 describe("ProjectTree component", () => {
21
22     it("should render ListItemIcon", () => {
23         const project: TreeItem<ProjectResource> = {
24             data: mockProjectResource(),
25             id: "3",
26             open: true,
27             active: true,
28             status: TreeItemStatus.PENDING
29         };
30         const wrapper = mount(<ProjectTree
31             projects={[project]}
32             toggleOpen={jest.fn()}
33             toggleActive={jest.fn()}
34             onContextMenu={jest.fn()} />);
35
36         expect(wrapper.find(ListItemIcon)).toHaveLength(2);
37     });
38
39     it("should render Collapse", () => {
40         const project: Array<TreeItem<ProjectResource>> = [
41             {
42                 data: mockProjectResource(),
43                 id: "3",
44                 open: true,
45                 active: true,
46                 status: TreeItemStatus.LOADED,
47                 items: [
48                     {
49                         data: mockProjectResource(),
50                         id: "3",
51                         open: true,
52                         active: true,
53                         status: TreeItemStatus.PENDING
54                     }
55                 ]
56             }
57         ];
58         const wrapper = mount(<ProjectTree
59             projects={project}
60             toggleOpen={jest.fn()}
61             toggleActive={jest.fn()}
62             onContextMenu={jest.fn()} />);
63
64         expect(wrapper.find(Collapse)).toHaveLength(1);
65     });
66
67     it("should render CircularProgress", () => {
68         const project: TreeItem<ProjectResource> = {
69             data: mockProjectResource(),
70             id: "3",
71             open: false,
72             active: true,
73             status: TreeItemStatus.PENDING
74         };
75         const wrapper = mount(<ProjectTree
76             projects={[project]}
77             toggleOpen={jest.fn()}
78             toggleActive={jest.fn()}
79             onContextMenu={jest.fn()} />);
80
81         expect(wrapper.find(CircularProgress)).toHaveLength(1);
82     });
83 });