1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
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';
13 import ProjectTree from './project-tree';
14 import { TreeItem } from '../../components/tree/tree';
15 import { Project } from '../../models/project';
16 import { ResourceKind } from "../../models/resource";
18 Enzyme.configure({ adapter: new Adapter() });
20 describe("ProjectTree component", () => {
22 it("should render ListItemIcon", () => {
23 const project: TreeItem<Project> = {
26 createdAt: "2018-06-12",
27 modifiedAt: "2018-06-13",
29 ownerUuid: "ownerUuid",
31 kind: ResourceKind.PROJECT
38 const wrapper = mount(<ProjectTree projects={[project]} toggleOpen={jest.fn()} toggleActive={jest.fn()} />);
40 expect(wrapper.find(ListItemIcon)).toHaveLength(1);
43 it("should render 2 ListItemIcons", () => {
44 const project: Array<TreeItem<Project>> = [
48 createdAt: "2018-06-12",
49 modifiedAt: "2018-06-13",
51 ownerUuid: "ownerUuid",
53 kind: ResourceKind.PROJECT
63 createdAt: "2018-06-12",
64 modifiedAt: "2018-06-13",
66 ownerUuid: "ownerUuid",
68 kind: ResourceKind.PROJECT
76 const wrapper = mount(<ProjectTree projects={project} toggleOpen={jest.fn()} toggleActive={jest.fn()} />);
78 expect(wrapper.find(ListItemIcon)).toHaveLength(2);
81 it("should render Collapse", () => {
82 const project: Array<TreeItem<Project>> = [
86 createdAt: "2018-06-12",
87 modifiedAt: "2018-06-13",
89 ownerUuid: "ownerUuid",
91 kind: ResourceKind.PROJECT
101 createdAt: "2018-06-12",
102 modifiedAt: "2018-06-13",
104 ownerUuid: "ownerUuid",
106 kind: ResourceKind.PROJECT
116 const wrapper = mount(<ProjectTree projects={project} toggleOpen={jest.fn()} toggleActive={jest.fn()}/>);
118 expect(wrapper.find(Collapse)).toHaveLength(1);
121 it("should render CircularProgress", () => {
122 const project: TreeItem<Project> = {
125 createdAt: "2018-06-12",
126 modifiedAt: "2018-06-13",
128 ownerUuid: "ownerUuid",
130 kind: ResourceKind.PROJECT
137 const wrapper = mount(<ProjectTree projects={[project]} toggleOpen={jest.fn()} toggleActive={jest.fn()} />);
139 expect(wrapper.find(CircularProgress)).toHaveLength(1);