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, TreeItemStatus } 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(),
28 status: TreeItemStatus.PENDING
30 const wrapper = mount(<ProjectTree
32 toggleOpen={jest.fn()}
33 toggleActive={jest.fn()}
34 onContextMenu={jest.fn()} />);
36 expect(wrapper.find(ListItemIcon)).toHaveLength(2);
39 it("should render Collapse", () => {
40 const project: Array<TreeItem<ProjectResource>> = [
42 data: mockProjectResource(),
46 status: TreeItemStatus.LOADED,
49 data: mockProjectResource(),
53 status: TreeItemStatus.PENDING
58 const wrapper = mount(<ProjectTree
60 toggleOpen={jest.fn()}
61 toggleActive={jest.fn()}
62 onContextMenu={jest.fn()} />);
64 expect(wrapper.find(Collapse)).toHaveLength(1);
67 it("should render CircularProgress", () => {
68 const project: TreeItem<ProjectResource> = {
69 data: mockProjectResource(),
73 status: TreeItemStatus.PENDING
75 const wrapper = mount(<ProjectTree
77 toggleOpen={jest.fn()}
78 toggleActive={jest.fn()}
79 onContextMenu={jest.fn()} />);
81 expect(wrapper.find(CircularProgress)).toHaveLength(1);