X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/75b209b2cbd37e3510fd726e737fa5457a6a8d77..c0afd448c39a41d229612afe47643aed7a2cf5dd:/src/store/data-explorer/data-explorer-reducer.test.tsx diff --git a/src/store/data-explorer/data-explorer-reducer.test.tsx b/src/store/data-explorer/data-explorer-reducer.test.tsx index 2a9e56ce3f..c54a86af4a 100644 --- a/src/store/data-explorer/data-explorer-reducer.test.tsx +++ b/src/store/data-explorer/data-explorer-reducer.test.tsx @@ -2,43 +2,44 @@ // // SPDX-License-Identifier: AGPL-3.0 -import dataExplorerReducer, { initialDataExplorer } from "./data-explorer-reducer"; -import actions from "./data-explorer-action"; -import { DataColumn } from "../../components/data-table/data-column"; +import { dataExplorerReducer, initialDataExplorer } from "./data-explorer-reducer"; +import { dataExplorerActions } from "./data-explorer-action"; import { DataTableFilterItem } from "../../components/data-table-filters/data-table-filters"; +import { DataColumns } from "../../components/data-table/data-table"; +import { SortDirection } from "../../components/data-table/data-column"; describe('data-explorer-reducer', () => { it('should set columns', () => { - const columns: Array> = [{ + const columns: DataColumns = [{ name: "Column 1", render: jest.fn(), selected: true }]; const state = dataExplorerReducer(undefined, - actions.SET_COLUMNS({ id: "Data explorer", columns })); + dataExplorerActions.SET_COLUMNS({ id: "Data explorer", columns })); expect(state["Data explorer"].columns).toEqual(columns); }); it('should toggle sorting', () => { - const columns: Array> = [{ + const columns: DataColumns = [{ name: "Column 1", render: jest.fn(), selected: true, - sortDirection: "asc" + sortDirection: SortDirection.ASC }, { name: "Column 2", render: jest.fn(), selected: true, - sortDirection: "none", + sortDirection: SortDirection.NONE, }]; const state = dataExplorerReducer({ "Data explorer": { ...initialDataExplorer, columns } }, - actions.TOGGLE_SORT({ id: "Data explorer", columnName: "Column 2" })); + dataExplorerActions.TOGGLE_SORT({ id: "Data explorer", columnName: "Column 2" })); expect(state["Data explorer"].columns[0].sortDirection).toEqual("none"); expect(state["Data explorer"].columns[1].sortDirection).toEqual("asc"); }); it('should set filters', () => { - const columns: Array> = [{ + const columns: DataColumns = [{ name: "Column 1", render: jest.fn(), selected: true, @@ -49,25 +50,31 @@ describe('data-explorer-reducer', () => { selected: true }]; const state = dataExplorerReducer({ "Data explorer": { ...initialDataExplorer, columns } }, - actions.SET_FILTERS({ id: "Data explorer", columnName: "Column 1", filters })); + dataExplorerActions.SET_FILTERS({ id: "Data explorer", columnName: "Column 1", filters })); expect(state["Data explorer"].columns[0].filters).toEqual(filters); }); it('should set items', () => { const state = dataExplorerReducer({ "Data explorer": undefined }, - actions.SET_ITEMS({ id: "Data explorer", items: ["Item 1", "Item 2"] })); + dataExplorerActions.SET_ITEMS({ + id: "Data explorer", + items: ["Item 1", "Item 2"], + page: 0, + rowsPerPage: 10, + itemsAvailable: 100 + })); expect(state["Data explorer"].items).toEqual(["Item 1", "Item 2"]); }); it('should set page', () => { const state = dataExplorerReducer({ "Data explorer": undefined }, - actions.SET_PAGE({ id: "Data explorer", page: 2 })); + dataExplorerActions.SET_PAGE({ id: "Data explorer", page: 2 })); expect(state["Data explorer"].page).toEqual(2); }); - + it('should set rows per page', () => { const state = dataExplorerReducer({ "Data explorer": undefined }, - actions.SET_ROWS_PER_PAGE({ id: "Data explorer", rowsPerPage: 5 })); + dataExplorerActions.SET_ROWS_PER_PAGE({ id: "Data explorer", rowsPerPage: 5 })); expect(state["Data explorer"].rowsPerPage).toEqual(5); }); });