diff --git a/src/studio-home/data/slice.test.js b/src/studio-home/data/slice.test.js new file mode 100644 index 000000000..dc7e1df55 --- /dev/null +++ b/src/studio-home/data/slice.test.js @@ -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); + }); +});