X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/616395646c46f90c46ad97bd9a335ab326e5a040..d4068786fd7136cfe21c3ef3ad3040f57ed3385a:/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 0eb3c321..d26d768a 100644
--- a/src/store/data-explorer/data-explorer-reducer.test.tsx
+++ b/src/store/data-explorer/data-explorer-reducer.test.tsx
@@ -2,37 +2,45 @@
 //
 // 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', () => {
         const columns: DataColumns<any> = [{
             name: "Column 1",
+            filters: [],
             render: jest.fn(),
-            selected: true
+            selected: true,
+            configurable: true,
+            sortDirection: SortDirection.NONE
         }];
         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: DataColumns<any> = [{
             name: "Column 1",
+            filters: [],
             render: jest.fn(),
             selected: true,
-            sortDirection: "asc"
+            sortDirection: SortDirection.ASC,
+            configurable: true
         }, {
             name: "Column 2",
+            filters: [],
             render: jest.fn(),
             selected: true,
-            sortDirection: "none",
+            configurable: true,
+            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");
     });
@@ -40,8 +48,11 @@ describe('data-explorer-reducer', () => {
     it('should set filters', () => {
         const columns: DataColumns<any> = [{
             name: "Column 1",
+            filters: [],
             render: jest.fn(),
             selected: true,
+            configurable: true,
+            sortDirection: SortDirection.NONE
         }];
 
         const filters: DataTableFilterItem[] = [{
@@ -49,25 +60,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"] }));
+        const state = dataExplorerReducer({},
+            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 }));
+        const state = dataExplorerReducer({},
+            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 }));
+        const state = dataExplorerReducer({},
+            dataExplorerActions.SET_ROWS_PER_PAGE({ id: "Data explorer", rowsPerPage: 5 }));
         expect(state["Data explorer"].rowsPerPage).toEqual(5);
     });
 });
