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() });
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}
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()}
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();
});
const mockDataExplorerProps = () => ({
+ fetchMode: DataTableFetchMode.PAGINATED,
columns: [],
items: [],
itemsAvailable: 0,
onContextMenu: jest.fn(),
defaultIcon: ProjectIcon,
onSetColumns: jest.fn(),
+ onLoadMore: jest.fn(),
defaultMessages: ['testing'],
contextMenuColumn: true
});