Skip to content

Commit

Permalink
chore: fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rijuma committed Dec 16, 2024
1 parent 4bd5522 commit 1e56ec3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import TrialDisclosure from '.';
const mockedUpgradeUrl = 'https://upgrade.edx/course/test';
const mockedAuditTrialDays = 7;

jest.mock('../../hooks', () => ({
useCourseUpgrade: jest.fn(),
useTrackEvent: jest.fn(() => ({ track: jest.fn() })),
}));

const PRIVACY_POLICY_URL = 'https://some.url/policy';
jest.mock('@edx/frontend-platform/config', () => ({
ensureConfig: jest.fn(),
getConfig: () => ({ PRIVACY_POLICY_URL }),
}));

jest.mock('../../hooks', () => ({
useCourseUpgrade: jest.fn(),
useTrackEvent: jest.fn(() => ({ track: jest.fn() })),
}));

describe('<TrialDisclosure />', () => {
let container;

Expand Down
1 change: 0 additions & 1 deletion src/hooks/use-course-upgrade.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useModel } from '@src/generic/model-store'; // eslint-disable-line impo
import { CourseInfoProvider } from '../context';
import useCourseUpgrade from './use-course-upgrade';

jest.mock('@src/generic/model-store', () => ({ useModel: jest.fn() }), { virtual: true });
jest.mock('react-redux', () => ({ useSelector: jest.fn() }));

const mockedUpgradeUrl = 'https://upgrade.edx/course/test';
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-track-event.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const renderHook = ({
{ wrapper: contextWrapper({ courseInfo }) },
);

describe('useCourseUpgrade()', () => {
describe('useTrackEvent()', () => {
afterEach(() => jest.resetAllMocks());

it('should return a track method that calls sendTrackEvent with the contextual information', () => {
Expand Down
7 changes: 7 additions & 0 deletions src/setupTest.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import '@testing-library/jest-dom';
import { mergeConfig } from '@edx/frontend-platform';

jest.mock('./hooks', () => ({
useCourseUpgrade: () => ({ upgradeable: false }),
useTrackEvent: () => ({ track: () => {} }),
}));

jest.mock('@src/generic/model-store', () => ({ useModel: jest.fn() }), { virtual: true });

mergeConfig({
...process.env,
});

0 comments on commit 1e56ec3

Please sign in to comment.