frontend-platform supports runtime configuration since 2.5.0 (see the PR that introduced it[1], but it requires MFE cooperation. This implements just that: by avoiding making configuration values constant, it should now be possible to change them after initialization. Only a single change related to the `LMS_BASE_URL` setting was required. [1] openedx/frontend-platform#335
25 lines
960 B
JavaScript
25 lines
960 B
JavaScript
import { Factory } from 'rosie'; // eslint-disable-line import/no-extraneous-dependencies
|
|
import { camelCaseObject } from '@edx/frontend-platform';
|
|
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
|
|
import MockAdapter from 'axios-mock-adapter';
|
|
import { initializeMockApp } from '../../../setupTest';
|
|
import * as api from './api';
|
|
import './__factories__/courseMetadata.factory';
|
|
|
|
describe('api', () => {
|
|
beforeAll(async () => {
|
|
await initializeMockApp();
|
|
});
|
|
|
|
test('getCourseHomeCourseMetadata', async () => {
|
|
const axiosMock = new MockAdapter(getAuthenticatedHttpClient());
|
|
const courseMetadata = Factory.build('courseMetadata');
|
|
const { id: courseId } = courseMetadata;
|
|
axiosMock
|
|
.onGet(`${api.getCourseHomeBaseUrl()}/${courseId}`)
|
|
.reply(200, courseMetadata);
|
|
const data = await api.getCourseHomeCourseMetadata(courseId);
|
|
expect(data).toEqual(camelCaseObject(courseMetadata));
|
|
});
|
|
});
|