X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/c11055f2d6ce8385088bc221eab1175e31777ec0..0ecbcbd790d784e72f2e7c90fc6a417b79acd022:/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 a34ab1c8..1d8738ab 100644 --- a/src/components/data-explorer/data-explorer.test.tsx +++ b/src/components/data-explorer/data-explorer.test.tsx @@ -8,11 +8,11 @@ import * as 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() }); @@ -20,11 +20,13 @@ describe("", () => { it("communicates with ", () => { const onSearch = jest.fn(); + const onSetColumns = jest.fn(); const dataExplorer = mount(); + onSearch={onSearch} + onSetColumns={onSetColumns} />); expect(dataExplorer.find(SearchInput).prop("value")).toEqual("search value"); dataExplorer.find(SearchInput).prop("onSearch")("new value"); expect(onSearch).toHaveBeenCalledWith("new value"); @@ -32,12 +34,14 @@ describe("", () => { it("communicates with ", () => { const onColumnToggle = jest.fn(); - const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true }]; + const onSetColumns = jest.fn(); + const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true, sortDirection: SortDirection.ASC, filters: {} }]; const dataExplorer = mount(); + items={[{ name: "item 1" }]} + onSetColumns={onSetColumns} />); expect(dataExplorer.find(ColumnSelector).prop("columns")).toBe(columns); dataExplorer.find(ColumnSelector).prop("onColumnToggle")("columns"); expect(onColumnToggle).toHaveBeenCalledWith("columns"); @@ -47,7 +51,8 @@ describe("", () => { const onFiltersChange = jest.fn(); const onSortToggle = jest.fn(); const onRowClick = jest.fn(); - const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true }]; + const onSetColumns = jest.fn(); + const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true, sortDirection: SortDirection.ASC, filters: {} }]; const items = [{ name: "item 1" }]; const dataExplorer = mount(", () => { items={items} onFiltersChange={onFiltersChange} onSortToggle={onSortToggle} - onRowClick={onRowClick} />); + onRowClick={onRowClick} + onSetColumns={onSetColumns} />); 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"); @@ -66,18 +72,10 @@ describe("", () => { expect(onRowClick).toHaveBeenCalledWith("rowClick"); }); - it("does not render if there is no items", () => { - const dataExplorer = mount(); - expect(dataExplorer.find(DataTable)).toHaveLength(0); - expect(dataExplorer.find(DefaultView)).toHaveLength(1); - }); - it("communicates with ", () => { const onChangePage = jest.fn(); const onChangeRowsPerPage = jest.fn(); + const onSetColumns = jest.fn(); const dataExplorer = mount(", () => { rowsPerPage={50} onChangePage={onChangePage} onChangeRowsPerPage={onChangeRowsPerPage} - />); + onSetColumns={onSetColumns} />); expect(dataExplorer.find(TablePagination).prop("page")).toEqual(10); expect(dataExplorer.find(TablePagination).prop("rowsPerPage")).toEqual(50); dataExplorer.find(TablePagination).prop("onChangePage")(undefined, 6); @@ -96,6 +94,7 @@ describe("", () => { }); const mockDataExplorerProps = () => ({ + fetchMode: DataTableFetchMode.PAGINATED, columns: [], items: [], itemsAvailable: 0, @@ -114,5 +113,8 @@ const mockDataExplorerProps = () => ({ onChangeRowsPerPage: jest.fn(), onContextMenu: jest.fn(), defaultIcon: ProjectIcon, + onSetColumns: jest.fn(), + onLoadMore: jest.fn(), defaultMessages: ['testing'], + contextMenuColumn: true });