Skip to content

Commit

Permalink
test: updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eemaanamir committed Nov 4, 2024
1 parent f851641 commit 07e0ec8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 19 deletions.
7 changes: 3 additions & 4 deletions src/data/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import { reducer as NewProfilePageReducer } from '../profile-v2';

const isNewProfileEnabled = process.env.ENABLE_NEW_PROFILE_VIEW === 'true';

Check warning on line 6 in src/data/reducers.js

View check run for this annotation

Codecov / codecov/patch

src/data/reducers.js#L6

Added line #L6 was not covered by tests

const createRootReducer = () =>
combineReducers({
profilePage: isNewProfileEnabled ? NewProfilePageReducer : profilePage,
});
const createRootReducer = () => combineReducers({
profilePage: isNewProfileEnabled ? NewProfilePageReducer : profilePage,

Check warning on line 9 in src/data/reducers.js

View check run for this annotation

Codecov / codecov/patch

src/data/reducers.js#L9

Added line #L9 was not covered by tests
});

export default createRootReducer;
8 changes: 5 additions & 3 deletions src/routes/AppRoutes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ const AppRoutes = () => (
<Route
path="/u/:username"
element={
<AuthenticatedPageRoute>
{isNewProfileEnabled ? <NewProfilePage /> : <ProfilePage />}
</AuthenticatedPageRoute>
(
<AuthenticatedPageRoute>
{isNewProfileEnabled ? <NewProfilePage /> : <ProfilePage />}
</AuthenticatedPageRoute>
)
}
/>
<Route
Expand Down
20 changes: 8 additions & 12 deletions src/routes/routes.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,15 @@ jest.mock('@edx/frontend-platform/auth', () => ({
getLoginRedirectUrl: jest.fn(),
}));

const isNewProfileEnabled = process.env.ENABLE_NEW_PROFILE_VIEW === 'true';
jest.mock('../profile', () => ({
ProfilePage: () => (<div>Profile page</div>),
NotFoundPage: () => (<div>Not found page</div>),
}));

if (isNewProfileEnabled) {
jest.mock('../profile-v2', () => ({
ProfilePage: () => (<div>New Profile page</div>),
NotFoundPage: () => (<div>New Not found page</div>),
}));
} else {
jest.mock('../profile', () => ({
ProfilePage: () => (<div>Profile page</div>),
NotFoundPage: () => (<div>Not found page</div>),
}));
}
jest.mock('../profile-v2', () => ({
ProfilePage: () => (<div>Profile page</div>),
NotFoundPage: () => (<div>Not found page</div>),
}));

const RoutesWithProvider = (context, path) => (
<AppContext.Provider value={context}>
Expand Down

0 comments on commit 07e0ec8

Please sign in to comment.