X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/876e5e2f31a218255845977489ea70aacc0211cd..02fa1acae263e5cf28e95a36801cb578be941307:/src/components/data-table/data-table.test.tsx
diff --git a/src/components/data-table/data-table.test.tsx b/src/components/data-table/data-table.test.tsx
index 77c7825b..1201dcb0 100644
--- a/src/components/data-table/data-table.test.tsx
+++ b/src/components/data-table/data-table.test.tsx
@@ -8,31 +8,31 @@ import { TableHead, TableCell, Typography, TableBody, Button, TableSortLabel } f
import * as Adapter from "enzyme-adapter-react-16";
import { DataTable, DataColumns } from "./data-table";
import { DataTableFilters } from "../data-table-filters/data-table-filters";
-import { SortDirection } from "./data-column";
+import { SortDirection, createDataColumn } from "./data-column";
configure({ adapter: new Adapter() });
describe("", () => {
it("shows only selected columns", () => {
const columns: DataColumns = [
- {
+ createDataColumn({
name: "Column 1",
render: () => ,
selected: true,
configurable: true
- },
- {
+ }),
+ createDataColumn({
name: "Column 2",
render: () => ,
selected: true,
configurable: true
- },
- {
+ }),
+ createDataColumn({
name: "Column 3",
render: () => ,
selected: false,
configurable: true
- }
+ }),
];
const dataTable = mount(", () => {
it("renders column name", () => {
const columns: DataColumns = [
- {
+ createDataColumn({
name: "Column 1",
render: () => ,
selected: true,
configurable: true
- }
+ }),
];
const dataTable = mount(", () => {
it("uses renderHeader instead of name prop", () => {
const columns: DataColumns = [
- {
+ createDataColumn({
name: "Column 1",
renderHeader: () => Column Header,
render: () => ,
selected: true,
configurable: true
- }
+ }),
];
const dataTable = mount(", () => {
it("passes column key prop to corresponding cells", () => {
const columns: DataColumns = [
- {
+ createDataColumn({
name: "Column 1",
key: "column-1-key",
render: () => ,
selected: true,
configurable: true
- }
+ })
];
const dataTable = mount(", () => {
it("renders items", () => {
const columns: DataColumns = [
- {
+ createDataColumn({
name: "Column 1",
render: (item) => {item},
selected: true,
configurable: true
- },
- {
+ }),
+ createDataColumn({
name: "Column 2",
render: (item) => ,
selected: true,
configurable: true
- }
+ })
];
const dataTable = mount(", () => {
});
it("passes sorting props to ", () => {
- const columns: DataColumns = [{
+ const columns: DataColumns = [
+ createDataColumn({
name: "Column 1",
sortDirection: SortDirection.ASC,
selected: true,
configurable: true,
render: (item) => {item}
- }];
+ })];
const onSortToggle = jest.fn();
const dataTable = mount(", () => {
expect(onSortToggle).toHaveBeenCalledWith(columns[0]);
});
+ it("does not display if there is no filters provided", () => {
+ const columns: DataColumns = [{
+ name: "Column 1",
+ sortDirection: SortDirection.ASC,
+ selected: true,
+ configurable: true,
+ filters: [],
+ render: (item) => {item}
+ }];
+ const onFiltersChange = jest.fn();
+ const dataTable = mount();
+ expect(dataTable.find(DataTableFilters)).toHaveLength(0);
+ });
+
it("passes filter props to ", () => {
const columns: DataColumns = [{
name: "Column 1",