Files
frontend-app-learner-dashboard/src/data/constants/app.test.js
2022-05-25 14:27:26 -04:00

25 lines
717 B
JavaScript

import * as platform from '@edx/frontend-platform';
import * as constants from './app';
jest.unmock('./app');
jest.mock('@edx/frontend-platform', () => {
const PUBLIC_PATH = 'test-public-path';
return {
getConfig: () => ({ PUBLIC_PATH }),
PUBLIC_PATH,
};
});
describe('app constants', () => {
test('route path draws from public path and adds courseId', () => {
expect(constants.routePath).toEqual(`${platform.PUBLIC_PATH}:courseId`);
});
test('locationId returns trimmed pathname', () => {
const old = window.location;
window.location = { pathName: '/somePath.jpg' };
expect(constants.locationId).toEqual(window.location.pathname.slice(1));
window.location = old;
});
});