X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/711d39ce13e6662e7823485f13a6e94a748cecf8..c26c98ff85da6a9ed2b946eae1d3484a3056bd10:/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 637a0cce..00931bf8 100644 --- a/src/store/data-explorer/data-explorer-middleware.test.ts +++ b/src/store/data-explorer/data-explorer-middleware.test.ts @@ -4,36 +4,16 @@ import { DataExplorerMiddlewareService } from "./data-explorer-middleware-service"; import { dataExplorerMiddleware } from "./data-explorer-middleware"; -import { MiddlewareAPI } from "../../../node_modules/redux"; -import { DataColumns } from "../../components/data-table/data-table"; +import { MiddlewareAPI } from "redux"; +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", () => { - it("initializes columns in the store", () => { - const config = { - id: "Id", - columns: [{ - name: "Column", - selected: true, - configurable: false, - render: jest.fn() - }], - requestItems: jest.fn(), - setApi: jest.fn() - }; - const service = new ServiceMock(config); - const api = { - getState: jest.fn(), - dispatch: jest.fn() - }; - const next = jest.fn(); - dataExplorerMiddleware(service)(api)(next); - expect(next) - .toHaveBeenCalledWith(dataExplorerActions.SET_COLUMNS({ id: service.getId(), columns: service.getColumns() })); - }); - it("handles only actions that are identified by service id", () => { const config = { id: "ServiceId", @@ -41,6 +21,8 @@ describe("DataExplorerMiddleware", () => { name: "Column", selected: true, configurable: false, + sortDirection: SortDirection.NONE, + filters: createTree(), render: jest.fn() }], requestItems: jest.fn(), @@ -67,6 +49,8 @@ describe("DataExplorerMiddleware", () => { name: "Column", selected: true, configurable: false, + sortDirection: SortDirection.NONE, + filters: createTree(), render: jest.fn() }], requestItems: jest.fn(), @@ -133,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); }); @@ -187,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); }); @@ -209,7 +193,7 @@ describe("DataExplorerMiddleware", () => { middleware(dataExplorerActions.SET_ITEMS({ id: service.getId(), items: [], rowsPerPage: 0, itemsAvailable: 0, page: 0 })); middleware(dataExplorerActions.TOGGLE_COLUMN({ id: service.getId(), columnName: "" })); expect(api.dispatch).toHaveBeenCalledTimes(0); - expect(next).toHaveBeenCalledTimes(4); + expect(next).toHaveBeenCalledTimes(3); }); }); @@ -218,8 +202,7 @@ class ServiceMock extends DataExplorerMiddlewareService { constructor(private config: { id: string, columns: DataColumns, - requestItems: (api: MiddlewareAPI) => void; - setApi: () => void; + requestItems: (api: MiddlewareAPI) => void }) { super(config.id); }