X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/e8d0331277033fea37a9fd73ffc781ffca8759f0..c1787278642d2ef02234ea27f94aaae9cdd52d40:/src/components/data-explorer/data-explorer.test.tsx

diff --git a/src/components/data-explorer/data-explorer.test.tsx b/src/components/data-explorer/data-explorer.test.tsx
index 97b1bec6..a34ab1c8 100644
--- a/src/components/data-explorer/data-explorer.test.tsx
+++ b/src/components/data-explorer/data-explorer.test.tsx
@@ -6,38 +6,23 @@ import * as React from "react";
 import { configure, mount } from "enzyme";
 import * as Adapter from 'enzyme-adapter-react-16';
 
-import DataExplorer from "./data-explorer";
-import ContextMenu from "../context-menu/context-menu";
-import ColumnSelector from "../column-selector/column-selector";
-import DataTable from "../data-table/data-table";
-import SearchInput from "../search-input/search-input";
+import { DataExplorer } from "./data-explorer";
+import { ColumnSelector } from "../column-selector/column-selector";
+import { DataTable } from "../data-table/data-table";
+import { SearchInput } from "../search-input/search-input";
 import { TablePagination } from "@material-ui/core";
-import { MockItem } from "../data-table/data-table.test";
+import { ProjectIcon } from '../icon/icon';
+import { DefaultView } from '../default-view/default-view';
 
 configure({ adapter: new Adapter() });
 
 describe("<DataExplorer />", () => {
 
-    it("communicates with <ContextMenu/>", () => {
-        const onContextAction = jest.fn();
-        const dataExplorer = mount(<DataExplorer
-            {...mockDataExplorerProps()}
-            items={[{ key: "1", name: "item 1" }] as MockItem[]}
-            columns={[{ name: "Column 1", render: jest.fn(), selected: true }]} />);
-        expect(dataExplorer.find(ContextMenu).prop("actions")).toEqual([]);
-        dataExplorer.find(DataTable).prop("onRowContextMenu")({
-            preventDefault: jest.fn(),
-            stopPropagation: jest.fn()
-        }, "Item 1");
-        dataExplorer.find(ContextMenu).prop("onActionClick")({ name: "Action 1", icon: "" });
-        expect(onContextAction).toHaveBeenCalledWith({ name: "Action 1", icon: "" }, "Item 1");
-    });
-
     it("communicates with <SearchInput/>", () => {
         const onSearch = jest.fn();
         const dataExplorer = mount(<DataExplorer
             {...mockDataExplorerProps()}
-            items={[{ key: "1", name: "item 1" }] as MockItem[]}
+            items={[{ name: "item 1" }]}
             searchValue="search value"
             onSearch={onSearch} />);
         expect(dataExplorer.find(SearchInput).prop("value")).toEqual("search value");
@@ -47,12 +32,12 @@ describe("<DataExplorer />", () => {
 
     it("communicates with <ColumnSelector/>", () => {
         const onColumnToggle = jest.fn();
-        const columns = [{ name: "Column 1", render: jest.fn(), selected: true }];
+        const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true }];
         const dataExplorer = mount(<DataExplorer
             {...mockDataExplorerProps()}
             columns={columns}
             onColumnToggle={onColumnToggle}
-            items={[{ key: "1", name: "item 1" }] as MockItem[]} />);
+            items={[{ name: "item 1" }]} />);
         expect(dataExplorer.find(ColumnSelector).prop("columns")).toBe(columns);
         dataExplorer.find(ColumnSelector).prop("onColumnToggle")("columns");
         expect(onColumnToggle).toHaveBeenCalledWith("columns");
@@ -62,8 +47,8 @@ describe("<DataExplorer />", () => {
         const onFiltersChange = jest.fn();
         const onSortToggle = jest.fn();
         const onRowClick = jest.fn();
-        const columns = [{ name: "Column 1", render: jest.fn(), selected: true }];
-        const items = [{ key: "1", name: "item 1" }] as MockItem[];
+        const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true }];
+        const items = [{ name: "item 1" }];
         const dataExplorer = mount(<DataExplorer
             {...mockDataExplorerProps()}
             columns={columns}
@@ -81,12 +66,13 @@ describe("<DataExplorer />", () => {
         expect(onRowClick).toHaveBeenCalledWith("rowClick");
     });
 
-    it("does not render <TablePagination/> if there is no items", () => {
+    it("does not render <DataTable/> if there is no items", () => {
         const dataExplorer = mount(<DataExplorer
             {...mockDataExplorerProps()}
             items={[]}
         />);
-        expect(dataExplorer.find(TablePagination)).toHaveLength(0);
+        expect(dataExplorer.find(DataTable)).toHaveLength(0);
+        expect(dataExplorer.find(DefaultView)).toHaveLength(1);
     });
 
     it("communicates with <TablePagination/>", () => {
@@ -94,7 +80,7 @@ describe("<DataExplorer />", () => {
         const onChangeRowsPerPage = jest.fn();
         const dataExplorer = mount(<DataExplorer
             {...mockDataExplorerProps()}
-            items={[{ key: "1", name: "item 1" }] as MockItem[]}
+            items={[{ name: "item 1" }]}
             page={10}
             rowsPerPage={50}
             onChangePage={onChangePage}
@@ -117,12 +103,16 @@ const mockDataExplorerProps = () => ({
     searchValue: "",
     page: 0,
     rowsPerPage: 0,
+    rowsPerPageOptions: [0],
     onSearch: jest.fn(),
     onFiltersChange: jest.fn(),
     onSortToggle: jest.fn(),
     onRowClick: jest.fn(),
+    onRowDoubleClick: jest.fn(),
     onColumnToggle: jest.fn(),
     onChangePage: jest.fn(),
     onChangeRowsPerPage: jest.fn(),
-    onContextMenu: jest.fn()
-});
\ No newline at end of file
+    onContextMenu: jest.fn(),
+    defaultIcon: ProjectIcon,
+    defaultMessages: ['testing'],
+});
