Repository navigation
FC-86 feat: Empty page templates #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
c8dc06b
46017bd
1ed63c6
6c0f09d
f39ac73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| const CourseAboutPage = () => ( | ||
| // TODO: remove it when will start develop page | ||
| <h1>Course About Page</h1> | ||
| ); | ||
|
|
||
| export default CourseAboutPage; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| const HomePage = () => ( | ||
| // TODO: remove it when will start develop page | ||
| <h1>Home page</h1> | ||
| ); | ||
|
|
||
| export default HomePage; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| import React from 'react'; | ||
| import { Routes, Route } from 'react-router-dom'; | ||
| import { AppProvider } from '@edx/frontend-platform/react'; | ||
|
|
||
| import HomePage from './home/HomePage'; | ||
| import CatalogPage from './сatalog/CatalogPage'; | ||
| import CourseAboutPage from './course-about/CourseAboutPage'; | ||
| import { render } from './setupTest'; | ||
|
|
||
| jest.mock('@edx/frontend-platform', () => ({ | ||
| ...jest.requireActual('@edx/frontend-platform'), | ||
| getAuthenticatedUser: () => ({ username: 'test_user', roles: [] }), | ||
| })); | ||
|
|
||
| jest.mock('@edx/frontend-platform/react', () => { | ||
| const original = jest.requireActual('@edx/frontend-platform/react'); | ||
| return { | ||
| ...original, | ||
| useAuthenticatedUser: () => ({ username: 'test_user', roles: [] }), | ||
| // eslint-disable-next-line react/prop-types | ||
| AppProvider: ({ children }) => <div>{children}</div>, | ||
| }; | ||
| }); | ||
|
|
||
| jest.mock('@edx/frontend-component-header', () => ( | ||
| <header>Header</header> | ||
| )); | ||
|
|
||
| jest.mock('@edx/frontend-component-footer', () => ({ | ||
| FooterSlot: () => <footer>Footer</footer>, | ||
| })); | ||
|
|
||
| const renderWithProviders = (path = '/') => { | ||
| // eslint-disable-next-line no-underscore-dangle | ||
| window._testHistory = [path]; | ||
|
|
||
| return render( | ||
| <AppProvider> | ||
| <Routes> | ||
| <Route path="/" element={<HomePage />} /> | ||
| <Route path="/courses" element={<CatalogPage />} /> | ||
| <Route path="/courses/:courseId/about" element={<CourseAboutPage />} /> | ||
| </Routes> | ||
| </AppProvider>, | ||
| ); | ||
| }; | ||
|
|
||
| describe('App routing', () => { | ||
| it('renders HomePage at route /', () => { | ||
| const { getByText } = renderWithProviders('/'); | ||
|
|
||
| expect(getByText('Home page')).toBeInTheDocument(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this will work for now, it will need to be updated as soon as the placeholder
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
| }); | ||
|
|
||
| it('renders CatalogPage at route /courses', () => { | ||
| const { getByText } = renderWithProviders('/courses'); | ||
|
|
||
| expect(getByText('Catalog Page')).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('renders CourseAboutPage at route /courses/123/about', () => { | ||
| const { getByText } = renderWithProviders('/courses/123/about'); | ||
|
|
||
| expect(getByText('Course About Page')).toBeInTheDocument(); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,40 @@ | ||
| import 'core-js/stable'; | ||
| import 'regenerator-runtime/runtime'; | ||
| import '@testing-library/jest-dom'; | ||
| import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
| import { render as rtlRender } from '@testing-library/react'; | ||
| import PropTypes from 'prop-types'; | ||
| import { MemoryRouter } from 'react-router-dom'; | ||
| import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
|
|
||
| function render(ui) { | ||
| const queryClient = new QueryClient({ | ||
| defaultOptions: { | ||
| queries: { | ||
| retry: false, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| const Wrapper = ({ children }) => ( | ||
| // eslint-disable-next-line react/jsx-filename-extension | ||
| <QueryClientProvider client={queryClient}> | ||
| {/* eslint-disable-next-line no-underscore-dangle */} | ||
| <MemoryRouter initialEntries={window._testHistory || ['/']}> | ||
| <IntlProvider locale="en"> | ||
| {children} | ||
| </IntlProvider> | ||
| </MemoryRouter> | ||
| </QueryClientProvider> | ||
| ); | ||
|
|
||
| Wrapper.propTypes = { | ||
| children: PropTypes.node.isRequired, | ||
| }; | ||
|
|
||
| return rtlRender(ui, { wrapper: Wrapper }); | ||
| } | ||
|
|
||
| export { | ||
| render, | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| const CatalogPage = () => ( | ||
| // TODO: remove it when will start develop page | ||
| <h1>Catalog Page</h1> | ||
| ); | ||
|
|
||
| export default CatalogPage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some spacing between these lines jest.mocks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed