orc-shared 5.10.0-dev.2 → 5.10.0-dev.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/metadata.js +30 -11
- package/dist/actions/requestsApi.js +10 -1
- package/dist/components/AppFrame/About.js +136 -100
- package/dist/components/AppFrame/Anchor.js +45 -21
- package/dist/components/AppFrame/AppFrame.js +53 -31
- package/dist/components/AppFrame/Help.js +35 -15
- package/dist/components/AppFrame/MenuItem.js +148 -114
- package/dist/components/AppFrame/Preferences.js +136 -97
- package/dist/components/AppFrame/Sidebar.js +51 -28
- package/dist/components/AppFrame/Topbar.js +61 -36
- package/dist/components/ColumnWrapper.js +28 -5
- package/dist/components/Culture.js +33 -14
- package/dist/components/DropMenu/Menu.js +79 -45
- package/dist/components/DropMenu/index.js +34 -29
- package/dist/components/Form/Combination.js +45 -16
- package/dist/components/Form/Field.js +57 -38
- package/dist/components/Form/FieldElements.js +0 -11
- package/dist/components/Form/Fieldset.js +47 -19
- package/dist/components/Form/Form.js +22 -9
- package/dist/components/Form/FormElement.js +40 -7
- package/dist/components/Form/Inputs/Button.js +63 -18
- package/dist/components/Form/Inputs/ReadOnly.js +50 -27
- package/dist/components/{AppFrame/ApplicationSelector/Header.js → Form/Inputs/Selector.js} +30 -31
- package/dist/components/Form/Inputs/Text.js +20 -37
- package/dist/components/Form/Inputs/Toggles.js +39 -40
- package/dist/components/Form/Inputs/index.js +2 -13
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +31 -11
- package/dist/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +89 -0
- package/dist/components/MaterialUI/DataDisplay/Table.js +109 -18
- package/dist/components/MaterialUI/DataDisplay/TableProps.js +5 -1
- package/dist/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +198 -0
- package/dist/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +4 -1
- package/dist/components/MaterialUI/Inputs/DatePicker.js +14 -14
- package/dist/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
- package/dist/components/MaterialUI/Inputs/Select.js +2 -0
- package/dist/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/dist/components/MaterialUI/Inputs/Switch.js +17 -1
- package/dist/components/MaterialUI/Inputs/SwitchProps.js +2 -0
- package/dist/components/MaterialUI/Inputs/TimePicker.js +14 -21
- package/dist/components/MaterialUI/hocs/withDeferredTooltip.js +3 -1
- package/dist/components/MaterialUI/muiThemes.js +2 -1
- package/dist/components/Provision.js +1 -1
- package/dist/constants.js +2 -1
- package/dist/content/iconsSheet.svg +740 -116
- package/dist/hocs/withScrollBox.js +27 -12
- package/dist/hooks/useDaysAndMonthsLocalization.js +77 -0
- package/dist/hooks/useInMemoryPaging.js +135 -0
- package/dist/hooks/useMultipleFieldEditState.js +12 -3
- package/dist/reducers/metadata.js +6 -0
- package/dist/schemas/metadata.js +9 -1
- package/dist/selectors/locale.js +1 -0
- package/dist/selectors/metadata.js +14 -11
- package/dist/sharedMessages.js +184 -0
- package/dist/utils/ListHelper.js +271 -0
- package/dist/utils/comparisonHelper.js +185 -0
- package/dist/utils/propertyBagHelper.js +3 -1
- package/dist/utils/timezoneHelper.js +18 -31
- package/package.json +4 -3
- package/src/actions/metadata.js +11 -0
- package/src/actions/metadata.test.js +27 -0
- package/src/actions/requestsApi.js +6 -0
- package/src/components/AppFrame/About.js +97 -117
- package/src/components/AppFrame/About.test.js +128 -90
- package/src/components/AppFrame/Anchor.js +34 -36
- package/src/components/AppFrame/Anchor.test.js +5 -68
- package/src/components/AppFrame/AppFrame.js +31 -40
- package/src/components/AppFrame/AppFrame.test.js +424 -445
- package/src/components/AppFrame/Help.js +23 -20
- package/src/components/AppFrame/Help.test.js +3 -3
- package/src/components/AppFrame/MenuItem.js +106 -126
- package/src/components/AppFrame/MenuItem.test.js +78 -169
- package/src/components/AppFrame/Preferences.js +110 -98
- package/src/components/AppFrame/Preferences.test.js +115 -219
- package/src/components/AppFrame/Sidebar.js +39 -41
- package/src/components/AppFrame/Sidebar.test.js +88 -168
- package/src/components/AppFrame/Topbar.js +59 -52
- package/src/components/AppFrame/Topbar.test.js +31 -39
- package/src/components/ColumnWrapper.js +18 -9
- package/src/components/Culture.js +20 -10
- package/src/components/Culture.test.js +27 -16
- package/src/components/DropMenu/DropMenu.test.js +185 -224
- package/src/components/DropMenu/Menu.js +73 -80
- package/src/components/DropMenu/Menu.test.js +35 -86
- package/src/components/DropMenu/index.js +19 -15
- package/src/components/Form/Combination.js +35 -28
- package/src/components/Form/Combination.test.js +6 -19
- package/src/components/Form/Field.js +53 -66
- package/src/components/Form/Field.test.js +29 -51
- package/src/components/Form/FieldElements.js +0 -14
- package/src/components/Form/FieldElements.test.js +104 -111
- package/src/components/Form/Fieldset.js +42 -37
- package/src/components/Form/Fieldset.test.js +14 -7
- package/src/components/Form/Form.js +11 -7
- package/src/components/Form/Form.test.js +75 -56
- package/src/components/Form/FormElement.js +24 -16
- package/src/components/Form/InputField.test.js +24 -30
- package/src/components/Form/Inputs/Button.js +58 -14
- package/src/components/Form/Inputs/Button.test.js +32 -7
- package/src/components/Form/Inputs/Inputs.test.js +0 -7
- package/src/components/Form/Inputs/ReadOnly.js +34 -28
- package/src/components/Form/Inputs/ReadOnly.test.js +45 -7
- package/src/components/Form/Inputs/Selector.js +22 -0
- package/src/components/Form/Inputs/Selector.test.js +105 -0
- package/src/components/Form/Inputs/Text.js +15 -44
- package/src/components/Form/Inputs/Text.test.js +20 -29
- package/src/components/Form/Inputs/Toggles.js +27 -26
- package/src/components/Form/Inputs/Toggles.test.js +22 -28
- package/src/components/Form/Inputs/index.js +4 -15
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/InformationItem.test.js +1 -4
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.js +32 -6
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/Placeholder.test.js +3 -1
- package/src/components/MaterialUI/DataDisplay/PredefinedElements/SectionToolbar.js +39 -0
- package/src/components/MaterialUI/DataDisplay/Table.js +190 -114
- package/src/components/MaterialUI/DataDisplay/Table.test.js +246 -1
- package/src/components/MaterialUI/DataDisplay/TableProps.js +4 -0
- package/src/components/MaterialUI/DataDisplay/TableProps.test.js +2 -0
- package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.js +145 -0
- package/src/components/MaterialUI/DataDisplay/TableWithInMemoryPaging.test.js +457 -0
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.js +5 -1
- package/src/components/MaterialUI/DataDisplay/TooltippedElements/MultipleLinesText.test.js +7 -1
- package/src/components/MaterialUI/Inputs/DatePicker.js +19 -20
- package/src/components/MaterialUI/Inputs/DatePicker.test.js +11 -6
- package/src/components/MaterialUI/Inputs/PredefinedElements/SearchControl.js +1 -0
- package/src/components/MaterialUI/Inputs/Select.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SelectProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/Switch.js +22 -1
- package/src/components/MaterialUI/Inputs/Switch.test.js +23 -0
- package/src/components/MaterialUI/Inputs/SwitchProps.js +2 -0
- package/src/components/MaterialUI/Inputs/SwitchProps.test.js +2 -0
- package/src/components/MaterialUI/Inputs/TimePicker.js +10 -19
- package/src/components/MaterialUI/Inputs/TimePicker.test.js +278 -117
- package/src/components/MaterialUI/hocs/withDeferredTooltip.js +4 -1
- package/src/components/MaterialUI/hocs/withDeferredTooltip.test.js +27 -0
- package/src/components/MaterialUI/muiThemes.js +1 -0
- package/src/components/Navigation/Bar.test.js +92 -87
- package/src/components/Provision.js +1 -1
- package/src/components/TaskDetailsModal.test.js +1 -3
- package/src/constants.js +1 -0
- package/src/content/iconsSheet.svg +740 -116
- package/src/hocs/withScrollBox.js +32 -19
- package/src/hocs/withScrollBox.test.js +15 -3
- package/src/hooks/useDaysAndMonthsLocalization.js +79 -0
- package/src/hooks/useDaysAndMonthsLocalization.test.js +107 -0
- package/src/hooks/useInMemoryPaging.js +78 -0
- package/src/hooks/useInMemoryPaging.test.js +515 -0
- package/src/hooks/useMultipleFieldEditState.js +11 -4
- package/src/hooks/useMultipleFieldEditState.test.js +49 -1
- package/src/reducers/metadata.js +6 -1
- package/src/reducers/metadata.test.js +31 -0
- package/src/requests +1 -0
- package/src/schemas/metadata.js +3 -0
- package/src/selectors/locale.js +1 -1
- package/src/selectors/metadata.js +12 -9
- package/src/selectors/metadata.test.js +92 -11
- package/src/sharedMessages.js +184 -0
- package/src/timezones.json +883 -0
- package/src/translations/en-US.json +46 -0
- package/src/translations/fr-CA.json +46 -0
- package/src/utils/ListHelper.js +203 -0
- package/src/utils/ListHelper.test.js +710 -0
- package/src/utils/comparisonHelper.js +135 -0
- package/src/utils/comparisonHelper.test.js +334 -0
- package/src/utils/propertyBagHelper.js +2 -0
- package/src/utils/propertyBagHelper.test.js +6 -0
- package/src/utils/timezoneHelper.js +10 -135
- package/src/utils/timezoneHelper.test.js +7 -7
- package/dist/components/Form/FieldList.js +0 -270
- package/dist/components/Form/Inputs/FieldButtons.js +0 -66
- package/dist/components/Form/Inputs/Number.js +0 -117
- package/dist/components/Form/Inputs/SmallButton.js +0 -91
- package/dist/components/Form/Inputs/Time.js +0 -86
- package/dist/components/Form/Inputs/Translation.js +0 -169
- package/src/components/AppFrame/ApplicationSelector/Header.js +0 -34
- package/src/components/AppFrame/ApplicationSelector/Header.test.js +0 -23
- package/src/components/Form/FieldList.js +0 -210
- package/src/components/Form/FieldList.test.js +0 -558
- package/src/components/Form/Inputs/FieldButtons.js +0 -90
- package/src/components/Form/Inputs/Number.js +0 -60
- package/src/components/Form/Inputs/Number.test.js +0 -435
- package/src/components/Form/Inputs/SmallButton.js +0 -37
- package/src/components/Form/Inputs/SmallButton.test.js +0 -65
- package/src/components/Form/Inputs/Time.js +0 -32
- package/src/components/Form/Inputs/Time.test.js +0 -41
- package/src/components/Form/Inputs/Translation.js +0 -93
- package/src/components/Form/Inputs/Translation.test.js +0 -204
|
@@ -0,0 +1,710 @@
|
|
|
1
|
+
import ListHelper, { ListInfoPropertyName } from "./ListHelper";
|
|
2
|
+
import Immutable from "immutable";
|
|
3
|
+
|
|
4
|
+
describe("createInitialListInfo", () => {
|
|
5
|
+
it("created expected object", () => {
|
|
6
|
+
const obj = ListHelper.createInitialListInfo();
|
|
7
|
+
expect(obj, "to equal", {
|
|
8
|
+
[ListInfoPropertyName]: {
|
|
9
|
+
sorting: null,
|
|
10
|
+
filters: null,
|
|
11
|
+
scope: null,
|
|
12
|
+
page: null,
|
|
13
|
+
nextPageToLoad: 1,
|
|
14
|
+
index: {},
|
|
15
|
+
list: [],
|
|
16
|
+
totalCount: 0,
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("created expected object with additional properties", () => {
|
|
22
|
+
const obj = ListHelper.createInitialListInfo({
|
|
23
|
+
prop1: 123,
|
|
24
|
+
prop2: { subprop: "a" },
|
|
25
|
+
});
|
|
26
|
+
expect(obj, "to equal", {
|
|
27
|
+
[ListInfoPropertyName]: {
|
|
28
|
+
sorting: null,
|
|
29
|
+
filters: null,
|
|
30
|
+
scope: null,
|
|
31
|
+
page: null,
|
|
32
|
+
nextPageToLoad: 1,
|
|
33
|
+
index: {},
|
|
34
|
+
list: [],
|
|
35
|
+
totalCount: 0,
|
|
36
|
+
prop1: 123,
|
|
37
|
+
prop2: { subprop: "a" },
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("created expected object with additional properties and overriding default values", () => {
|
|
43
|
+
const obj = ListHelper.createInitialListInfo({
|
|
44
|
+
sorting: { a: 1 },
|
|
45
|
+
filters: { b: 1 },
|
|
46
|
+
scope: "canada",
|
|
47
|
+
page: 1,
|
|
48
|
+
nextPageToLoad: 2,
|
|
49
|
+
index: { c: 1 },
|
|
50
|
+
list: [1, 2, 3],
|
|
51
|
+
totalCount: 10,
|
|
52
|
+
prop1: 123,
|
|
53
|
+
prop2: { subprop: "a" },
|
|
54
|
+
});
|
|
55
|
+
expect(obj, "to equal", {
|
|
56
|
+
[ListInfoPropertyName]: {
|
|
57
|
+
sorting: { a: 1 },
|
|
58
|
+
filters: { b: 1 },
|
|
59
|
+
scope: "canada",
|
|
60
|
+
page: 1,
|
|
61
|
+
nextPageToLoad: 2,
|
|
62
|
+
index: { c: 1 },
|
|
63
|
+
list: [1, 2, 3],
|
|
64
|
+
totalCount: 10,
|
|
65
|
+
prop1: 123,
|
|
66
|
+
prop2: { subprop: "a" },
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe("createListInfoFrom", () => {
|
|
73
|
+
it("created expected object", () => {
|
|
74
|
+
const obj = ListHelper.createListInfoFrom();
|
|
75
|
+
expect(obj, "to equal", {
|
|
76
|
+
[ListInfoPropertyName]: {
|
|
77
|
+
sorting: null,
|
|
78
|
+
filters: null,
|
|
79
|
+
scope: null,
|
|
80
|
+
page: null,
|
|
81
|
+
nextPageToLoad: 1,
|
|
82
|
+
index: {},
|
|
83
|
+
list: [],
|
|
84
|
+
totalCount: 0,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("created expected object with additional properties", () => {
|
|
90
|
+
const obj = ListHelper.createListInfoFrom({
|
|
91
|
+
prop1: 123,
|
|
92
|
+
prop2: { subprop: "a" },
|
|
93
|
+
});
|
|
94
|
+
expect(obj, "to equal", {
|
|
95
|
+
[ListInfoPropertyName]: {
|
|
96
|
+
sorting: null,
|
|
97
|
+
filters: null,
|
|
98
|
+
scope: null,
|
|
99
|
+
page: null,
|
|
100
|
+
nextPageToLoad: 1,
|
|
101
|
+
index: {},
|
|
102
|
+
list: [],
|
|
103
|
+
totalCount: 0,
|
|
104
|
+
prop1: 123,
|
|
105
|
+
prop2: { subprop: "a" },
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("created expected object with additional properties and overriding default values", () => {
|
|
111
|
+
const obj = ListHelper.createListInfoFrom({
|
|
112
|
+
sorting: { a: 1 },
|
|
113
|
+
filters: { b: 1 },
|
|
114
|
+
scope: "canada",
|
|
115
|
+
page: 1,
|
|
116
|
+
nextPageToLoad: 2,
|
|
117
|
+
index: { c: 1 },
|
|
118
|
+
list: [1, 2, 3],
|
|
119
|
+
totalCount: 10,
|
|
120
|
+
prop1: 123,
|
|
121
|
+
prop2: { subprop: "a" },
|
|
122
|
+
});
|
|
123
|
+
expect(obj, "to equal", {
|
|
124
|
+
[ListInfoPropertyName]: {
|
|
125
|
+
sorting: { a: 1 },
|
|
126
|
+
filters: { b: 1 },
|
|
127
|
+
scope: "canada",
|
|
128
|
+
page: 1,
|
|
129
|
+
nextPageToLoad: 2,
|
|
130
|
+
index: { c: 1 },
|
|
131
|
+
list: [1, 2, 3],
|
|
132
|
+
totalCount: 10,
|
|
133
|
+
prop1: 123,
|
|
134
|
+
prop2: { subprop: "a" },
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
describe("ListSelectorHelper", () => {
|
|
141
|
+
const initialState = Immutable.fromJS(
|
|
142
|
+
ListHelper.createListInfoFrom({
|
|
143
|
+
sorting: { a: 1 },
|
|
144
|
+
filters: { b: 1 },
|
|
145
|
+
scope: "canada",
|
|
146
|
+
page: 1,
|
|
147
|
+
nextPageToLoad: 2,
|
|
148
|
+
index: { c: 1 },
|
|
149
|
+
list: [1, 2, 3],
|
|
150
|
+
totalCount: 10,
|
|
151
|
+
prop1: 123,
|
|
152
|
+
prop2: { subprop: "a" },
|
|
153
|
+
}),
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
it("getNextPageToLoad", () => {
|
|
157
|
+
const value = ListHelper.selector.getNextPageToLoad(initialState);
|
|
158
|
+
expect(value, "to equal", 2);
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it("getList", () => {
|
|
162
|
+
const value = ListHelper.selector.getList(initialState);
|
|
163
|
+
expect(value, "to equal", Immutable.fromJS([1, 2, 3]));
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("getIndex", () => {
|
|
167
|
+
const value = ListHelper.selector.getIndex(initialState);
|
|
168
|
+
expect(value, "to equal", Immutable.fromJS({ c: 1 }));
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("getCurrentInfo", () => {
|
|
172
|
+
const value = ListHelper.selector.getCurrentInfo(initialState);
|
|
173
|
+
expect(value, "to equal", {
|
|
174
|
+
currentSorting: { a: 1 },
|
|
175
|
+
currentFilters: { b: 1 },
|
|
176
|
+
currentScope: "canada",
|
|
177
|
+
currentPage: 1,
|
|
178
|
+
totalCount: 10,
|
|
179
|
+
prop1: 123,
|
|
180
|
+
prop2: { subprop: "a" },
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("getCurrentInfo without filters or sorting", () => {
|
|
185
|
+
const value = ListHelper.selector.getCurrentInfo(
|
|
186
|
+
initialState.setIn([ListInfoPropertyName, "filters"], null).setIn([ListInfoPropertyName, "sorting"], null),
|
|
187
|
+
);
|
|
188
|
+
expect(value, "to equal", {
|
|
189
|
+
currentSorting: undefined,
|
|
190
|
+
currentFilters: undefined,
|
|
191
|
+
currentScope: "canada",
|
|
192
|
+
currentPage: 1,
|
|
193
|
+
totalCount: 10,
|
|
194
|
+
prop1: 123,
|
|
195
|
+
prop2: { subprop: "a" },
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("getCurrentInfo with empty state", () => {
|
|
200
|
+
const value = ListHelper.selector.getCurrentInfo(initialState.set(ListInfoPropertyName));
|
|
201
|
+
expect(value, "to equal", {
|
|
202
|
+
currentSorting: undefined,
|
|
203
|
+
currentFilters: undefined,
|
|
204
|
+
currentScope: undefined,
|
|
205
|
+
currentPage: undefined,
|
|
206
|
+
totalCount: undefined,
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
describe("ListReducerHelper", () => {
|
|
212
|
+
const initialState = Immutable.fromJS(
|
|
213
|
+
ListHelper.createListInfoFrom({
|
|
214
|
+
sorting: { a: 1 },
|
|
215
|
+
filters: { b: 1 },
|
|
216
|
+
scope: "canada",
|
|
217
|
+
page: 1,
|
|
218
|
+
nextPageToLoad: 2,
|
|
219
|
+
index: { c: 1 },
|
|
220
|
+
list: [1, 2, 3],
|
|
221
|
+
totalCount: 10,
|
|
222
|
+
prop1: 123,
|
|
223
|
+
prop2: { subprop: "a" },
|
|
224
|
+
}),
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
it("setNextPageToLoad", () => {
|
|
228
|
+
const newState = ListHelper.reducer.setNextPageToLoad(initialState, 888);
|
|
229
|
+
expect(
|
|
230
|
+
newState,
|
|
231
|
+
"to equal",
|
|
232
|
+
Immutable.fromJS(
|
|
233
|
+
ListHelper.createListInfoFrom({
|
|
234
|
+
sorting: { a: 1 },
|
|
235
|
+
filters: { b: 1 },
|
|
236
|
+
scope: "canada",
|
|
237
|
+
page: 1,
|
|
238
|
+
nextPageToLoad: 888,
|
|
239
|
+
index: { c: 1 },
|
|
240
|
+
list: [1, 2, 3],
|
|
241
|
+
totalCount: 10,
|
|
242
|
+
prop1: 123,
|
|
243
|
+
prop2: { subprop: "a" },
|
|
244
|
+
}),
|
|
245
|
+
),
|
|
246
|
+
);
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it("setResults first page", () => {
|
|
250
|
+
const listInfo = {
|
|
251
|
+
indexEntities: { d: 1 },
|
|
252
|
+
listEntities: [4, 5, 6],
|
|
253
|
+
totalCount: 222,
|
|
254
|
+
};
|
|
255
|
+
const newState = ListHelper.reducer.setResults(
|
|
256
|
+
initialState.setIn([ListInfoPropertyName, "nextPageToLoad"], 1),
|
|
257
|
+
listInfo,
|
|
258
|
+
);
|
|
259
|
+
expect(
|
|
260
|
+
newState,
|
|
261
|
+
"to equal",
|
|
262
|
+
Immutable.fromJS(
|
|
263
|
+
ListHelper.createListInfoFrom({
|
|
264
|
+
sorting: { a: 1 },
|
|
265
|
+
filters: { b: 1 },
|
|
266
|
+
scope: "canada",
|
|
267
|
+
page: 1,
|
|
268
|
+
nextPageToLoad: 1,
|
|
269
|
+
index: { d: 1 },
|
|
270
|
+
list: [4, 5, 6],
|
|
271
|
+
totalCount: 222,
|
|
272
|
+
prop1: 123,
|
|
273
|
+
prop2: { subprop: "a" },
|
|
274
|
+
}),
|
|
275
|
+
),
|
|
276
|
+
);
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it("setResults with null entities", () => {
|
|
280
|
+
const listInfo = {
|
|
281
|
+
indexEntities: null,
|
|
282
|
+
listEntities: [4, 5, 6],
|
|
283
|
+
totalCount: 222,
|
|
284
|
+
};
|
|
285
|
+
const newState = ListHelper.reducer.setResults(
|
|
286
|
+
initialState.setIn([ListInfoPropertyName, "nextPageToLoad"], 1),
|
|
287
|
+
listInfo,
|
|
288
|
+
false,
|
|
289
|
+
);
|
|
290
|
+
expect(
|
|
291
|
+
newState,
|
|
292
|
+
"to equal",
|
|
293
|
+
Immutable.fromJS(
|
|
294
|
+
ListHelper.createListInfoFrom({
|
|
295
|
+
sorting: { a: 1 },
|
|
296
|
+
filters: { b: 1 },
|
|
297
|
+
scope: "canada",
|
|
298
|
+
page: 1,
|
|
299
|
+
nextPageToLoad: 1,
|
|
300
|
+
index: {},
|
|
301
|
+
list: [4, 5, 6],
|
|
302
|
+
totalCount: 222,
|
|
303
|
+
prop1: 123,
|
|
304
|
+
prop2: { subprop: "a" },
|
|
305
|
+
}),
|
|
306
|
+
),
|
|
307
|
+
);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it("setResults another page", () => {
|
|
311
|
+
const listInfo = {
|
|
312
|
+
indexEntities: { d: 1 },
|
|
313
|
+
listEntities: [4, 5, 6],
|
|
314
|
+
totalCount: 222,
|
|
315
|
+
};
|
|
316
|
+
const newState = ListHelper.reducer.setResults(initialState, listInfo, false);
|
|
317
|
+
expect(
|
|
318
|
+
newState,
|
|
319
|
+
"to equal",
|
|
320
|
+
Immutable.fromJS(
|
|
321
|
+
ListHelper.createListInfoFrom({
|
|
322
|
+
sorting: { a: 1 },
|
|
323
|
+
filters: { b: 1 },
|
|
324
|
+
scope: "canada",
|
|
325
|
+
page: 1,
|
|
326
|
+
nextPageToLoad: 2,
|
|
327
|
+
index: { c: 1, d: 1 },
|
|
328
|
+
list: [1, 2, 3, 4, 5, 6],
|
|
329
|
+
totalCount: 222,
|
|
330
|
+
prop1: 123,
|
|
331
|
+
prop2: { subprop: "a" },
|
|
332
|
+
}),
|
|
333
|
+
),
|
|
334
|
+
);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it("setResults force reset", () => {
|
|
338
|
+
const listInfo = {
|
|
339
|
+
indexEntities: { d: 1 },
|
|
340
|
+
listEntities: [4, 5, 6],
|
|
341
|
+
totalCount: 222,
|
|
342
|
+
};
|
|
343
|
+
const newState = ListHelper.reducer.setResults(initialState, listInfo, true);
|
|
344
|
+
expect(
|
|
345
|
+
newState,
|
|
346
|
+
"to equal",
|
|
347
|
+
Immutable.fromJS(
|
|
348
|
+
ListHelper.createListInfoFrom({
|
|
349
|
+
sorting: { a: 1 },
|
|
350
|
+
filters: { b: 1 },
|
|
351
|
+
scope: "canada",
|
|
352
|
+
page: 1,
|
|
353
|
+
nextPageToLoad: 2,
|
|
354
|
+
index: { d: 1 },
|
|
355
|
+
list: [4, 5, 6],
|
|
356
|
+
totalCount: 222,
|
|
357
|
+
prop1: 123,
|
|
358
|
+
prop2: { subprop: "a" },
|
|
359
|
+
}),
|
|
360
|
+
),
|
|
361
|
+
);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it("setCurrentInfo with reset", () => {
|
|
365
|
+
const info = {
|
|
366
|
+
resetList: true,
|
|
367
|
+
scope: "usa",
|
|
368
|
+
filters: { e: 1 },
|
|
369
|
+
sorting: { f: 1 },
|
|
370
|
+
prop1: 456,
|
|
371
|
+
prop2: { subprop: "b" },
|
|
372
|
+
};
|
|
373
|
+
const newState = ListHelper.reducer.setCurrentInfo(initialState, info);
|
|
374
|
+
expect(
|
|
375
|
+
newState,
|
|
376
|
+
"to equal",
|
|
377
|
+
Immutable.fromJS(
|
|
378
|
+
ListHelper.createListInfoFrom({
|
|
379
|
+
sorting: { f: 1 },
|
|
380
|
+
filters: { e: 1 },
|
|
381
|
+
scope: "usa",
|
|
382
|
+
page: null,
|
|
383
|
+
nextPageToLoad: 1,
|
|
384
|
+
index: {},
|
|
385
|
+
list: [],
|
|
386
|
+
totalCount: 0,
|
|
387
|
+
prop1: 456,
|
|
388
|
+
prop2: { subprop: "b" },
|
|
389
|
+
}),
|
|
390
|
+
),
|
|
391
|
+
);
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it("setCurrentInfo without reset", () => {
|
|
395
|
+
const info = {
|
|
396
|
+
resetList: false,
|
|
397
|
+
scope: "usa",
|
|
398
|
+
filters: { e: 1 },
|
|
399
|
+
sorting: { f: 1 },
|
|
400
|
+
prop1: 456,
|
|
401
|
+
prop2: { subprop: "b" },
|
|
402
|
+
};
|
|
403
|
+
const newState = ListHelper.reducer.setCurrentInfo(initialState, info);
|
|
404
|
+
expect(
|
|
405
|
+
newState,
|
|
406
|
+
"to equal",
|
|
407
|
+
Immutable.fromJS(
|
|
408
|
+
ListHelper.createListInfoFrom({
|
|
409
|
+
sorting: { f: 1 },
|
|
410
|
+
filters: { e: 1 },
|
|
411
|
+
scope: "usa",
|
|
412
|
+
page: 2,
|
|
413
|
+
nextPageToLoad: 2,
|
|
414
|
+
index: { c: 1 },
|
|
415
|
+
list: [1, 2, 3],
|
|
416
|
+
totalCount: 10,
|
|
417
|
+
prop1: 456,
|
|
418
|
+
prop2: { subprop: "b" },
|
|
419
|
+
}),
|
|
420
|
+
),
|
|
421
|
+
);
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
it("setCurrentInfo without reset and without all other props", () => {
|
|
425
|
+
const info = {
|
|
426
|
+
resetList: false,
|
|
427
|
+
scope: "usa",
|
|
428
|
+
filters: { e: 1 },
|
|
429
|
+
sorting: { f: 1 },
|
|
430
|
+
prop1: 456,
|
|
431
|
+
prop3: 789,
|
|
432
|
+
};
|
|
433
|
+
const newState = ListHelper.reducer.setCurrentInfo(initialState, info);
|
|
434
|
+
expect(
|
|
435
|
+
newState,
|
|
436
|
+
"to equal",
|
|
437
|
+
Immutable.fromJS(
|
|
438
|
+
ListHelper.createListInfoFrom({
|
|
439
|
+
sorting: { f: 1 },
|
|
440
|
+
filters: { e: 1 },
|
|
441
|
+
scope: "usa",
|
|
442
|
+
page: 2,
|
|
443
|
+
nextPageToLoad: 2,
|
|
444
|
+
index: { c: 1 },
|
|
445
|
+
list: [1, 2, 3],
|
|
446
|
+
totalCount: 10,
|
|
447
|
+
prop1: 456,
|
|
448
|
+
prop3: 789,
|
|
449
|
+
}),
|
|
450
|
+
),
|
|
451
|
+
);
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
it("setCurrentInfo without reset and without any other props", () => {
|
|
455
|
+
const info = {
|
|
456
|
+
resetList: false,
|
|
457
|
+
scope: "usa",
|
|
458
|
+
filters: { e: 1 },
|
|
459
|
+
sorting: { f: 1 },
|
|
460
|
+
};
|
|
461
|
+
const newState = ListHelper.reducer.setCurrentInfo(initialState, info);
|
|
462
|
+
expect(
|
|
463
|
+
newState,
|
|
464
|
+
"to equal",
|
|
465
|
+
Immutable.fromJS(
|
|
466
|
+
ListHelper.createListInfoFrom({
|
|
467
|
+
sorting: { f: 1 },
|
|
468
|
+
filters: { e: 1 },
|
|
469
|
+
scope: "usa",
|
|
470
|
+
page: 2,
|
|
471
|
+
nextPageToLoad: 2,
|
|
472
|
+
index: { c: 1 },
|
|
473
|
+
list: [1, 2, 3],
|
|
474
|
+
totalCount: 10,
|
|
475
|
+
}),
|
|
476
|
+
),
|
|
477
|
+
);
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
it("setCurrentInfo without filters and sorting", () => {
|
|
481
|
+
const info = {
|
|
482
|
+
resetList: false,
|
|
483
|
+
scope: "usa",
|
|
484
|
+
filters: null,
|
|
485
|
+
sorting: null,
|
|
486
|
+
prop1: 456,
|
|
487
|
+
prop2: { subprop: "b" },
|
|
488
|
+
};
|
|
489
|
+
const newState = ListHelper.reducer.setCurrentInfo(initialState, info);
|
|
490
|
+
expect(
|
|
491
|
+
newState,
|
|
492
|
+
"to equal",
|
|
493
|
+
Immutable.fromJS(
|
|
494
|
+
ListHelper.createListInfoFrom({
|
|
495
|
+
sorting: null,
|
|
496
|
+
filters: null,
|
|
497
|
+
scope: "usa",
|
|
498
|
+
page: 2,
|
|
499
|
+
nextPageToLoad: 2,
|
|
500
|
+
index: { c: 1 },
|
|
501
|
+
list: [1, 2, 3],
|
|
502
|
+
totalCount: 10,
|
|
503
|
+
prop1: 456,
|
|
504
|
+
prop2: { subprop: "b" },
|
|
505
|
+
}),
|
|
506
|
+
),
|
|
507
|
+
);
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
it("setCurrentInfo without details", () => {
|
|
511
|
+
const newState = ListHelper.reducer.setCurrentInfo(initialState);
|
|
512
|
+
expect(
|
|
513
|
+
newState,
|
|
514
|
+
"to equal",
|
|
515
|
+
Immutable.fromJS(
|
|
516
|
+
ListHelper.createListInfoFrom({
|
|
517
|
+
sorting: null,
|
|
518
|
+
filters: null,
|
|
519
|
+
scope: null,
|
|
520
|
+
page: 2,
|
|
521
|
+
nextPageToLoad: 2,
|
|
522
|
+
index: { c: 1 },
|
|
523
|
+
list: [1, 2, 3],
|
|
524
|
+
totalCount: 10,
|
|
525
|
+
}),
|
|
526
|
+
),
|
|
527
|
+
);
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
it("addIndexWithMutations", () => {
|
|
531
|
+
const newState = initialState.withMutations(s => ListHelper.reducer.addIndexWithMutations(s, "d", 888));
|
|
532
|
+
expect(
|
|
533
|
+
newState,
|
|
534
|
+
"to equal",
|
|
535
|
+
Immutable.fromJS(
|
|
536
|
+
ListHelper.createListInfoFrom({
|
|
537
|
+
sorting: { a: 1 },
|
|
538
|
+
filters: { b: 1 },
|
|
539
|
+
scope: "canada",
|
|
540
|
+
page: 1,
|
|
541
|
+
nextPageToLoad: 2,
|
|
542
|
+
index: { c: 1, d: 888 },
|
|
543
|
+
list: [1, 2, 3],
|
|
544
|
+
totalCount: 10,
|
|
545
|
+
prop1: 123,
|
|
546
|
+
prop2: { subprop: "a" },
|
|
547
|
+
}),
|
|
548
|
+
),
|
|
549
|
+
);
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
it("appendIdToListWithMutations", () => {
|
|
553
|
+
const newState = initialState.withMutations(s => ListHelper.reducer.appendIdToListWithMutations(s, 888));
|
|
554
|
+
expect(
|
|
555
|
+
newState,
|
|
556
|
+
"to equal",
|
|
557
|
+
Immutable.fromJS(
|
|
558
|
+
ListHelper.createListInfoFrom({
|
|
559
|
+
sorting: { a: 1 },
|
|
560
|
+
filters: { b: 1 },
|
|
561
|
+
scope: "canada",
|
|
562
|
+
page: 1,
|
|
563
|
+
nextPageToLoad: 2,
|
|
564
|
+
index: { c: 1 },
|
|
565
|
+
list: [1, 2, 3, 888],
|
|
566
|
+
totalCount: 10,
|
|
567
|
+
prop1: 123,
|
|
568
|
+
prop2: { subprop: "a" },
|
|
569
|
+
}),
|
|
570
|
+
),
|
|
571
|
+
);
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
it("updateIndexWithMutations existing", () => {
|
|
575
|
+
const newState = initialState.withMutations(s => ListHelper.reducer.updateIndexWithMutations(s, "c", 888));
|
|
576
|
+
expect(
|
|
577
|
+
newState,
|
|
578
|
+
"to equal",
|
|
579
|
+
Immutable.fromJS(
|
|
580
|
+
ListHelper.createListInfoFrom({
|
|
581
|
+
sorting: { a: 1 },
|
|
582
|
+
filters: { b: 1 },
|
|
583
|
+
scope: "canada",
|
|
584
|
+
page: 1,
|
|
585
|
+
nextPageToLoad: 2,
|
|
586
|
+
index: { c: 888 },
|
|
587
|
+
list: [1, 2, 3],
|
|
588
|
+
totalCount: 10,
|
|
589
|
+
prop1: 123,
|
|
590
|
+
prop2: { subprop: "a" },
|
|
591
|
+
}),
|
|
592
|
+
),
|
|
593
|
+
);
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
it("updateIndexWithMutations missing", () => {
|
|
597
|
+
const newState = initialState.withMutations(s => ListHelper.reducer.updateIndexWithMutations(s, "d", 888));
|
|
598
|
+
expect(
|
|
599
|
+
newState,
|
|
600
|
+
"to equal",
|
|
601
|
+
Immutable.fromJS(
|
|
602
|
+
ListHelper.createListInfoFrom({
|
|
603
|
+
sorting: { a: 1 },
|
|
604
|
+
filters: { b: 1 },
|
|
605
|
+
scope: "canada",
|
|
606
|
+
page: 1,
|
|
607
|
+
nextPageToLoad: 2,
|
|
608
|
+
index: { c: 1 },
|
|
609
|
+
list: [1, 2, 3],
|
|
610
|
+
totalCount: 10,
|
|
611
|
+
prop1: 123,
|
|
612
|
+
prop2: { subprop: "a" },
|
|
613
|
+
}),
|
|
614
|
+
),
|
|
615
|
+
);
|
|
616
|
+
});
|
|
617
|
+
|
|
618
|
+
it("removeFromIndexWithMutations existing", () => {
|
|
619
|
+
const newState = initialState.withMutations(s => ListHelper.reducer.removeFromIndexWithMutations(s, "c"));
|
|
620
|
+
expect(
|
|
621
|
+
newState,
|
|
622
|
+
"to equal",
|
|
623
|
+
Immutable.fromJS(
|
|
624
|
+
ListHelper.createListInfoFrom({
|
|
625
|
+
sorting: { a: 1 },
|
|
626
|
+
filters: { b: 1 },
|
|
627
|
+
scope: "canada",
|
|
628
|
+
page: 1,
|
|
629
|
+
nextPageToLoad: 2,
|
|
630
|
+
index: {},
|
|
631
|
+
list: [1, 2, 3],
|
|
632
|
+
totalCount: 10,
|
|
633
|
+
prop1: 123,
|
|
634
|
+
prop2: { subprop: "a" },
|
|
635
|
+
}),
|
|
636
|
+
),
|
|
637
|
+
);
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
it("removeFromIndexWithMutations missing", () => {
|
|
641
|
+
const newState = initialState.withMutations(s => ListHelper.reducer.removeFromIndexWithMutations(s, "d"));
|
|
642
|
+
expect(
|
|
643
|
+
newState,
|
|
644
|
+
"to equal",
|
|
645
|
+
Immutable.fromJS(
|
|
646
|
+
ListHelper.createListInfoFrom({
|
|
647
|
+
sorting: { a: 1 },
|
|
648
|
+
filters: { b: 1 },
|
|
649
|
+
scope: "canada",
|
|
650
|
+
page: 1,
|
|
651
|
+
nextPageToLoad: 2,
|
|
652
|
+
index: { c: 1 },
|
|
653
|
+
list: [1, 2, 3],
|
|
654
|
+
totalCount: 10,
|
|
655
|
+
prop1: 123,
|
|
656
|
+
prop2: { subprop: "a" },
|
|
657
|
+
}),
|
|
658
|
+
),
|
|
659
|
+
);
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
it("resetListInfo without properties to keep", () => {
|
|
663
|
+
const newState = ListHelper.reducer.resetListInfo(initialState);
|
|
664
|
+
expect(
|
|
665
|
+
newState,
|
|
666
|
+
"to equal",
|
|
667
|
+
Immutable.fromJS(
|
|
668
|
+
ListHelper.createListInfoFrom({
|
|
669
|
+
sorting: null,
|
|
670
|
+
filters: null,
|
|
671
|
+
scope: null,
|
|
672
|
+
page: null,
|
|
673
|
+
nextPageToLoad: 1,
|
|
674
|
+
index: {},
|
|
675
|
+
list: [],
|
|
676
|
+
totalCount: 0,
|
|
677
|
+
prop1: 123,
|
|
678
|
+
prop2: { subprop: "a" },
|
|
679
|
+
}),
|
|
680
|
+
),
|
|
681
|
+
);
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
it("resetListInfo with properties to keep", () => {
|
|
685
|
+
const newState = ListHelper.reducer.resetListInfo(initialState, {
|
|
686
|
+
filters: true,
|
|
687
|
+
sorting: true,
|
|
688
|
+
scope: true,
|
|
689
|
+
page: true,
|
|
690
|
+
});
|
|
691
|
+
expect(
|
|
692
|
+
newState,
|
|
693
|
+
"to equal",
|
|
694
|
+
Immutable.fromJS(
|
|
695
|
+
ListHelper.createListInfoFrom({
|
|
696
|
+
sorting: { a: 1 },
|
|
697
|
+
filters: { b: 1 },
|
|
698
|
+
scope: "canada",
|
|
699
|
+
page: 1,
|
|
700
|
+
nextPageToLoad: 1,
|
|
701
|
+
index: {},
|
|
702
|
+
list: [],
|
|
703
|
+
totalCount: 0,
|
|
704
|
+
prop1: 123,
|
|
705
|
+
prop2: { subprop: "a" },
|
|
706
|
+
}),
|
|
707
|
+
),
|
|
708
|
+
);
|
|
709
|
+
});
|
|
710
|
+
});
|