X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/2b3f667039ba2e7efe0852d58ae2c62899b773f0..d230941e87d4619683e4f3f7b44f19dab5017bd0:/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 d0b83b96..a72056d1 100644
--- a/src/components/data-table/data-table.test.tsx
+++ b/src/components/data-table/data-table.test.tsx
@@ -2,23 +2,22 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from "react";
+import React from "react";
 import { mount, configure } from "enzyme";
 import { pipe } from 'lodash/fp';
 import { TableHead, TableCell, Typography, TableBody, Button, TableSortLabel } from "@material-ui/core";
-import * as Adapter from "enzyme-adapter-react-16";
+import Adapter from "enzyme-adapter-react-16";
 import { DataTable, DataColumns } from "./data-table";
-import { DataTableFilters } from "~/components/data-table-filters/data-table-filters";
 import { SortDirection, createDataColumn } from "./data-column";
-import { DataTableFiltersPopover } from '~/components/data-table-filters/data-table-filters-popover';
-import { createTree, setNode, initTreeNode } from '~/models/tree';
-import { DataTableFilterItem } from "~/components/data-table-filters/data-table-filters-tree";
+import { DataTableFiltersPopover } from 'components/data-table-filters/data-table-filters-popover';
+import { createTree, setNode, initTreeNode } from 'models/tree';
+import { DataTableFilterItem } from "components/data-table-filters/data-table-filters-tree";
 
 configure({ adapter: new Adapter() });
 
 describe("<DataTable />", () => {
     it("shows only selected columns", () => {
-        const columns: DataColumns<string> = [
+        const columns: DataColumns<string, string> = [
             createDataColumn({
                 name: "Column 1",
                 render: () => <span />,
@@ -50,7 +49,7 @@ describe("<DataTable />", () => {
     });
 
     it("renders column name", () => {
-        const columns: DataColumns<string> = [
+        const columns: DataColumns<string, string> = [
             createDataColumn({
                 name: "Column 1",
                 render: () => <span />,
@@ -70,7 +69,7 @@ describe("<DataTable />", () => {
     });
 
     it("uses renderHeader instead of name prop", () => {
-        const columns: DataColumns<string> = [
+        const columns: DataColumns<string, string> = [
             createDataColumn({
                 name: "Column 1",
                 renderHeader: () => <span>Column Header</span>,
@@ -91,7 +90,7 @@ describe("<DataTable />", () => {
     });
 
     it("passes column key prop to corresponding cells", () => {
-        const columns: DataColumns<string> = [
+        const columns: DataColumns<string, string> = [
             createDataColumn({
                 name: "Column 1",
                 key: "column-1-key",
@@ -102,6 +101,7 @@ describe("<DataTable />", () => {
         ];
         const dataTable = mount(<DataTable
             columns={columns}
+            working={false}
             items={["item 1"]}
             onFiltersChange={jest.fn()}
             onRowClick={jest.fn()}
@@ -113,7 +113,7 @@ describe("<DataTable />", () => {
     });
 
     it("renders items", () => {
-        const columns: DataColumns<string> = [
+        const columns: DataColumns<string, string> = [
             createDataColumn({
                 name: "Column 1",
                 render: (item) => <Typography>{item}</Typography>,
@@ -129,6 +129,7 @@ describe("<DataTable />", () => {
         ];
         const dataTable = mount(<DataTable
             columns={columns}
+            working={false}
             items={["item 1"]}
             onFiltersChange={jest.fn()}
             onRowClick={jest.fn()}
@@ -140,10 +141,10 @@ describe("<DataTable />", () => {
     });
 
     it("passes sorting props to <TableSortLabel />", () => {
-        const columns: DataColumns<string> = [
+        const columns: DataColumns<string, string> = [
             createDataColumn({
                 name: "Column 1",
-                sortDirection: SortDirection.ASC,
+                sort: {direction: SortDirection.ASC, field: "length"},
                 selected: true,
                 configurable: true,
                 render: (item) => <Typography>{item}</Typography>
@@ -162,10 +163,9 @@ describe("<DataTable />", () => {
         expect(onSortToggle).toHaveBeenCalledWith(columns[0]);
     });
 
-    it("does not display <DataTableFilter /> if there is no filters provided", () => {
-        const columns: DataColumns<string> = [{
+    it("does not display <DataTableFiltersPopover /> if there is no filters provided", () => {
+        const columns: DataColumns<string, string> = [{
             name: "Column 1",
-            sortDirection: SortDirection.ASC,
             selected: true,
             configurable: true,
             filters: [],
@@ -180,7 +180,7 @@ describe("<DataTable />", () => {
             onRowDoubleClick={jest.fn()}
             onSortToggle={jest.fn()}
             onContextMenu={jest.fn()} />);
-        expect(dataTable.find(DataTableFilters)).toHaveLength(0);
+        expect(dataTable.find(DataTableFiltersPopover)).toHaveLength(0);
     });
 
     it("passes filter props to <DataTableFiltersPopover />", () => {
@@ -188,9 +188,8 @@ describe("<DataTable />", () => {
             () => createTree<DataTableFilterItem>(),
             setNode(initTreeNode({ id: 'filter', value: { name: 'filter' } }))
         );
-        const columns: DataColumns<string> = [{
+        const columns: DataColumns<string, string> = [{
             name: "Column 1",
-            sortDirection: SortDirection.ASC,
             selected: true,
             configurable: true,
             filters: filters(),
@@ -209,24 +208,4 @@ describe("<DataTable />", () => {
         dataTable.find(DataTableFiltersPopover).prop("onChange")([]);
         expect(onFiltersChange).toHaveBeenCalledWith([], columns[0]);
     });
-
-    // it("shows default view if there is no items", () => {
-    //     const columns: DataColumns<string> = [
-    //         createDataColumn({
-    //             name: "Column 1",
-    //             render: () => <span />,
-    //             selected: true,
-    //             configurable: true
-    //         }),
-    //     ];
-    //     const dataTable = mount(<DataTable
-    //         columns={columns}
-    //         items={[]}
-    //         onFiltersChange={jest.fn()}
-    //         onRowClick={jest.fn()}
-    //         onRowDoubleClick={jest.fn()}
-    //         onContextMenu={jest.fn()}
-    //         onSortToggle={jest.fn()} />);
-    //     expect(dataTable.find(DataTableDefaultView)).toHaveLength(1);
-    // });
 });
