X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f0d519637c997df11d5b1a1b32b3d9e4a2872325..25d64433dff3ffcf083c2cedd8d849de49a691d1:/src/store/data-explorer/data-explorer-middleware.test.ts diff --git a/src/store/data-explorer/data-explorer-middleware.test.ts b/src/store/data-explorer/data-explorer-middleware.test.ts index d93ccbf4..ef6cfe42 100644 --- a/src/store/data-explorer/data-explorer-middleware.test.ts +++ b/src/store/data-explorer/data-explorer-middleware.test.ts @@ -5,8 +5,11 @@ import { DataExplorerMiddlewareService } from "./data-explorer-middleware-service"; import { dataExplorerMiddleware } from "./data-explorer-middleware"; import { MiddlewareAPI } from "redux"; -import { DataColumns } from "~/components/data-table/data-table"; +import { DataColumns } from "components/data-table/data-table"; import { dataExplorerActions } from "./data-explorer-action"; +import { SortDirection } from "components/data-table/data-column"; +import { createTree } from 'models/tree'; +import { DataTableFilterItem } from "components/data-table-filters/data-table-filters-tree"; describe("DataExplorerMiddleware", () => { @@ -18,6 +21,8 @@ describe("DataExplorerMiddleware", () => { name: "Column", selected: true, configurable: false, + sortDirection: SortDirection.NONE, + filters: createTree(), render: jest.fn() }], requestItems: jest.fn(), @@ -33,7 +38,7 @@ describe("DataExplorerMiddleware", () => { middleware(dataExplorerActions.SET_PAGE({ id: "OtherId", page: 0 })); middleware(dataExplorerActions.SET_PAGE({ id: "ServiceId", page: 0 })); middleware(dataExplorerActions.SET_PAGE({ id: "OtherId", page: 0 })); - expect(api.dispatch).toHaveBeenCalledWith(dataExplorerActions.REQUEST_ITEMS({ id: "ServiceId" })); + expect(api.dispatch).toHaveBeenCalledWith(dataExplorerActions.REQUEST_ITEMS({ id: "ServiceId", criteriaChanged: false })); expect(api.dispatch).toHaveBeenCalledTimes(1); }); @@ -44,6 +49,8 @@ describe("DataExplorerMiddleware", () => { name: "Column", selected: true, configurable: false, + sortDirection: SortDirection.NONE, + filters: createTree(), render: jest.fn() }], requestItems: jest.fn(), @@ -57,7 +64,7 @@ describe("DataExplorerMiddleware", () => { const next = jest.fn(); const middleware = dataExplorerMiddleware(service)(api)(next); middleware(dataExplorerActions.REQUEST_ITEMS({ id: "ServiceId" })); - expect(config.requestItems).toHaveBeenCalled(); + expect(api.dispatch).toHaveBeenCalledTimes(1); }); it("handles SET_PAGE action", () => { @@ -110,7 +117,7 @@ describe("DataExplorerMiddleware", () => { }; const next = jest.fn(); const middleware = dataExplorerMiddleware(service)(api)(next); - middleware(dataExplorerActions.SET_FILTERS({ id: service.getId(), columnName: "", filters: [] })); + middleware(dataExplorerActions.SET_FILTERS({ id: service.getId(), columnName: "", filters: createTree() })); expect(api.dispatch).toHaveBeenCalledTimes(2); }); @@ -164,7 +171,7 @@ describe("DataExplorerMiddleware", () => { }; const next = jest.fn(); const middleware = dataExplorerMiddleware(service)(api)(next); - middleware(dataExplorerActions.SET_SEARCH_VALUE({ id: service.getId(), searchValue: "" })); + middleware(dataExplorerActions.SET_EXPLORER_SEARCH_VALUE({ id: service.getId(), searchValue: "" })); expect(api.dispatch).toHaveBeenCalledTimes(2); }); @@ -195,7 +202,7 @@ class ServiceMock extends DataExplorerMiddlewareService { constructor(private config: { id: string, columns: DataColumns, - requestItems: (api: MiddlewareAPI) => void + requestItems: (api: MiddlewareAPI) => Promise }) { super(config.id); } @@ -204,7 +211,8 @@ class ServiceMock extends DataExplorerMiddlewareService { return this.config.columns; } - requestItems(api: MiddlewareAPI) { + requestItems(api: MiddlewareAPI): Promise { this.config.requestItems(api); + return Promise.resolve(); } }