17782: Fixes almost all tests (4 left) mostly by fixing namespace-type imports.
[arvados-workbench2.git] / src / components / data-explorer / data-explorer.test.tsx
index 3e447b4015480091b66e6ee39f5b6d5560ea6cc6..dc7e8725793524b57bf7cfb76aadd5c466577274 100644 (file)
@@ -2,17 +2,16 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from "react";
+import React from "react";
 import { configure, mount } from "enzyme";
-import * as Adapter from 'enzyme-adapter-react-16';
+import Adapter from 'enzyme-adapter-react-16';
 
 import { DataExplorer } from "./data-explorer";
 import { ColumnSelector } from "../column-selector/column-selector";
-import { DataTable } from "../data-table/data-table";
+import { DataTable, DataTableFetchMode } from "../data-table/data-table";
 import { SearchInput } from "../search-input/search-input";
 import { TablePagination } from "@material-ui/core";
 import { ProjectIcon } from '../icon/icon';
-import { DefaultView } from '../default-view/default-view';
 import { SortDirection } from '../data-table/data-column';
 
 configure({ adapter: new Adapter() });
@@ -36,7 +35,7 @@ describe("<DataExplorer />", () => {
     it("communicates with <ColumnSelector/>", () => {
         const onColumnToggle = jest.fn();
         const onSetColumns = jest.fn();
-        const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true, sortDirection: SortDirection.ASC, filters: [] }];
+        const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true, sortDirection: SortDirection.ASC, filters: {} }];
         const dataExplorer = mount(<DataExplorer
             {...mockDataExplorerProps()}
             columns={columns}
@@ -53,7 +52,7 @@ describe("<DataExplorer />", () => {
         const onSortToggle = jest.fn();
         const onRowClick = jest.fn();
         const onSetColumns = jest.fn();
-        const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true, sortDirection: SortDirection.ASC, filters: [] }];
+        const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true, sortDirection: SortDirection.ASC, filters: {} }];
         const items = [{ name: "item 1" }];
         const dataExplorer = mount(<DataExplorer
             {...mockDataExplorerProps()}
@@ -73,15 +72,6 @@ describe("<DataExplorer />", () => {
         expect(onRowClick).toHaveBeenCalledWith("rowClick");
     });
 
-    it("does not render <DataTable/> if there is no items", () => {
-        const dataExplorer = mount(<DataExplorer
-            {...mockDataExplorerProps()}
-            items={[]}
-            onSetColumns={jest.fn()} />);
-        expect(dataExplorer.find(DataTable)).toHaveLength(0);
-        expect(dataExplorer.find(DefaultView)).toHaveLength(1);
-    });
-
     it("communicates with <TablePagination/>", () => {
         const onChangePage = jest.fn();
         const onChangeRowsPerPage = jest.fn();
@@ -104,6 +94,7 @@ describe("<DataExplorer />", () => {
 });
 
 const mockDataExplorerProps = () => ({
+    fetchMode: DataTableFetchMode.PAGINATED,
     columns: [],
     items: [],
     itemsAvailable: 0,
@@ -123,5 +114,7 @@ const mockDataExplorerProps = () => ({
     onContextMenu: jest.fn(),
     defaultIcon: ProjectIcon,
     onSetColumns: jest.fn(),
+    onLoadMore: jest.fn(),
     defaultMessages: ['testing'],
+    contextMenuColumn: true
 });