X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/616395646c46f90c46ad97bd9a335ab326e5a040..c0afd448c39a41d229612afe47643aed7a2cf5dd:/src/store/data-explorer/data-explorer-reducer.test.tsx?ds=sidebyside diff --git a/src/store/data-explorer/data-explorer-reducer.test.tsx b/src/store/data-explorer/data-explorer-reducer.test.tsx index 0eb3c321a3..c54a86af4a 100644 --- a/src/store/data-explorer/data-explorer-reducer.test.tsx +++ b/src/store/data-explorer/data-explorer-reducer.test.tsx @@ -2,10 +2,11 @@ // // SPDX-License-Identifier: AGPL-3.0 -import dataExplorerReducer, { initialDataExplorer } from "./data-explorer-reducer"; -import actions from "./data-explorer-action"; +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', () => { @@ -15,7 +16,7 @@ describe('data-explorer-reducer', () => { 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); }); @@ -24,15 +25,15 @@ describe('data-explorer-reducer', () => { 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"); }); @@ -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); }); });