Skip to content

Commit

Permalink
♻️(frontend) missing richie context
Browse files Browse the repository at this point in the history
To instanciate our generated api client, we need to build joanie's
endpoint.
Even if no api call are made on theses test, they need to mock richie
context.
  • Loading branch information
rlecellier committed Mar 6, 2024
1 parent e1c5394 commit 1a38c6f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
20 changes: 15 additions & 5 deletions src/frontend/js/components/CourseGlimpseList/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import { render, screen } from '@testing-library/react';
import { IntlProvider } from 'react-intl';

import { RichieContextFactory, CourseLightFactory } from 'utils/test/factories/richie';
import { CommonDataProps } from 'types/commonDataProps';
import { render, screen } from '@testing-library/react';
import { CourseStateTextEnum, Priority } from 'types';
import { CommonDataProps } from 'types/commonDataProps';
import {
CourseLightFactory,
RichieContextFactory as mockRichieContextFactory,
} from 'utils/test/factories/richie';

import { CourseGlimpseList, getCourseGlimpseListProps } from '.';

jest.mock('utils/context', () => ({
__esModule: true,
default: mockRichieContextFactory({
joanie_backend: { endpoint: 'https://joanie.endpoint' },
}).one(),
}));

describe('widgets/Search/components/CourseGlimpseList', () => {
const contextProps: CommonDataProps['context'] = RichieContextFactory().one();
const contextProps: CommonDataProps['context'] = mockRichieContextFactory().one();

it('renders a list of Courses into a list of CourseGlimpses', () => {
const courses = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
import { createIntl } from 'react-intl';
import { screen } from '@testing-library/react';
import { getAllByRole, within } from '@testing-library/dom';
import { faker } from '@faker-js/faker';
import { getAllByRole, within } from '@testing-library/dom';
import { screen } from '@testing-library/react';
import { NestedCourseOrderFactory } from 'utils/test/factories/joanieLegacy';
import { expectNoSpinner } from 'utils/test/expectSpinner';
import { PaginationFactory } from 'utils/test/factories/cunningham';
import { DEFAULT_DATE_FORMAT } from 'hooks/useDateFormat';
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
import { OrderState } from 'types/Joanie';
import { render } from 'utils/test/render';
import { PresentationalAppWrapper } from 'utils/test/wrappers/PresentationalAppWrapper';

import CourseLearnerDataGrid from '.';

jest.mock('utils/context', () => ({
__esModule: true,
default: mockRichieContextFactory({
joanie_backend: { endpoint: 'https://joanie.endpoint' },
}).one(),
}));

describe('pages/CourseLearnerDataGrid', () => {
it('should render a list of user', async () => {
const courseOrderList = NestedCourseOrderFactory({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import { PropsWithChildren } from 'react';

import { IntlProvider } from 'react-intl';
import { renderHook } from '@testing-library/react';
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';

import useDashboardRoutes from '.';

jest.mock('utils/context', () => ({
__esModule: true,
default: mockRichieContextFactory({
joanie_backend: { endpoint: 'https://joanie.endpoint' },
}).one(),
}));

describe('useDashboardRouter', () => {
const Wrapper = ({ children }: PropsWithChildren<{}>) => (
<IntlProvider locale="en">{children}</IntlProvider>
Expand Down

0 comments on commit 1a38c6f

Please sign in to comment.