Skip to content

Commit

Permalink
refactor: after review
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Nov 20, 2024
1 parent 38f2ef9 commit 6890245
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
31 changes: 13 additions & 18 deletions src/CourseAuthoringRoutes.test.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { MemoryRouter } from 'react-router-dom';

import CourseAuthoringRoutes from './CourseAuthoringRoutes';
import { executeThunk } from './utils';
import { getApiWaffleFlagsUrl } from './data/api';
Expand Down Expand Up @@ -61,13 +59,12 @@ describe('<CourseAuthoringRoutes>', () => {
await executeThunk(fetchWaffleFlags(courseId), store.dispatch);
});

fit('renders the PagesAndResources component when the pages and resources route is active', () => {
it('renders the PagesAndResources component when the pages and resources route is active', async () => {
render(
<MemoryRouter initialEntries={['/pages-and-resources']}>
<CourseAuthoringRoutes />
</MemoryRouter>,
<CourseAuthoringRoutes />,
{ routerProps: { initialEntries: ['/pages-and-resources'] } },
);
waitFor(() => {
await waitFor(() => {
expect(screen.getByText(pagesAndResourcesMockText)).toBeVisible();
expect(mockComponentFn).toHaveBeenCalledWith(
expect.objectContaining({
Expand All @@ -77,30 +74,28 @@ describe('<CourseAuthoringRoutes>', () => {
});
});

it('renders the EditorContainer component when the course editor route is active', () => {
it('renders the EditorContainer component when the course editor route is active', async () => {
render(
<MemoryRouter initialEntries={['/editor/video/block-id']}>
<CourseAuthoringRoutes />
</MemoryRouter>,
<CourseAuthoringRoutes />,
{ routerProps: { initialEntries: ['/editor/video/block-id'] } },
);
waitFor(() => {
await waitFor(() => {
expect(screen.queryByText(editorContainerMockText)).toBeInTheDocument();
expect(screen.queryByText(pagesAndResourcesMockText)).not.toBeInTheDocument();
expect(mockComponentFn).toHaveBeenCalledWith(
expect.objectContaining({
courseId,
learningContextId: courseId,
}),
);
});
});

it('renders the VideoSelectorContainer component when the course videos route is active', () => {
it('renders the VideoSelectorContainer component when the course videos route is active', async () => {
render(
<MemoryRouter initialEntries={['/editor/course-videos/block-id']}>
<CourseAuthoringRoutes />
</MemoryRouter>,
<CourseAuthoringRoutes />,
{ routerProps: { initialEntries: ['/editor/course-videos/block-id'] } },
);
waitFor(() => {
await waitFor(() => {
expect(screen.queryByText(videoSelectorContainerMockText)).toBeInTheDocument();
expect(screen.queryByText(pagesAndResourcesMockText)).not.toBeInTheDocument();
expect(mockComponentFn).toHaveBeenCalledWith(
Expand Down
9 changes: 4 additions & 5 deletions src/studio-home/StudioHome.test.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useSelector } from 'react-redux';
import { MemoryRouter, Routes, Route } from 'react-router-dom';
import { injectIntl } from '@edx/frontend-platform/i18n';

import { RequestStatus } from '../data/constants';
import { COURSE_CREATOR_STATES } from '../constants';
Expand Down Expand Up @@ -40,17 +39,17 @@ const RootWrapper = () => (
<Routes>
<Route
path="/home"
element={<StudioHome intl={injectIntl} />}
element={<StudioHome />}
/>
<Route
path="/libraries"
element={<StudioHome intl={injectIntl} />}
element={<StudioHome />}
/>
<Route
path="/libraries-v1"
element={<StudioHome intl={injectIntl} />}
element={<StudioHome />}
/>
</Routes>
</Routes>,
</MemoryRouter>
);

Expand Down

0 comments on commit 6890245

Please sign in to comment.