refs #master Merge branch 'origin/master' into 13856-upload-component
[arvados.git] / src / store / data-explorer / data-explorer-reducer.test.tsx
index 0eb3c321a3e107e49fb43af4f2c267e16648f81c..c54a86af4aa6a44559d5b7f41624ac483ea6cd2b 100644 (file)
@@ -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);
     });
 });