|
1 |
| -import { reducer, updateStudioHomeCoursesCustomParams } from './slice'; |
| 1 | +import { reducer, resetStudioHomeCoursesCustomParams, updateStudioHomeCoursesCustomParams } from './slice'; |
2 | 2 |
|
3 | 3 | import { RequestStatus } from '../../data/constants';
|
4 | 4 |
|
@@ -26,36 +26,44 @@ describe('updateStudioHomeCoursesCustomParams action', () => {
|
26 | 26 | },
|
27 | 27 | };
|
28 | 28 |
|
29 |
| - it('should return the initial state', () => { |
30 |
| - const result = reducer(undefined, { type: undefined }); |
31 |
| - expect(result).toEqual(initialState); |
32 |
| - }); |
33 |
| - |
34 |
| - it('should update the payload passed in studioHomeCoursesRequestParams', () => { |
35 |
| - const newState = { |
36 |
| - ...initialState, |
37 |
| - studioHomeCoursesRequestParams: { |
38 |
| - currentPage: 2, |
39 |
| - search: 'test', |
40 |
| - order: 'display_name', |
41 |
| - archivedOnly: true, |
42 |
| - activeOnly: true, |
43 |
| - isFiltered: true, |
44 |
| - cleanFilters: true, |
45 |
| - }, |
46 |
| - }; |
47 |
| - |
48 |
| - const payload = { |
| 29 | + const modifiedRequestParamsState = { |
| 30 | + ...initialState, |
| 31 | + studioHomeCoursesRequestParams: { |
49 | 32 | currentPage: 2,
|
50 | 33 | search: 'test',
|
51 | 34 | order: 'display_name',
|
52 | 35 | archivedOnly: true,
|
53 | 36 | activeOnly: true,
|
54 | 37 | isFiltered: true,
|
55 | 38 | cleanFilters: true,
|
56 |
| - }; |
| 39 | + }, |
| 40 | + }; |
| 41 | + |
| 42 | + const payload = { |
| 43 | + currentPage: 2, |
| 44 | + search: 'test', |
| 45 | + order: 'display_name', |
| 46 | + archivedOnly: true, |
| 47 | + activeOnly: true, |
| 48 | + isFiltered: true, |
| 49 | + cleanFilters: true, |
| 50 | + }; |
| 51 | + |
| 52 | + it('should return the initial state', () => { |
| 53 | + const result = reducer(undefined, { type: undefined }); |
| 54 | + expect(result).toEqual(initialState); |
| 55 | + }); |
57 | 56 |
|
| 57 | + it('should update the payload passed in studioHomeCoursesRequestParams', () => { |
58 | 58 | const result = reducer(initialState, updateStudioHomeCoursesCustomParams(payload));
|
59 |
| - expect(result).toEqual(newState); |
| 59 | + expect(result).toEqual(modifiedRequestParamsState); |
| 60 | + }); |
| 61 | + |
| 62 | + it('should reset the studioHomeCoursesRequestParams state to the initial value', () => { |
| 63 | + const stateChanged = reducer(initialState, updateStudioHomeCoursesCustomParams(payload)); |
| 64 | + expect(stateChanged).toEqual(modifiedRequestParamsState); |
| 65 | + |
| 66 | + const stateReset = reducer(stateChanged, resetStudioHomeCoursesCustomParams()); |
| 67 | + expect(stateReset.studioHomeCoursesRequestParams).toEqual(initialState.studioHomeCoursesRequestParams); |
60 | 68 | });
|
61 | 69 | });
|
0 commit comments