@eeacms/volto-eea-website-theme 3.7.0 → 3.9.0
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/CHANGELOG.md +19 -2
- package/package.json +3 -1
- package/src/actions/index.js +1 -0
- package/src/actions/navigation.js +24 -0
- package/src/actions/print.js +9 -1
- package/src/components/manage/Blocks/ContextNavigation/variations/Accordion.jsx +42 -35
- package/src/components/manage/Blocks/LayoutSettings/LayoutSettingsEdit.test.jsx +383 -0
- package/src/components/manage/Blocks/Title/variations/WebReportPage.test.jsx +232 -0
- package/src/components/theme/Banner/View.jsx +11 -92
- package/src/components/theme/PrintLoader/PrintLoader.jsx +56 -0
- package/src/components/theme/PrintLoader/PrintLoader.test.jsx +91 -0
- package/src/components/theme/PrintLoader/style.less +12 -0
- package/src/components/theme/WebReport/WebReportSectionView.test.jsx +462 -0
- package/src/components/theme/Widgets/ImageViewWidget.test.jsx +26 -0
- package/src/components/theme/Widgets/NavigationBehaviorWidget.jsx +601 -0
- package/src/components/theme/Widgets/NavigationBehaviorWidget.test.jsx +507 -0
- package/src/components/theme/Widgets/SimpleArrayWidget.jsx +183 -0
- package/src/components/theme/Widgets/SimpleArrayWidget.test.jsx +283 -0
- package/src/constants/ActionTypes.js +2 -0
- package/src/customizations/volto/components/manage/History/History.diff +207 -0
- package/src/customizations/volto/components/manage/History/History.jsx +444 -0
- package/src/customizations/volto/components/theme/Comments/Comments.jsx +9 -2
- package/src/customizations/volto/components/theme/Comments/Comments.test.jsx +4 -4
- package/src/customizations/volto/components/theme/Comments/comments.less +16 -0
- package/src/customizations/volto/components/theme/Header/Header.jsx +60 -1
- package/src/customizations/volto/components/theme/View/DefaultView.jsx +42 -33
- package/src/customizations/volto/helpers/Html/Html.jsx +212 -0
- package/src/customizations/volto/helpers/Html/Readme.md +1 -0
- package/src/customizations/volto/server.jsx +375 -0
- package/src/helpers/loadLazyImages.js +11 -0
- package/src/helpers/loadLazyImages.test.js +22 -0
- package/src/helpers/setupPrintView.js +134 -0
- package/src/helpers/setupPrintView.test.js +49 -0
- package/src/index.js +11 -1
- package/src/index.test.js +6 -0
- package/src/middleware/voltoCustom.test.js +282 -0
- package/src/reducers/index.js +2 -1
- package/src/reducers/navigation/navigation.js +47 -0
- package/src/reducers/navigation/navigation.test.js +348 -0
- package/src/reducers/navigation.js +55 -0
- package/src/reducers/print.js +18 -8
- package/src/reducers/print.test.js +117 -0
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import navigationReducer from './navigation';
|
|
2
|
+
import { GET_NAVIGATION_SETTINGS } from '../../constants/ActionTypes';
|
|
3
|
+
|
|
4
|
+
describe('navigation reducer', () => {
|
|
5
|
+
const initialState = {
|
|
6
|
+
error: null,
|
|
7
|
+
items: {},
|
|
8
|
+
loaded: false,
|
|
9
|
+
loading: false,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
it('should return the initial state', () => {
|
|
13
|
+
expect(navigationReducer(undefined, {})).toEqual(initialState);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('should handle GET_NAVIGATION_SETTINGS_PENDING', () => {
|
|
17
|
+
const action = {
|
|
18
|
+
type: `${GET_NAVIGATION_SETTINGS}_PENDING`,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const expectedState = {
|
|
22
|
+
...initialState,
|
|
23
|
+
error: null,
|
|
24
|
+
loaded: false,
|
|
25
|
+
loading: true,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
expect(navigationReducer(initialState, action)).toEqual(expectedState);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should handle GET_NAVIGATION_SETTINGS_PENDING when state has existing data', () => {
|
|
32
|
+
const existingState = {
|
|
33
|
+
error: 'Some error',
|
|
34
|
+
items: { '/existing': { title: 'Existing' } },
|
|
35
|
+
loaded: true,
|
|
36
|
+
loading: false,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const action = {
|
|
40
|
+
type: `${GET_NAVIGATION_SETTINGS}_PENDING`,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const expectedState = {
|
|
44
|
+
...existingState,
|
|
45
|
+
error: null,
|
|
46
|
+
loaded: false,
|
|
47
|
+
loading: true,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
expect(navigationReducer(existingState, action)).toEqual(expectedState);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should handle GET_NAVIGATION_SETTINGS_SUCCESS', () => {
|
|
54
|
+
const action = {
|
|
55
|
+
type: `${GET_NAVIGATION_SETTINGS}_SUCCESS`,
|
|
56
|
+
result: {
|
|
57
|
+
'@id': '/test-page',
|
|
58
|
+
title: 'Test Page',
|
|
59
|
+
hideChildrenFromNavigation: false,
|
|
60
|
+
menuItemColumns: [1, 2],
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const expectedState = {
|
|
65
|
+
...initialState,
|
|
66
|
+
error: null,
|
|
67
|
+
items: {
|
|
68
|
+
'/test-page': {
|
|
69
|
+
'@id': '/test-page',
|
|
70
|
+
title: 'Test Page',
|
|
71
|
+
hideChildrenFromNavigation: false,
|
|
72
|
+
menuItemColumns: [1, 2],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
loaded: true,
|
|
76
|
+
loading: false,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
expect(navigationReducer(initialState, action)).toEqual(expectedState);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('should handle GET_NAVIGATION_SETTINGS_SUCCESS with undefined hideChildrenFromNavigation', () => {
|
|
83
|
+
const action = {
|
|
84
|
+
type: `${GET_NAVIGATION_SETTINGS}_SUCCESS`,
|
|
85
|
+
result: {
|
|
86
|
+
'@id': '/test-page',
|
|
87
|
+
title: 'Test Page',
|
|
88
|
+
// hideChildrenFromNavigation is undefined
|
|
89
|
+
menuItemColumns: [1, 2],
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const expectedState = {
|
|
94
|
+
...initialState,
|
|
95
|
+
error: null,
|
|
96
|
+
items: {
|
|
97
|
+
'/test-page': {
|
|
98
|
+
'@id': '/test-page',
|
|
99
|
+
title: 'Test Page',
|
|
100
|
+
hideChildrenFromNavigation: true, // Should default to true
|
|
101
|
+
menuItemColumns: [1, 2],
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
loaded: true,
|
|
105
|
+
loading: false,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
expect(navigationReducer(initialState, action)).toEqual(expectedState);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should handle GET_NAVIGATION_SETTINGS_SUCCESS and merge with existing items', () => {
|
|
112
|
+
const existingState = {
|
|
113
|
+
error: null,
|
|
114
|
+
items: {
|
|
115
|
+
'/existing-page': {
|
|
116
|
+
'@id': '/existing-page',
|
|
117
|
+
title: 'Existing Page',
|
|
118
|
+
hideChildrenFromNavigation: true,
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
loaded: true,
|
|
122
|
+
loading: false,
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const action = {
|
|
126
|
+
type: `${GET_NAVIGATION_SETTINGS}_SUCCESS`,
|
|
127
|
+
result: {
|
|
128
|
+
'@id': '/new-page',
|
|
129
|
+
title: 'New Page',
|
|
130
|
+
hideChildrenFromNavigation: false,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const expectedState = {
|
|
135
|
+
...existingState,
|
|
136
|
+
error: null,
|
|
137
|
+
items: {
|
|
138
|
+
'/existing-page': {
|
|
139
|
+
'@id': '/existing-page',
|
|
140
|
+
title: 'Existing Page',
|
|
141
|
+
hideChildrenFromNavigation: true,
|
|
142
|
+
},
|
|
143
|
+
'/new-page': {
|
|
144
|
+
'@id': '/new-page',
|
|
145
|
+
title: 'New Page',
|
|
146
|
+
hideChildrenFromNavigation: false,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
loaded: true,
|
|
150
|
+
loading: false,
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
expect(navigationReducer(existingState, action)).toEqual(expectedState);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('should handle GET_NAVIGATION_SETTINGS_SUCCESS and update existing item', () => {
|
|
157
|
+
const existingState = {
|
|
158
|
+
error: null,
|
|
159
|
+
items: {
|
|
160
|
+
'/test-page': {
|
|
161
|
+
'@id': '/test-page',
|
|
162
|
+
title: 'Old Title',
|
|
163
|
+
hideChildrenFromNavigation: true,
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
loaded: true,
|
|
167
|
+
loading: false,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const action = {
|
|
171
|
+
type: `${GET_NAVIGATION_SETTINGS}_SUCCESS`,
|
|
172
|
+
result: {
|
|
173
|
+
'@id': '/test-page',
|
|
174
|
+
title: 'Updated Title',
|
|
175
|
+
hideChildrenFromNavigation: false,
|
|
176
|
+
menuItemColumns: [1, 2, 3],
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const expectedState = {
|
|
181
|
+
...existingState,
|
|
182
|
+
error: null,
|
|
183
|
+
items: {
|
|
184
|
+
'/test-page': {
|
|
185
|
+
'@id': '/test-page',
|
|
186
|
+
title: 'Updated Title',
|
|
187
|
+
hideChildrenFromNavigation: false,
|
|
188
|
+
menuItemColumns: [1, 2, 3],
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
loaded: true,
|
|
192
|
+
loading: false,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
expect(navigationReducer(existingState, action)).toEqual(expectedState);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it('should handle GET_NAVIGATION_SETTINGS_FAIL', () => {
|
|
199
|
+
const existingState = {
|
|
200
|
+
error: null,
|
|
201
|
+
items: { '/existing': { title: 'Existing' } },
|
|
202
|
+
loaded: true,
|
|
203
|
+
loading: true,
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const action = {
|
|
207
|
+
type: `${GET_NAVIGATION_SETTINGS}_FAIL`,
|
|
208
|
+
error: 'Network error',
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const expectedState = {
|
|
212
|
+
...existingState,
|
|
213
|
+
error: 'Network error',
|
|
214
|
+
items: {},
|
|
215
|
+
loaded: false,
|
|
216
|
+
loading: false,
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
expect(navigationReducer(existingState, action)).toEqual(expectedState);
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
it('should handle GET_NAVIGATION_SETTINGS_FAIL from initial state', () => {
|
|
223
|
+
const action = {
|
|
224
|
+
type: `${GET_NAVIGATION_SETTINGS}_FAIL`,
|
|
225
|
+
error: 'API error',
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const expectedState = {
|
|
229
|
+
...initialState,
|
|
230
|
+
error: 'API error',
|
|
231
|
+
items: {},
|
|
232
|
+
loaded: false,
|
|
233
|
+
loading: false,
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
expect(navigationReducer(initialState, action)).toEqual(expectedState);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('should return current state for unknown action types', () => {
|
|
240
|
+
const currentState = {
|
|
241
|
+
error: null,
|
|
242
|
+
items: { '/test': { title: 'Test' } },
|
|
243
|
+
loaded: true,
|
|
244
|
+
loading: false,
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
const action = {
|
|
248
|
+
type: 'UNKNOWN_ACTION',
|
|
249
|
+
payload: 'some data',
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
expect(navigationReducer(currentState, action)).toBe(currentState);
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
it('should handle action without type property', () => {
|
|
256
|
+
const currentState = {
|
|
257
|
+
error: null,
|
|
258
|
+
items: { '/test': { title: 'Test' } },
|
|
259
|
+
loaded: true,
|
|
260
|
+
loading: false,
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const action = {
|
|
264
|
+
payload: 'some data',
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
expect(navigationReducer(currentState, action)).toBe(currentState);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
it('should handle empty action object', () => {
|
|
271
|
+
const currentState = {
|
|
272
|
+
error: null,
|
|
273
|
+
items: { '/test': { title: 'Test' } },
|
|
274
|
+
loaded: true,
|
|
275
|
+
loading: false,
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
expect(navigationReducer(currentState, {})).toBe(currentState);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
it('should handle success action with complex result object', () => {
|
|
282
|
+
const action = {
|
|
283
|
+
type: `${GET_NAVIGATION_SETTINGS}_SUCCESS`,
|
|
284
|
+
result: {
|
|
285
|
+
'@id': '/complex-page',
|
|
286
|
+
title: 'Complex Page',
|
|
287
|
+
description: 'A complex navigation item',
|
|
288
|
+
hideChildrenFromNavigation: false,
|
|
289
|
+
menuItemColumns: [1, 2, 3],
|
|
290
|
+
menuItemChildrenListColumns: [2, 4],
|
|
291
|
+
customProperty: 'custom value',
|
|
292
|
+
nestedObject: {
|
|
293
|
+
nested: 'value',
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const expectedState = {
|
|
299
|
+
...initialState,
|
|
300
|
+
error: null,
|
|
301
|
+
items: {
|
|
302
|
+
'/complex-page': {
|
|
303
|
+
'@id': '/complex-page',
|
|
304
|
+
title: 'Complex Page',
|
|
305
|
+
description: 'A complex navigation item',
|
|
306
|
+
hideChildrenFromNavigation: false,
|
|
307
|
+
menuItemColumns: [1, 2, 3],
|
|
308
|
+
menuItemChildrenListColumns: [2, 4],
|
|
309
|
+
customProperty: 'custom value',
|
|
310
|
+
nestedObject: {
|
|
311
|
+
nested: 'value',
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
},
|
|
315
|
+
loaded: true,
|
|
316
|
+
loading: false,
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
expect(navigationReducer(initialState, action)).toEqual(expectedState);
|
|
320
|
+
});
|
|
321
|
+
|
|
322
|
+
it('should handle success action with null hideChildrenFromNavigation', () => {
|
|
323
|
+
const action = {
|
|
324
|
+
type: `${GET_NAVIGATION_SETTINGS}_SUCCESS`,
|
|
325
|
+
result: {
|
|
326
|
+
'@id': '/test-page',
|
|
327
|
+
title: 'Test Page',
|
|
328
|
+
hideChildrenFromNavigation: null,
|
|
329
|
+
},
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
const expectedState = {
|
|
333
|
+
...initialState,
|
|
334
|
+
error: null,
|
|
335
|
+
items: {
|
|
336
|
+
'/test-page': {
|
|
337
|
+
'@id': '/test-page',
|
|
338
|
+
title: 'Test Page',
|
|
339
|
+
hideChildrenFromNavigation: null, // null values are preserved
|
|
340
|
+
},
|
|
341
|
+
},
|
|
342
|
+
loaded: true,
|
|
343
|
+
loading: false,
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
expect(navigationReducer(initialState, action)).toEqual(expectedState);
|
|
347
|
+
});
|
|
348
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Navigation reducer.
|
|
3
|
+
* @module reducers/navigation
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { GET_NAVIGATION_SETTINGS } from '../constants/ActionTypes';
|
|
7
|
+
|
|
8
|
+
const initialState = {
|
|
9
|
+
error: null,
|
|
10
|
+
loaded: false,
|
|
11
|
+
loading: false,
|
|
12
|
+
settings: {},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Navigation reducer.
|
|
17
|
+
* @function navigation
|
|
18
|
+
* @param {Object} state Current state.
|
|
19
|
+
* @param {Object} action Action to be performed.
|
|
20
|
+
* @returns {Object} New state.
|
|
21
|
+
*/
|
|
22
|
+
export default function navigationSettings(state = initialState, action = {}) {
|
|
23
|
+
switch (action.type) {
|
|
24
|
+
case `${GET_NAVIGATION_SETTINGS}_PENDING`:
|
|
25
|
+
return {
|
|
26
|
+
...state,
|
|
27
|
+
error: null,
|
|
28
|
+
loaded: false,
|
|
29
|
+
loading: true,
|
|
30
|
+
};
|
|
31
|
+
case `${GET_NAVIGATION_SETTINGS}_SUCCESS`:
|
|
32
|
+
return {
|
|
33
|
+
...state,
|
|
34
|
+
error: null,
|
|
35
|
+
loaded: true,
|
|
36
|
+
loading: false,
|
|
37
|
+
settings: action.result?.['eea.enhanced_navigation']?.data
|
|
38
|
+
?.navigation_settings
|
|
39
|
+
? JSON.parse(
|
|
40
|
+
action.result['eea.enhanced_navigation'].data.navigation_settings,
|
|
41
|
+
)
|
|
42
|
+
: {},
|
|
43
|
+
};
|
|
44
|
+
case `${GET_NAVIGATION_SETTINGS}_FAIL`:
|
|
45
|
+
return {
|
|
46
|
+
...state,
|
|
47
|
+
error: action.error,
|
|
48
|
+
loaded: false,
|
|
49
|
+
loading: false,
|
|
50
|
+
settings: {},
|
|
51
|
+
};
|
|
52
|
+
default:
|
|
53
|
+
return state;
|
|
54
|
+
}
|
|
55
|
+
}
|
package/src/reducers/print.js
CHANGED
|
@@ -3,19 +3,29 @@
|
|
|
3
3
|
* @module reducers/print
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
SET_ISPRINT,
|
|
8
|
+
SET_PRINT_LOADING,
|
|
9
|
+
} from '@eeacms/volto-eea-website-theme/constants/ActionTypes';
|
|
7
10
|
|
|
8
11
|
const initialState = {
|
|
9
12
|
isPrint: false,
|
|
13
|
+
isPrintLoading: false,
|
|
10
14
|
};
|
|
11
15
|
|
|
12
16
|
export default function print(state = initialState, action) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
switch (action.type) {
|
|
18
|
+
case SET_ISPRINT:
|
|
19
|
+
return {
|
|
20
|
+
...state,
|
|
21
|
+
isPrint: action.payload,
|
|
22
|
+
};
|
|
23
|
+
case SET_PRINT_LOADING:
|
|
24
|
+
return {
|
|
25
|
+
...state,
|
|
26
|
+
isPrintLoading: action.payload,
|
|
27
|
+
};
|
|
28
|
+
default:
|
|
29
|
+
return state;
|
|
20
30
|
}
|
|
21
31
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import print from './print';
|
|
2
|
+
import {
|
|
3
|
+
SET_ISPRINT,
|
|
4
|
+
SET_PRINT_LOADING,
|
|
5
|
+
} from '@eeacms/volto-eea-website-theme/constants/ActionTypes';
|
|
6
|
+
|
|
7
|
+
describe('print reducer', () => {
|
|
8
|
+
const initialState = {
|
|
9
|
+
isPrint: false,
|
|
10
|
+
isPrintLoading: false,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
it('should return the initial state', () => {
|
|
14
|
+
expect(print(undefined, {})).toEqual(initialState);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('should handle SET_ISPRINT action', () => {
|
|
18
|
+
const action = {
|
|
19
|
+
type: SET_ISPRINT,
|
|
20
|
+
payload: true,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const expectedState = {
|
|
24
|
+
isPrint: true,
|
|
25
|
+
isPrintLoading: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
expect(print(initialState, action)).toEqual(expectedState);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should handle SET_ISPRINT action with false payload', () => {
|
|
32
|
+
const currentState = {
|
|
33
|
+
isPrint: true,
|
|
34
|
+
isPrintLoading: true,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const action = {
|
|
38
|
+
type: SET_ISPRINT,
|
|
39
|
+
payload: false,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const expectedState = {
|
|
43
|
+
isPrint: false,
|
|
44
|
+
isPrintLoading: true,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
expect(print(currentState, action)).toEqual(expectedState);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should handle SET_PRINT_LOADING action', () => {
|
|
51
|
+
const action = {
|
|
52
|
+
type: SET_PRINT_LOADING,
|
|
53
|
+
payload: true,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const expectedState = {
|
|
57
|
+
isPrint: false,
|
|
58
|
+
isPrintLoading: true,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
expect(print(initialState, action)).toEqual(expectedState);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should handle SET_PRINT_LOADING action with false payload', () => {
|
|
65
|
+
const currentState = {
|
|
66
|
+
isPrint: true,
|
|
67
|
+
isPrintLoading: true,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const action = {
|
|
71
|
+
type: SET_PRINT_LOADING,
|
|
72
|
+
payload: false,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const expectedState = {
|
|
76
|
+
isPrint: true,
|
|
77
|
+
isPrintLoading: false,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
expect(print(currentState, action)).toEqual(expectedState);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should return current state for unknown action types', () => {
|
|
84
|
+
const currentState = {
|
|
85
|
+
isPrint: true,
|
|
86
|
+
isPrintLoading: true,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const action = {
|
|
90
|
+
type: 'UNKNOWN_ACTION',
|
|
91
|
+
payload: 'some value',
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
expect(print(currentState, action)).toEqual(currentState);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should preserve other state properties when handling actions', () => {
|
|
98
|
+
const currentState = {
|
|
99
|
+
isPrint: false,
|
|
100
|
+
isPrintLoading: false,
|
|
101
|
+
someOtherProperty: 'preserved',
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const action = {
|
|
105
|
+
type: SET_ISPRINT,
|
|
106
|
+
payload: true,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const expectedState = {
|
|
110
|
+
isPrint: true,
|
|
111
|
+
isPrintLoading: false,
|
|
112
|
+
someOtherProperty: 'preserved',
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
expect(print(currentState, action)).toEqual(expectedState);
|
|
116
|
+
});
|
|
117
|
+
});
|