From 1f6d30ff239a5062f3c0d1c9aeefa2983f16c497 Mon Sep 17 00:00:00 2001 From: Jhon Vente Date: Thu, 8 Feb 2024 13:56:25 -0500 Subject: [PATCH] test: adding test for studio home slice --- src/studio-home/data/slice.test.js | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/studio-home/data/slice.test.js 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); + }); +});