Skip to content

Commit

Permalink
fix: test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
NawfalAhmed committed Apr 8, 2024
1 parent 926f9c5 commit 7eb35fa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ACCESS_TOKEN_COOKIE_NAME='edx-jwt-cookie-header-payload'
BASE_URL='localhost:1995'
COMMERCE_COORDINATOR_ORDER_DETAILS_URL='http://localhost:8140/lms/order_details_page_redirect'
CREDENTIALS_BASE_URL='http://localhost:18150'
CSRF_TOKEN_API_PATH='/csrf/api/v1/token'
ENTERPRISE_ACCESS_BASE_URL='http://localhost:18270'
Expand Down
1 change: 1 addition & 0 deletions src/setupTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { MockAuthService } from '@edx/frontend-platform/auth';
Enzyme.configure({ adapter: new Adapter() });

mergeConfig({
COMMERCE_COORDINATOR_ORDER_DETAILS_URL: process.env.COMMERCE_COORDINATOR_ORDER_DETAILS_URL || null,
LICENSE_MANAGER_URL: process.env.LICENSE_MANAGER_URL,
PREDEFINED_CATALOG_QUERIES: {
everything: 1,
Expand Down
13 changes: 13 additions & 0 deletions src/users/enrollments/Enrollments.test.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import { mount } from 'enzyme';
import React from 'react';
import { getConfig } from '@edx/frontend-platform';
import Enrollments from './Enrollments';
import { enrollmentsData } from '../data/test/enrollments';
import UserMessagesProvider from '../../userMessages/UserMessagesProvider';
import { waitForComponentToPaint } from '../../setupTest';
import * as api from '../data/api';

jest.mock('@edx/frontend-platform', () => ({
...jest.requireActual('@edx/frontend-platform'),
getConfig: jest.fn(() => ({
ECOMMERCE_BASE_URL: 'http://example.com',
COMMERCE_COORDINATOR_ORDER_DETAILS_URL: 'http://example.com/coordinater/',
})),
}));

const EnrollmentPageWrapper = (props) => (
<UserMessagesProvider>
<Enrollments {...props} />
Expand Down Expand Up @@ -123,6 +132,10 @@ describe('Course Enrollments Listing', () => {
});

it('Enterprise course enrollments table is not rendered if are no enterprise course enrollments', async () => {
getConfig.mockReturnValue({
ECOMMERCE_BASE_URL: 'http://example.com',
COMMERCE_COORDINATOR_ORDER_DETAILS_URL: null,
});
const mockEnrollments = [{
...enrollmentsData[0],
enterpriseCourseEnrollments: [],
Expand Down

0 comments on commit 7eb35fa

Please sign in to comment.