refactor: simplify challenge.block usage (#41185)

This commit is contained in:
Oliver Eyton-Williams
2021-02-23 05:22:48 +01:00
committed by GitHub
parent 3dd33d87ed
commit f8699a8d55
14 changed files with 32 additions and 47 deletions

View File

@ -13,7 +13,6 @@ import isNumeric from 'validator/lib/isNumeric';
import isURL from 'validator/lib/isURL';
import { ifNoUserSend } from '../utils/middleware';
import { dasherize } from '../../../../utils/slugs';
import { fixCompletedChallengeItem } from '../../common/utils';
import { getChallenges } from '../utils/get-curriculum';
import {
@ -144,7 +143,7 @@ export function buildUserUpdate(
export function buildChallengeUrl(challenge) {
const { superBlock, block, dashedName } = challenge;
return `/learn/${dasherize(superBlock)}/${dasherize(block)}/${dashedName}`;
return `/learn/${superBlock}/${block}/${dashedName}`;
}
// this is only called once during boot, so it can be slow.

View File

@ -159,14 +159,6 @@ describe('boot/challenge', () => {
expect(result).toEqual(requestedChallengeUrl);
});
it('can handle non-url-compliant challenge names', () => {
const challenge = { ...mockChallenge, superBlock: 'my awesome' };
const expected = '/learn/my-awesome/actual/challenge';
const result = buildChallengeUrl(challenge);
expect(result).toEqual(expected);
});
});
describe('challengeUrlResolver', () => {