Skip to content

Commit

Permalink
fix: fixed test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
sundasnoreen12 committed Nov 19, 2024
1 parent 27c686f commit 301797a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
10 changes: 10 additions & 0 deletions src/account-settings/test/AccountSettingsPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ describe('AccountSettingsPage', () => {

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(<IntlAccountSettingsPage {...props} />));

Expand Down
2 changes: 1 addition & 1 deletion src/account-settings/test/mockData.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const mockData = {
preferences: {
status: 'idle',
updatePreferenceStatus: 'idle',
selectedCourse: null,
selectedCourse: 'account',
preferences: [],
apps: [],
nonEditable: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { fireEvent, render, screen } from '@testing-library/react';

import { defaultState } from './data/reducers';
import NotificationPreferences from './NotificationPreferences';
import { FAILURE_STATUS, LOADING_STATUS, SUCCESS_STATUS } from '../constants';
import { LOADING_STATUS, SUCCESS_STATUS } from '../constants';

const courseId = 'selected-course-id';

Expand Down Expand Up @@ -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();
});
});
15 changes: 8 additions & 7 deletions src/notification-preferences/data/reducers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,15 @@ describe('notification-preferences reducer', () => {
hasMore: false,
totalPages: 1,
},
courseList: [
{ id: selectedCourseId, name: 'Selected Course' },
],
courseList: [],
};
const result = reducer(
state,
{ type: Actions.FETCHED_COURSE_LIST, payload: data },
);
expect(result.courses).toEqual({
status: SUCCESS_STATUS,
courses: data.courseList,
courses: [{ id: 'account', name: 'Account' }],
pagination: data.pagination,
});
});
Expand All @@ -61,7 +59,10 @@ describe('notification-preferences reducer', () => {
);
expect(result.courses).toEqual({
status,
courses: [],
courses: [{
id: 'account',
name: 'Account',
}],
pagination: {},
});
});
Expand All @@ -82,7 +83,7 @@ describe('notification-preferences reducer', () => {
expect(result.preferences).toEqual({
status: SUCCESS_STATUS,
updatePreferenceStatus: SUCCESS_STATUS,
selectedCourse: null,
selectedCourse: 'account',
...preferenceData,
});
});
Expand All @@ -97,7 +98,7 @@ describe('notification-preferences reducer', () => {
);
expect(result.preferences).toEqual({
status,
selectedCourse: null,
selectedCourse: 'account',
preferences: [],
apps: [],
nonEditable: {},
Expand Down

0 comments on commit 301797a

Please sign in to comment.