X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/5be1434f78d6dbcf2949918f7f042cab994ab0c5..47e0dc87fa82bac593c53518e556ba7c55410288:/src/views-components/project-tree/project-tree.test.tsx?ds=inline

diff --git a/src/views-components/project-tree/project-tree.test.tsx b/src/views-components/project-tree/project-tree.test.tsx
index 1a5e9f9d..56566da6 100644
--- a/src/views-components/project-tree/project-tree.test.tsx
+++ b/src/views-components/project-tree/project-tree.test.tsx
@@ -10,101 +10,69 @@ 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 { ProjectTree } from './project-tree';
 import { TreeItem } from '../../components/tree/tree';
-import { Project } from '../../models/project';
-import { ResourceKind } from "../../models/resource";
+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: ResourceKind.PROJECT
-            },
+        const project: TreeItem<ProjectResource> = {
+            data: mockProjectResource(),
             id: "3",
             open: true,
             active: true,
             status: 1
         };
-        const wrapper = mount(<ProjectTree projects={[project]} onContextMenu={jest.fn()} 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(1);
     });
 
     it("should render 2 ListItemIcons", () => {
-        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: ResourceKind.PROJECT
-                },
+                data: mockProjectResource(),
                 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: ResourceKind.PROJECT
-                },
+                data: mockProjectResource(),
                 id: "3",
                 open: false,
                 active: true,
                 status: 1
             }
         ];
-        const wrapper = mount(<ProjectTree projects={project} onContextMenu={jest.fn()} 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: ResourceKind.PROJECT
-                },
+                data: mockProjectResource(),
                 id: "3",
                 open: true,
                 active: true,
                 status: 2,
                 items: [
                     {
-                        data: {
-                            name: "sample name",
-                            createdAt: "2018-06-12",
-                            modifiedAt: "2018-06-13",
-                            uuid: "uuid",
-                            ownerUuid: "ownerUuid",
-                            href: "href",
-                            kind: ResourceKind.PROJECT
-                        },
+                        data: mockProjectResource(),
                         id: "3",
                         open: true,
                         active: true,
@@ -113,28 +81,28 @@ describe("ProjectTree component", () => {
                 ]
             }
         ];
-        const wrapper = mount(<ProjectTree projects={project} onContextMenu={jest.fn()} 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: ResourceKind.PROJECT
-            },
+        const project: TreeItem<ProjectResource> = {
+            data: mockProjectResource(),
             id: "3",
             open: false,
             active: true,
             status: 1
         };
-        const wrapper = mount(<ProjectTree projects={[project]} onContextMenu={jest.fn()} 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);
     });
