X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/cc9505ee86539329d5ae0c4809aa293c54c2a25c..dd89200ad6fdbfa337fdbab5f54def8712c6746c:/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 eff49923..2be106cc 100644 --- a/src/components/data-explorer/data-explorer.test.tsx +++ b/src/components/data-explorer/data-explorer.test.tsx @@ -6,38 +6,21 @@ 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"; configure({ adapter: new Adapter() }); describe("", () => { - it("communicates with ", () => { - const onContextAction = jest.fn(); - const dataExplorer = mount(); - expect(dataExplorer.find(ContextMenu).prop("actions")).toEqual([]); - dataExplorer.find(DataTable).prop("onRowContextMenu")({ - preventDefault: 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 ", () => { const onSearch = jest.fn(); const dataExplorer = mount(); expect(dataExplorer.find(SearchInput).prop("value")).toEqual("search value"); @@ -47,13 +30,12 @@ describe("", () => { it("communicates with ", () => { 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(); + items={[{ name: "item 1" }]} />); expect(dataExplorer.find(ColumnSelector).prop("columns")).toBe(columns); dataExplorer.find(ColumnSelector).prop("onColumnToggle")("columns"); expect(onColumnToggle).toHaveBeenCalledWith("columns"); @@ -63,8 +45,8 @@ describe("", () => { const onFiltersChange = jest.fn(); const onSortToggle = jest.fn(); const onRowClick = jest.fn(); - const columns = [{ name: "Column 1", render: jest.fn(), selected: true }]; - const items = ["Item 1"]; + const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true }]; + const items = [{ name: "item 1" }]; const dataExplorer = mount(", () => { onFiltersChange={onFiltersChange} onSortToggle={onSortToggle} onRowClick={onRowClick} />); - expect(dataExplorer.find(DataTable).prop("columns")).toBe(columns); + expect(dataExplorer.find(DataTable).prop("columns").slice(0, -1)).toEqual(columns); expect(dataExplorer.find(DataTable).prop("items")).toBe(items); dataExplorer.find(DataTable).prop("onRowClick")("event", "rowClick"); dataExplorer.find(DataTable).prop("onFiltersChange")("filtersChange"); @@ -82,13 +64,11 @@ describe("", () => { expect(onRowClick).toHaveBeenCalledWith("rowClick"); }); - it("does not render , and if there is no items", () => { + it("does not render if there is no items", () => { const dataExplorer = mount(); - expect(dataExplorer.find(SearchInput)).toHaveLength(0); - expect(dataExplorer.find(ColumnSelector)).toHaveLength(0); expect(dataExplorer.find(TablePagination)).toHaveLength(0); }); @@ -97,7 +77,7 @@ describe("", () => { const onChangeRowsPerPage = jest.fn(); const dataExplorer = mount(", () => { const mockDataExplorerProps = () => ({ columns: [], items: [], + itemsAvailable: 0, contextActions: [], searchValue: "", page: 0, rowsPerPage: 0, + rowsPerPageOptions: [], onSearch: jest.fn(), onFiltersChange: jest.fn(), onSortToggle: jest.fn(), onRowClick: jest.fn(), + onRowDoubleClick: jest.fn(), onColumnToggle: jest.fn(), - onContextAction: jest.fn(), onChangePage: jest.fn(), - onChangeRowsPerPage: jest.fn() -}); \ No newline at end of file + onChangeRowsPerPage: jest.fn(), + onContextMenu: jest.fn() +});