Skip to content

Commit 95ebf9d

Browse files
committed
tests: improve test coverage
1 parent eb6203a commit 95ebf9d

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

src/studio-home/data/slice.test.js

+31-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { reducer, updateStudioHomeCoursesCustomParams } from './slice';
1+
import { reducer, resetStudioHomeCoursesCustomParams, updateStudioHomeCoursesCustomParams } from './slice';
22

33
import { RequestStatus } from '../../data/constants';
44

@@ -26,36 +26,44 @@ describe('updateStudioHomeCoursesCustomParams action', () => {
2626
},
2727
};
2828

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: {
4932
currentPage: 2,
5033
search: 'test',
5134
order: 'display_name',
5235
archivedOnly: true,
5336
activeOnly: true,
5437
isFiltered: true,
5538
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+
});
5756

57+
it('should update the payload passed in studioHomeCoursesRequestParams', () => {
5858
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);
6068
});
6169
});

0 commit comments

Comments
 (0)