Skip to content

Commit

Permalink
♻️(frontend) Joanie api client load in test
Browse files Browse the repository at this point in the history
Joanie's api client shouldn't be loaded on test that don't use it.
  • Loading branch information
rlecellier committed Mar 7, 2024
1 parent c078301 commit 2d3a4c2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import fetchMock from 'fetch-mock';
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
import { OrganizationFactory } from 'utils/test/factories/joanieLegacy';
import { Organization } from 'types/Joanie';
import { JoanieAppWrapper, setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
import JoanieAppWrapper, { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
import useDefaultOrganizationId from '.';

jest.mock('utils/context', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CourseProductRelationFactory,
OrganizationFactory,
} from 'utils/test/factories/joanieLegacy';
import { JoanieAppWrapper, setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
import JoanieAppWrapper, { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
import useCourseLearnersFilters from '.';

jest.mock('utils/context', () => ({
Expand Down
5 changes: 3 additions & 2 deletions src/frontend/js/utils/test/render.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { RenderResult, screen, render as testingLibraryRender } from '@testing-library/react';
import React, { ReactElement } from 'react';
import React, { ReactElement, lazy } from 'react';
import { Nullable } from 'types/utils';
import { AppWrapperProps } from './wrappers/types';
import { JoanieAppWrapper } from './wrappers/JoanieAppWrapper';

const JoanieAppWrapper = lazy(() => import('./wrappers/JoanieAppWrapper'));

// ------- setup -------

Expand Down
4 changes: 3 additions & 1 deletion src/frontend/js/utils/test/wrappers/JoanieAppWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const setupJoanieSession = () => {
};
};

export const JoanieAppWrapper = ({
const JoanieAppWrapper = ({
children,
intlOptions,
queryOptions,
Expand All @@ -35,3 +35,5 @@ export const JoanieAppWrapper = ({
</BaseJoanieAppWrapper>
);
};

export default JoanieAppWrapper;

0 comments on commit 2d3a4c2

Please sign in to comment.