X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/77af50a44c54ef12a1d7abb59a0e4cba4284e77e..7ae86efd9905582df4191910528c3803a68ba81b:/src/components/data-table/data-table.test.tsx

diff --git a/src/components/data-table/data-table.test.tsx b/src/components/data-table/data-table.test.tsx
index b9d112520a..99ed2daffb 100644
--- a/src/components/data-table/data-table.test.tsx
+++ b/src/components/data-table/data-table.test.tsx
@@ -6,8 +6,9 @@ import * as React from "react";
 import { mount, configure } from "enzyme";
 import { TableHead, TableCell, Typography, TableBody, Button, TableSortLabel } from "@material-ui/core";
 import * as Adapter from "enzyme-adapter-react-16";
-import DataTable, { DataColumns } from "./data-table";
-import DataTableFilters from "../data-table-filters/data-table-filters";
+import { DataTable, DataColumns } from "./data-table";
+import { DataTableFilters } from "../data-table-filters/data-table-filters";
+import { SortDirection } from "./data-column";
 
 configure({ adapter: new Adapter() });
 
@@ -32,10 +33,11 @@ describe("<DataTable />", () => {
         ];
         const dataTable = mount(<DataTable
             columns={columns}
-            items={["item 1"]}
+            items={[{ key: "1", name: "item 1" }]}
             onFiltersChange={jest.fn()}
             onRowClick={jest.fn()}
-            onRowContextMenu={jest.fn()}
+            onRowDoubleClick={jest.fn()}
+            onContextMenu={jest.fn()}
             onSortToggle={jest.fn()} />);
         expect(dataTable.find(TableHead).find(TableCell)).toHaveLength(2);
     });
@@ -53,7 +55,8 @@ describe("<DataTable />", () => {
             items={["item 1"]}
             onFiltersChange={jest.fn()}
             onRowClick={jest.fn()}
-            onRowContextMenu={jest.fn()}
+            onRowDoubleClick={jest.fn()}
+            onContextMenu={jest.fn()}
             onSortToggle={jest.fn()} />);
         expect(dataTable.find(TableHead).find(TableCell).text()).toBe("Column 1");
     });
@@ -69,10 +72,11 @@ describe("<DataTable />", () => {
         ];
         const dataTable = mount(<DataTable
             columns={columns}
-            items={["item 1"]}
+            items={[]}
             onFiltersChange={jest.fn()}
             onRowClick={jest.fn()}
-            onRowContextMenu={jest.fn()}
+            onRowDoubleClick={jest.fn()}
+            onContextMenu={jest.fn()}
             onSortToggle={jest.fn()} />);
         expect(dataTable.find(TableHead).find(TableCell).text()).toBe("Column Header");
     });
@@ -91,7 +95,8 @@ describe("<DataTable />", () => {
             items={["item 1"]}
             onFiltersChange={jest.fn()}
             onRowClick={jest.fn()}
-            onRowContextMenu={jest.fn()}
+            onRowDoubleClick={jest.fn()}
+            onContextMenu={jest.fn()}
             onSortToggle={jest.fn()} />);
         expect(dataTable.find(TableHead).find(TableCell).key()).toBe("column-1-key");
         expect(dataTable.find(TableBody).find(TableCell).key()).toBe("column-1-key");
@@ -110,12 +115,13 @@ describe("<DataTable />", () => {
                 selected: true
             }
         ];
-        const dataTable = mount(<DataTable 
-            columns={columns} 
+        const dataTable = mount(<DataTable
+            columns={columns}
             items={["item 1"]}
             onFiltersChange={jest.fn()}
             onRowClick={jest.fn()}
-            onRowContextMenu={jest.fn()}
+            onRowDoubleClick={jest.fn()}
+            onContextMenu={jest.fn()}
             onSortToggle={jest.fn()} />);
         expect(dataTable.find(TableBody).find(Typography).text()).toBe("item 1");
         expect(dataTable.find(TableBody).find(Button).text()).toBe("item 1");
@@ -124,18 +130,19 @@ describe("<DataTable />", () => {
     it("passes sorting props to <TableSortLabel />", () => {
         const columns: DataColumns<string> = [{
             name: "Column 1",
-            sortDirection: "asc",
+            sortDirection: SortDirection.ASC,
             selected: true,
             render: (item) => <Typography>{item}</Typography>
         }];
         const onSortToggle = jest.fn();
-        const dataTable = mount(<DataTable 
-            columns={columns} 
-            items={["item 1"]} 
+        const dataTable = mount(<DataTable
+            columns={columns}
+            items={["item 1"]}
             onFiltersChange={jest.fn()}
             onRowClick={jest.fn()}
-            onRowContextMenu={jest.fn()}
-            onSortToggle={onSortToggle}/>);
+            onRowDoubleClick={jest.fn()}
+            onContextMenu={jest.fn()}
+            onSortToggle={onSortToggle} />);
         expect(dataTable.find(TableSortLabel).prop("active")).toBeTruthy();
         dataTable.find(TableSortLabel).at(0).simulate("click");
         expect(onSortToggle).toHaveBeenCalledWith(columns[0]);
@@ -144,23 +151,22 @@ describe("<DataTable />", () => {
     it("passes filter props to <DataTableFilter />", () => {
         const columns: DataColumns<string> = [{
             name: "Column 1",
-            sortDirection: "asc",
+            sortDirection: SortDirection.ASC,
             selected: true,
-            filters: [{name: "Filter 1", selected: true}],
+            filters: [{ name: "Filter 1", selected: true }],
             render: (item) => <Typography>{item}</Typography>
         }];
         const onFiltersChange = jest.fn();
-        const dataTable = mount(<DataTable 
-            columns={columns} 
-            items={["item 1"]} 
+        const dataTable = mount(<DataTable
+            columns={columns}
+            items={[]}
             onFiltersChange={onFiltersChange}
             onRowClick={jest.fn()}
-            onRowContextMenu={jest.fn()}
-            onSortToggle={jest.fn()}/>);
+            onRowDoubleClick={jest.fn()}
+            onSortToggle={jest.fn()}
+            onContextMenu={jest.fn()} />);
         expect(dataTable.find(DataTableFilters).prop("filters")).toBe(columns[0].filters);
         dataTable.find(DataTableFilters).prop("onChange")([]);
         expect(onFiltersChange).toHaveBeenCalledWith([], columns[0]);
     });
-
-
-});
\ No newline at end of file
+});
