fix(path-map): Refactor pathMigrationMap for new curriculum package

This commit is contained in:
Bouncey
2018-10-07 08:52:41 +01:00
committed by mrugesh mohapatra
parent bc9b3b4ddd
commit d52ba8c6fd
3 changed files with 143 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
/* global describe expect */
const { isPlainObject } = require('lodash');
const { createPathMigrationMap } = require('./createPathMigrationMap');
const mockCurriculum = require('./__mocks__/curriculum.json');
describe('createPathMigrationMap', () => {
const pathMap = createPathMigrationMap(mockCurriculum);
it('is a function', () => {
expect(typeof createPathMigrationMap).toEqual('function');
});
it('returns an object', () => {
expect(isPlainObject(pathMap)).toBe(true);
});
it('maps a challenge title to the correct uri slug', () => {
expect.assertions(3);
const slugOne = '/learn/super-block-b/block-one/challenge-ten';
const slugTwo = '/learn/super-block-a/block-two/challenge-five';
const slugThree = '/learn/super-block-a/block-one/challenge-three';
expect(pathMap['challenge-ten']).toEqual(slugOne);
expect(pathMap['challenge-five']).toEqual(slugTwo);
expect(pathMap['challenge-three']).toEqual(slugThree);
});
it('does not add uri migrations for private challenges', () => {
expect(pathMap['challenge-nine']).toBeUndefined();
});
});