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 } from 'enzyme';
7 import * as Enzyme 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 Enzyme.configure({ adapter: new Adapter() });
18 describe("ProjectTree component", () => {
20 it("should render ListItemIcon", () => {
21 const project: TreeItem<Project> = {
24 createdAt: "2018-06-12",
25 modifiedAt: "2018-06-13",
27 ownerUuid: "ownerUuid",
35 const wrapper = mount(<ProjectTree projects={[project]} toggleProjectTreeItem={() => { }} />);
37 expect(wrapper.find(ListItemIcon)).toHaveLength(1);
40 it("should render 2 ListItemIcons", () => {
41 const project: Array<TreeItem<Project>> = [
45 createdAt: "2018-06-12",
46 modifiedAt: "2018-06-13",
48 ownerUuid: "ownerUuid",
59 createdAt: "2018-06-12",
60 modifiedAt: "2018-06-13",
62 ownerUuid: "ownerUuid",
71 const wrapper = mount(<ProjectTree projects={project} toggleProjectTreeItem={() => { }} />);
73 expect(wrapper.find(ListItemIcon)).toHaveLength(2);
76 it("should render Collapse", () => {
77 const project: Array<TreeItem<Project>> = [
81 createdAt: "2018-06-12",
82 modifiedAt: "2018-06-13",
84 ownerUuid: "ownerUuid",
95 createdAt: "2018-06-12",
96 modifiedAt: "2018-06-13",
98 ownerUuid: "ownerUuid",
109 const wrapper = mount(<ProjectTree projects={project} toggleProjectTreeItem={() => { }} />);
111 expect(wrapper.find(Collapse)).toHaveLength(1);
114 it("should render CircularProgress", () => {
115 const project: TreeItem<Project> = {
118 createdAt: "2018-06-12",
119 modifiedAt: "2018-06-13",
121 ownerUuid: "ownerUuid",
129 const wrapper = mount(<ProjectTree projects={[project]} toggleProjectTreeItem={() => { }} />);
131 expect(wrapper.find(CircularProgress)).toHaveLength(1);