[ARVADOS-WORKBENCH2] updated: 1.1.4-208-g9ab26fe
Git user
git at public.curoverse.com
Thu Jul 5 09:30:22 EDT 2018
Summary of changes:
.../data-explorer/data-explorer.test.tsx | 15 ++---
src/components/data-table/data-table.test.tsx | 65 ++++++++++++----------
2 files changed, 43 insertions(+), 37 deletions(-)
via 9ab26fe1f0838a97818416bd6b833fc74968ed65 (commit)
from 5c513f2c78337482da4cc6055706fd022c26c007 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 9ab26fe1f0838a97818416bd6b833fc74968ed65
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Thu Jul 5 15:30:11 2018 +0200
Update existing tests to work with latest changes
Feature #13703
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/components/data-explorer/data-explorer.test.tsx b/src/components/data-explorer/data-explorer.test.tsx
index 94c7be6..33899c0 100644
--- a/src/components/data-explorer/data-explorer.test.tsx
+++ b/src/components/data-explorer/data-explorer.test.tsx
@@ -12,6 +12,7 @@ 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";
configure({ adapter: new Adapter() });
@@ -23,7 +24,7 @@ describe("<DataExplorer />", () => {
{...mockDataExplorerProps()}
contextActions={[]}
onContextAction={onContextAction}
- items={["Item 1"]}
+ 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")({
@@ -38,7 +39,7 @@ describe("<DataExplorer />", () => {
const onSearch = jest.fn();
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
- items={["item 1"]}
+ items={[{ key: "1", name: "item 1" }] as MockItem[]}
searchValue="search value"
onSearch={onSearch} />);
expect(dataExplorer.find(SearchInput).prop("value")).toEqual("search value");
@@ -54,7 +55,7 @@ describe("<DataExplorer />", () => {
columns={columns}
onColumnToggle={onColumnToggle}
contextActions={[]}
- items={["Item 1"]} />);
+ items={[{ key: "1", name: "item 1" }] as MockItem[]} />);
expect(dataExplorer.find(ColumnSelector).prop("columns")).toBe(columns);
dataExplorer.find(ColumnSelector).prop("onColumnToggle")("columns");
expect(onColumnToggle).toHaveBeenCalledWith("columns");
@@ -65,7 +66,7 @@ describe("<DataExplorer />", () => {
const onSortToggle = jest.fn();
const onRowClick = jest.fn();
const columns = [{ name: "Column 1", render: jest.fn(), selected: true }];
- const items = ["Item 1"];
+ const items = [{ key: "1", name: "item 1" }] as MockItem[];
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
columns={columns}
@@ -83,12 +84,11 @@ describe("<DataExplorer />", () => {
expect(onRowClick).toHaveBeenCalledWith("rowClick");
});
- it("does not render <SearchInput/>, <ColumnSelector/> and <TablePagination/> if there is no items", () => {
+ it("does not render <TablePagination/> if there is no items", () => {
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
items={[]}
/>);
- expect(dataExplorer.find(SearchInput)).toHaveLength(0);
expect(dataExplorer.find(TablePagination)).toHaveLength(0);
});
@@ -97,7 +97,7 @@ describe("<DataExplorer />", () => {
const onChangeRowsPerPage = jest.fn();
const dataExplorer = mount(<DataExplorer
{...mockDataExplorerProps()}
- items={["Item 1"]}
+ items={[{ key: "1", name: "item 1" }] as MockItem[]}
page={10}
rowsPerPage={50}
onChangePage={onChangePage}
@@ -115,6 +115,7 @@ describe("<DataExplorer />", () => {
const mockDataExplorerProps = () => ({
columns: [],
items: [],
+ itemsAvailable: 0,
contextActions: [],
searchValue: "",
page: 0,
diff --git a/src/components/data-table/data-table.test.tsx b/src/components/data-table/data-table.test.tsx
index b9d1125..6dbccb5 100644
--- a/src/components/data-table/data-table.test.tsx
+++ b/src/components/data-table/data-table.test.tsx
@@ -6,14 +6,19 @@ import * as React from "react";
import { mount, configure } from "enzyme";
import { TableHead, TableCell, Typography, TableBody, Button, TableSortLabel } from "@material-ui/core";
import * as Adapter from "enzyme-adapter-react-16";
-import DataTable, { DataColumns } from "./data-table";
+import DataTable, { DataColumns, DataItem } from "./data-table";
import DataTableFilters from "../data-table-filters/data-table-filters";
+import { SortDirection } from "./data-column";
configure({ adapter: new Adapter() });
+export interface MockItem extends DataItem {
+ name: string;
+}
+
describe("<DataTable />", () => {
it("shows only selected columns", () => {
- const columns: DataColumns<string> = [
+ const columns: DataColumns<MockItem> = [
{
name: "Column 1",
render: () => <span />,
@@ -32,7 +37,7 @@ describe("<DataTable />", () => {
];
const dataTable = mount(<DataTable
columns={columns}
- items={["item 1"]}
+ items={[{ key: "1", name: "item 1" }] as MockItem[]}
onFiltersChange={jest.fn()}
onRowClick={jest.fn()}
onRowContextMenu={jest.fn()}
@@ -41,7 +46,7 @@ describe("<DataTable />", () => {
});
it("renders column name", () => {
- const columns: DataColumns<string> = [
+ const columns: DataColumns<MockItem> = [
{
name: "Column 1",
render: () => <span />,
@@ -50,7 +55,7 @@ describe("<DataTable />", () => {
];
const dataTable = mount(<DataTable
columns={columns}
- items={["item 1"]}
+ items={[{ key: "1", name: "item 1" }] as MockItem[]}
onFiltersChange={jest.fn()}
onRowClick={jest.fn()}
onRowContextMenu={jest.fn()}
@@ -59,7 +64,7 @@ describe("<DataTable />", () => {
});
it("uses renderHeader instead of name prop", () => {
- const columns: DataColumns<string> = [
+ const columns: DataColumns<MockItem> = [
{
name: "Column 1",
renderHeader: () => <span>Column Header</span>,
@@ -69,7 +74,7 @@ describe("<DataTable />", () => {
];
const dataTable = mount(<DataTable
columns={columns}
- items={["item 1"]}
+ items={[{ key: "1", name: "item 1" }] as MockItem[]}
onFiltersChange={jest.fn()}
onRowClick={jest.fn()}
onRowContextMenu={jest.fn()}
@@ -78,7 +83,7 @@ describe("<DataTable />", () => {
});
it("passes column key prop to corresponding cells", () => {
- const columns: DataColumns<string> = [
+ const columns: DataColumns<MockItem> = [
{
name: "Column 1",
key: "column-1-key",
@@ -88,7 +93,7 @@ describe("<DataTable />", () => {
];
const dataTable = mount(<DataTable
columns={columns}
- items={["item 1"]}
+ items={[{ key: "1", name: "item 1" }] as MockItem[]}
onFiltersChange={jest.fn()}
onRowClick={jest.fn()}
onRowContextMenu={jest.fn()}
@@ -98,21 +103,21 @@ describe("<DataTable />", () => {
});
it("renders items", () => {
- const columns: DataColumns<string> = [
+ const columns: DataColumns<MockItem> = [
{
name: "Column 1",
- render: (item) => <Typography>{item}</Typography>,
+ render: (item) => <Typography>{item.name}</Typography>,
selected: true
},
{
name: "Column 2",
- render: (item) => <Button>{item}</Button>,
+ render: (item) => <Button>{item.name}</Button>,
selected: true
}
];
- const dataTable = mount(<DataTable
- columns={columns}
- items={["item 1"]}
+ const dataTable = mount(<DataTable
+ columns={columns}
+ items={[{ key: "1", name: "item 1" }] as MockItem[]}
onFiltersChange={jest.fn()}
onRowClick={jest.fn()}
onRowContextMenu={jest.fn()}
@@ -122,41 +127,41 @@ describe("<DataTable />", () => {
});
it("passes sorting props to <TableSortLabel />", () => {
- const columns: DataColumns<string> = [{
+ const columns: DataColumns<MockItem> = [{
name: "Column 1",
- sortDirection: "asc",
+ sortDirection: SortDirection.Asc,
selected: true,
- render: (item) => <Typography>{item}</Typography>
+ render: (item) => <Typography>{item.name}</Typography>
}];
const onSortToggle = jest.fn();
- const dataTable = mount(<DataTable
- columns={columns}
- items={["item 1"]}
+ const dataTable = mount(<DataTable
+ columns={columns}
+ items={[{ key: "1", name: "item 1" }] as MockItem[]}
onFiltersChange={jest.fn()}
onRowClick={jest.fn()}
onRowContextMenu={jest.fn()}
- onSortToggle={onSortToggle}/>);
+ onSortToggle={onSortToggle} />);
expect(dataTable.find(TableSortLabel).prop("active")).toBeTruthy();
dataTable.find(TableSortLabel).at(0).simulate("click");
expect(onSortToggle).toHaveBeenCalledWith(columns[0]);
});
it("passes filter props to <DataTableFilter />", () => {
- const columns: DataColumns<string> = [{
+ const columns: DataColumns<MockItem> = [{
name: "Column 1",
- sortDirection: "asc",
+ sortDirection: SortDirection.Asc,
selected: true,
- filters: [{name: "Filter 1", selected: true}],
- render: (item) => <Typography>{item}</Typography>
+ filters: [{ name: "Filter 1", selected: true }],
+ render: (item) => <Typography>{item.name}</Typography>
}];
const onFiltersChange = jest.fn();
- const dataTable = mount(<DataTable
- columns={columns}
- items={["item 1"]}
+ const dataTable = mount(<DataTable
+ columns={columns}
+ items={[{ key: "1", name: "item 1" }] as MockItem[]}
onFiltersChange={onFiltersChange}
onRowClick={jest.fn()}
onRowContextMenu={jest.fn()}
- onSortToggle={jest.fn()}/>);
+ onSortToggle={jest.fn()} />);
expect(dataTable.find(DataTableFilters).prop("filters")).toBe(columns[0].filters);
dataTable.find(DataTableFilters).prop("onChange")([]);
expect(onFiltersChange).toHaveBeenCalledWith([], columns[0]);
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list