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 { ProjectResource } from '../../models/project';
16 import { mockProjectResource } from '../../models/test-utils';
18 Enzyme.configure({ adapter: new Adapter() });
20 describe("ProjectTree component", () => {
22 it("should render ListItemIcon", () => {
23 const project: TreeItem<ProjectResource> = {
24 data: mockProjectResource(),
30 const wrapper = mount(<ProjectTree
32 toggleOpen={jest.fn()}
33 toggleActive={jest.fn()}
34 onContextMenu={jest.fn()} />);
36 expect(wrapper.find(ListItemIcon)).toHaveLength(1);
39 it("should render 2 ListItemIcons", () => {
40 const project: Array<TreeItem<ProjectResource>> = [
42 data: mockProjectResource(),
49 data: mockProjectResource(),
56 const wrapper = mount(<ProjectTree
58 toggleOpen={jest.fn()}
59 toggleActive={jest.fn()}
60 onContextMenu={jest.fn()} />);
62 expect(wrapper.find(ListItemIcon)).toHaveLength(2);
65 it("should render Collapse", () => {
66 const project: Array<TreeItem<ProjectResource>> = [
68 data: mockProjectResource(),
75 data: mockProjectResource(),
84 const wrapper = mount(<ProjectTree
86 toggleOpen={jest.fn()}
87 toggleActive={jest.fn()}
88 onContextMenu={jest.fn()} />);
90 expect(wrapper.find(Collapse)).toHaveLength(1);
93 it("should render CircularProgress", () => {
94 const project: TreeItem<ProjectResource> = {
95 data: mockProjectResource(),
101 const wrapper = mount(<ProjectTree
103 toggleOpen={jest.fn()}
104 toggleActive={jest.fn()}
105 onContextMenu={jest.fn()} />);
107 expect(wrapper.find(CircularProgress)).toHaveLength(1);