projects
/
arvados-workbench2.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
refs #master Merge branch 'origin/master' into 14280-query-language
[arvados-workbench2.git]
/
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 616a9c122e751cdf72746b4e58838c6d6c3d41ca..d74b5319d789b743bfa6878bd6e359839cdbe16d 100644
(file)
--- a/
src/components/data-explorer/data-explorer.test.tsx
+++ b/
src/components/data-explorer/data-explorer.test.tsx
@@
-11,6
+11,9
@@
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 { DataTable } 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() });
configure({ adapter: new Adapter() });
@@
-18,11
+21,13
@@
describe("<DataExplorer />", () => {
it("communicates with <SearchInput/>", () => {
const onSearch = jest.fn();
it("communicates with <SearchInput/>", () => {
const onSearch = jest.fn();
+ const onSetColumns = jest.fn();
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
items={[{ name: "item 1" }]}
searchValue="search value"
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
items={[{ name: "item 1" }]}
searchValue="search value"
- onSearch={onSearch} />);
+ 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");
expect(dataExplorer.find(SearchInput).prop("value")).toEqual("search value");
dataExplorer.find(SearchInput).prop("onSearch")("new value");
expect(onSearch).toHaveBeenCalledWith("new value");
@@
-30,12
+35,14
@@
describe("<DataExplorer />", () => {
it("communicates with <ColumnSelector/>", () => {
const onColumnToggle = jest.fn();
it("communicates with <ColumnSelector/>", () => {
const onColumnToggle = jest.fn();
- const columns = [{ name: "Column 1", render: jest.fn(), selected: true }];
+ const onSetColumns = jest.fn();
+ const columns = [{ name: "Column 1", render: jest.fn(), selected: true, configurable: true, sortDirection: SortDirection.ASC, filters: [] }];
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
columns={columns}
onColumnToggle={onColumnToggle}
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
columns={columns}
onColumnToggle={onColumnToggle}
- items={[{ name: "item 1" }]} />);
+ items={[{ name: "item 1" }]}
+ onSetColumns={onSetColumns} />);
expect(dataExplorer.find(ColumnSelector).prop("columns")).toBe(columns);
dataExplorer.find(ColumnSelector).prop("onColumnToggle")("columns");
expect(onColumnToggle).toHaveBeenCalledWith("columns");
expect(dataExplorer.find(ColumnSelector).prop("columns")).toBe(columns);
dataExplorer.find(ColumnSelector).prop("onColumnToggle")("columns");
expect(onColumnToggle).toHaveBeenCalledWith("columns");
@@
-45,7
+52,8
@@
describe("<DataExplorer />", () => {
const onFiltersChange = jest.fn();
const onSortToggle = jest.fn();
const onRowClick = jest.fn();
const onFiltersChange = jest.fn();
const onSortToggle = jest.fn();
const onRowClick = jest.fn();
- const columns = [{ name: "Column 1", render: jest.fn(), selected: 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(<DataExplorer
{...mockDataExplorerProps()}
const items = [{ name: "item 1" }];
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
@@
-53,7
+61,8
@@
describe("<DataExplorer />", () => {
items={items}
onFiltersChange={onFiltersChange}
onSortToggle={onSortToggle}
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");
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");
@@
-64,17
+73,10
@@
describe("<DataExplorer />", () => {
expect(onRowClick).toHaveBeenCalledWith("rowClick");
});
expect(onRowClick).toHaveBeenCalledWith("rowClick");
});
- it("does not render <TablePagination/> if there is no items", () => {
- const dataExplorer = mount(<DataExplorer
- {...mockDataExplorerProps()}
- items={[]}
- />);
- expect(dataExplorer.find(TablePagination)).toHaveLength(0);
- });
-
it("communicates with <TablePagination/>", () => {
const onChangePage = jest.fn();
const onChangeRowsPerPage = jest.fn();
it("communicates with <TablePagination/>", () => {
const onChangePage = jest.fn();
const onChangeRowsPerPage = jest.fn();
+ const onSetColumns = jest.fn();
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
items={[{ name: "item 1" }]}
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
items={[{ name: "item 1" }]}
@@
-82,7
+84,7
@@
describe("<DataExplorer />", () => {
rowsPerPage={50}
onChangePage={onChangePage}
onChangeRowsPerPage={onChangeRowsPerPage}
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);
expect(dataExplorer.find(TablePagination).prop("page")).toEqual(10);
expect(dataExplorer.find(TablePagination).prop("rowsPerPage")).toEqual(50);
dataExplorer.find(TablePagination).prop("onChangePage")(undefined, 6);
@@
-100,6
+102,7
@@
const mockDataExplorerProps = () => ({
searchValue: "",
page: 0,
rowsPerPage: 0,
searchValue: "",
page: 0,
rowsPerPage: 0,
+ rowsPerPageOptions: [0],
onSearch: jest.fn(),
onFiltersChange: jest.fn(),
onSortToggle: jest.fn(),
onSearch: jest.fn(),
onFiltersChange: jest.fn(),
onSortToggle: jest.fn(),
@@
-108,5
+111,9
@@
const mockDataExplorerProps = () => ({
onColumnToggle: jest.fn(),
onChangePage: jest.fn(),
onChangeRowsPerPage: jest.fn(),
onColumnToggle: jest.fn(),
onChangePage: jest.fn(),
onChangeRowsPerPage: jest.fn(),
- onContextMenu: jest.fn()
+ onContextMenu: jest.fn(),
+ defaultIcon: ProjectIcon,
+ onSetColumns: jest.fn(),
+ defaultMessages: ['testing'],
+ contextMenuColumn: true
});
});