15768: cleanup before sort/refresh fix Arvados-DCO-1.1-Signed-off-by: Lisa Knox...
[arvados-workbench2.git] / src / components / data-table / data-table.test.tsx
index 5e591ffcf22c6fd32fdd144e812fb6b7de6d3a7c..a72056d142aa110b09a43ffe0b82784d7a389e24 100644 (file)
@@ -2,11 +2,11 @@
 //
 // 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 { SortDirection, createDataColumn } from "./data-column";
 import { DataTableFiltersPopover } from 'components/data-table-filters/data-table-filters-popover';
@@ -17,7 +17,7 @@ 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 />,
@@ -49,7 +49,7 @@ describe("<DataTable />", () => {
     });
 
     it("renders column name", () => {
-        const columns: DataColumns<string> = [
+        const columns: DataColumns<string, string> = [
             createDataColumn({
                 name: "Column 1",
                 render: () => <span />,
@@ -69,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>,
@@ -90,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",
@@ -101,6 +101,7 @@ describe("<DataTable />", () => {
         ];
         const dataTable = mount(<DataTable
             columns={columns}
+            working={false}
             items={["item 1"]}
             onFiltersChange={jest.fn()}
             onRowClick={jest.fn()}
@@ -112,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>,
@@ -128,6 +129,7 @@ describe("<DataTable />", () => {
         ];
         const dataTable = mount(<DataTable
             columns={columns}
+            working={false}
             items={["item 1"]}
             onFiltersChange={jest.fn()}
             onRowClick={jest.fn()}
@@ -139,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,9 +164,8 @@ describe("<DataTable />", () => {
     });
 
     it("does not display <DataTableFiltersPopover /> if there is no filters provided", () => {
-        const columns: DataColumns<string> = [{
+        const columns: DataColumns<string, string> = [{
             name: "Column 1",
-            sortDirection: SortDirection.ASC,
             selected: true,
             configurable: true,
             filters: [],
@@ -187,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(),