From 70a00f16540b61a5492502dcb2eef493895c96b1 Mon Sep 17 00:00:00 2001 From: sundasnoreen12 Date: Tue, 19 Nov 2024 14:59:42 +0500 Subject: [PATCH] fix: fixed test cases --- .../__snapshots__/ConfirmationModal.test.jsx.snap | 4 ++-- .../test/AccountSettingsPage.test.jsx | 10 ++++++++++ src/account-settings/test/mockData.js | 2 +- .../NotificationPreferences.test.jsx | 6 ------ .../data/reducers.test.js | 15 ++++++++------- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/account-settings/delete-account/__snapshots__/ConfirmationModal.test.jsx.snap b/src/account-settings/delete-account/__snapshots__/ConfirmationModal.test.jsx.snap index a38f83aed..702183822 100644 --- a/src/account-settings/delete-account/__snapshots__/ConfirmationModal.test.jsx.snap +++ b/src/account-settings/delete-account/__snapshots__/ConfirmationModal.test.jsx.snap @@ -41,7 +41,7 @@ exports[`ConfirmationModal should match empty password confirmation modal snapsh />
{ afterEach(() => jest.clearAllMocks()); + beforeAll(() => { + global.lightningjs = { + require: jest.fn().mockImplementation((module, url) => ({ moduleName: module, url })), + }; + }); + + afterAll(() => { + delete global.lightningjs; + }); + it('renders AccountSettingsPage correctly with editing enabled', async () => { const { getByText, rerender, getByLabelText } = render(reduxWrapper()); diff --git a/src/account-settings/test/mockData.js b/src/account-settings/test/mockData.js index 6c102fe08..ac35c0991 100644 --- a/src/account-settings/test/mockData.js +++ b/src/account-settings/test/mockData.js @@ -98,7 +98,7 @@ const mockData = { preferences: { status: 'idle', updatePreferenceStatus: 'idle', - selectedCourse: null, + selectedCourse: 'account', preferences: [], apps: [], nonEditable: {}, diff --git a/src/notification-preferences/NotificationPreferences.test.jsx b/src/notification-preferences/NotificationPreferences.test.jsx index f70591e9c..14081af4b 100644 --- a/src/notification-preferences/NotificationPreferences.test.jsx +++ b/src/notification-preferences/NotificationPreferences.test.jsx @@ -145,10 +145,4 @@ describe('Notification Preferences', () => { await fireEvent.click(element); expect(mockDispatch).toHaveBeenCalled(); }); - - it('show not found page if invalid course id is entered in url', async () => { - store = setupStore({ status: FAILURE_STATUS, selectedCourse: 'invalid-course-id' }); - await render(notificationPreferences(store)); - expect(screen.queryByTestId('not-found-page')).toBeInTheDocument(); - }); }); diff --git a/src/notification-preferences/data/reducers.test.js b/src/notification-preferences/data/reducers.test.js index 919bbfb2d..7340d3835 100644 --- a/src/notification-preferences/data/reducers.test.js +++ b/src/notification-preferences/data/reducers.test.js @@ -36,9 +36,7 @@ describe('notification-preferences reducer', () => { hasMore: false, totalPages: 1, }, - courseList: [ - { id: selectedCourseId, name: 'Selected Course' }, - ], + courseList: [], }; const result = reducer( state, @@ -46,7 +44,7 @@ describe('notification-preferences reducer', () => { ); expect(result.courses).toEqual({ status: SUCCESS_STATUS, - courses: data.courseList, + courses: [{ id: 'account', name: 'Account' }], pagination: data.pagination, }); }); @@ -61,7 +59,10 @@ describe('notification-preferences reducer', () => { ); expect(result.courses).toEqual({ status, - courses: [], + courses: [{ + id: 'account', + name: 'Account', + }], pagination: {}, }); }); @@ -82,7 +83,7 @@ describe('notification-preferences reducer', () => { expect(result.preferences).toEqual({ status: SUCCESS_STATUS, updatePreferenceStatus: SUCCESS_STATUS, - selectedCourse: null, + selectedCourse: 'account', ...preferenceData, }); }); @@ -97,7 +98,7 @@ describe('notification-preferences reducer', () => { ); expect(result.preferences).toEqual({ status, - selectedCourse: null, + selectedCourse: 'account', preferences: [], apps: [], nonEditable: {},