Merge pull request #181 from raccoongang/palm/fix-location-id
This commit is contained in:
@@ -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, '');
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user