test: adding test for studio home slice

This commit is contained in:
Jhon Vente
2024-02-08 13:56:25 -05:00
parent d6e2e91b9a
commit 1f6d30ff23

View 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);
});
});