X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/75b209b2cbd37e3510fd726e737fa5457a6a8d77..a1e2b8ba77e4a7273940a3fc542bc42e282618a7:/src/views-components/project-tree/project-tree.test.tsx

diff --git a/src/views-components/project-tree/project-tree.test.tsx b/src/views-components/project-tree/project-tree.test.tsx
index 1ba3abb8bb..18efdaf88d 100644
--- a/src/views-components/project-tree/project-tree.test.tsx
+++ b/src/views-components/project-tree/project-tree.test.tsx
@@ -3,136 +3,80 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { mount } from 'enzyme';
 import * as Enzyme from 'enzyme';
+import { mount } from 'enzyme';
 import * as Adapter from 'enzyme-adapter-react-16';
 import ListItemIcon from '@material-ui/core/ListItemIcon';
 import { Collapse } from '@material-ui/core';
 import CircularProgress from '@material-ui/core/CircularProgress';
 
-import ProjectTree from './project-tree';
-import { TreeItem } from '../../components/tree/tree';
-import { Project } from '../../models/project';
+import { ProjectTree } from './project-tree';
+import { TreeItem, TreeItemStatus } from '../../components/tree/tree';
+import { ProjectResource } from '../../models/project';
+import { mockProjectResource } from '../../models/test-utils';
+
 Enzyme.configure({ adapter: new Adapter() });
 
 describe("ProjectTree component", () => {
 
     it("should render ListItemIcon", () => {
-        const project: TreeItem<Project> = {
-            data: {
-                name: "sample name",
-                createdAt: "2018-06-12",
-                modifiedAt: "2018-06-13",
-                uuid: "uuid",
-                ownerUuid: "ownerUuid",
-                href: "href",
-                kind: 'example'
-            },
+        const project: TreeItem<ProjectResource> = {
+            data: mockProjectResource(),
             id: "3",
             open: true,
             active: true,
-            status: 1
+            status: TreeItemStatus.PENDING
         };
-        const wrapper = mount(<ProjectTree projects={[project]} toggleOpen={jest.fn()} toggleActive={jest.fn()} />);
-
-        expect(wrapper.find(ListItemIcon)).toHaveLength(1);
-    });
-
-    it("should render 2 ListItemIcons", () => {
-        const project: Array<TreeItem<Project>> = [
-            {
-                data: {
-                    name: "sample name",
-                    createdAt: "2018-06-12",
-                    modifiedAt: "2018-06-13",
-                    uuid: "uuid",
-                    ownerUuid: "ownerUuid",
-                    href: "href",
-                    kind: 'example'
-                },
-                id: "3",
-                open: false,
-                active: true,
-                status: 1
-            },
-            {
-                data: {
-                    name: "sample name",
-                    createdAt: "2018-06-12",
-                    modifiedAt: "2018-06-13",
-                    uuid: "uuid",
-                    ownerUuid: "ownerUuid",
-                    href: "href",
-                    kind: 'example'
-                },
-                id: "3",
-                open: false,
-                active: true,
-                status: 1
-            }
-        ];
-        const wrapper = mount(<ProjectTree projects={project} toggleOpen={jest.fn()} toggleActive={jest.fn()} />);
+        const wrapper = mount(<ProjectTree
+            projects={[project]}
+            toggleOpen={jest.fn()}
+            toggleActive={jest.fn()}
+            onContextMenu={jest.fn()} />);
 
         expect(wrapper.find(ListItemIcon)).toHaveLength(2);
     });
 
     it("should render Collapse", () => {
-        const project: Array<TreeItem<Project>> = [
+        const project: Array<TreeItem<ProjectResource>> = [
             {
-                data: {
-                    name: "sample name",
-                    createdAt: "2018-06-12",
-                    modifiedAt: "2018-06-13",
-                    uuid: "uuid",
-                    ownerUuid: "ownerUuid",
-                    href: "href",
-                    kind: 'example'
-                },
+                data: mockProjectResource(),
                 id: "3",
                 open: true,
                 active: true,
-                status: 2,
+                status: TreeItemStatus.LOADED,
                 items: [
                     {
-                        data: {
-                            name: "sample name",
-                            createdAt: "2018-06-12",
-                            modifiedAt: "2018-06-13",
-                            uuid: "uuid",
-                            ownerUuid: "ownerUuid",
-                            href: "href",
-                            kind: 'example'
-                        },
+                        data: mockProjectResource(),
                         id: "3",
                         open: true,
                         active: true,
-                        status: 1
+                        status: TreeItemStatus.PENDING
                     }
                 ]
             }
         ];
-        const wrapper = mount(<ProjectTree projects={project} toggleOpen={jest.fn()} toggleActive={jest.fn()}/>);
+        const wrapper = mount(<ProjectTree
+            projects={project}
+            toggleOpen={jest.fn()}
+            toggleActive={jest.fn()}
+            onContextMenu={jest.fn()} />);
 
         expect(wrapper.find(Collapse)).toHaveLength(1);
     });
 
     it("should render CircularProgress", () => {
-        const project: TreeItem<Project> = {
-            data: {
-                name: "sample name",
-                createdAt: "2018-06-12",
-                modifiedAt: "2018-06-13",
-                uuid: "uuid",
-                ownerUuid: "ownerUuid",
-                href: "href",
-                kind: 'example'
-            },
+        const project: TreeItem<ProjectResource> = {
+            data: mockProjectResource(),
             id: "3",
             open: false,
             active: true,
-            status: 1
+            status: TreeItemStatus.PENDING
         };
-        const wrapper = mount(<ProjectTree projects={[project]} toggleOpen={jest.fn()} toggleActive={jest.fn()} />);
+        const wrapper = mount(<ProjectTree
+            projects={[project]}
+            toggleOpen={jest.fn()}
+            toggleActive={jest.fn()}
+            onContextMenu={jest.fn()} />);
 
         expect(wrapper.find(CircularProgress)).toHaveLength(1);
     });
