test: adding test for studio home slice
This commit is contained in:
42
src/studio-home/data/slice.test.js
Normal file
42
src/studio-home/data/slice.test.js
Normal file
@@ -0,0 +1,42 @@
|
||||
import { reducer, updateStudioHomeCoursesCustomParams } from './slice'; // Assuming the file is named slice.js
|
||||
|
||||
import { RequestStatus } from '../../data/constants';
|
||||
|
||||
describe('updateStudioHomeCoursesCustomParams action', () => {
|
||||
const initialState = {
|
||||
loadingStatuses: {
|
||||
studioHomeLoadingStatus: RequestStatus.IN_PROGRESS,
|
||||
courseNotificationLoadingStatus: RequestStatus.IN_PROGRESS,
|
||||
courseLoadingStatus: RequestStatus.IN_PROGRESS,
|
||||
libraryLoadingStatus: RequestStatus.IN_PROGRESS,
|
||||
},
|
||||
savingStatuses: {
|
||||
courseCreatorSavingStatus: '',
|
||||
deleteNotificationSavingStatus: '',
|
||||
},
|
||||
studioHomeData: {},
|
||||
studioHomeCoursesCustomParams: {
|
||||
currentPage: 1,
|
||||
},
|
||||
};
|
||||
|
||||
it('should return the initial state', () => {
|
||||
const result = reducer(undefined, { type: undefined });
|
||||
expect(result).toEqual(initialState);
|
||||
});
|
||||
|
||||
it('should update the currentPage in studioHomeCoursesCustomParams', () => {
|
||||
const newState = {
|
||||
...initialState,
|
||||
studioHomeCoursesCustomParams: {
|
||||
currentPage: 2,
|
||||
},
|
||||
};
|
||||
const payload = {
|
||||
currentPage: 2,
|
||||
};
|
||||
|
||||
const result = reducer(initialState, updateStudioHomeCoursesCustomParams(payload));
|
||||
expect(result).toEqual(newState);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user