Merge pull request #181 from raccoongang/palm/fix-location-id

This commit is contained in:
Adolfo R. Brandes
2023-05-15 10:37:48 -03:00
committed by GitHub
2 changed files with 4 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
import { getConfig } from '@edx/frontend-platform';
export const routePath = `${getConfig().PUBLIC_PATH}:courseId`;
export const locationId = window.location.pathname.slice(1);
export const locationId = window.location.pathname.replace(getConfig().PUBLIC_PATH, '');

View File

@@ -4,7 +4,7 @@ import * as constants from './app';
jest.unmock('./app');
jest.mock('@edx/frontend-platform', () => {
const PUBLIC_PATH = 'test-public-path';
const PUBLIC_PATH = '/test-public-path/';
return {
getConfig: () => ({ PUBLIC_PATH }),
PUBLIC_PATH,
@@ -17,8 +17,8 @@ describe('app constants', () => {
});
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 = { pathName: `${platform.PUBLIC_PATH}somePath.jpg` };
expect(constants.locationId).toEqual(window.location.pathname.replace(platform.PUBLIC_PATH, ''));
window.location = old;
});
});