Update pathmap generation for roadmap routes

pull/1331/head
Kamran Ahmed 5 years ago
parent 0b72a07147
commit b53f8c982c
  1. 2
      scripts/path-map.js
  2. 27
      test/path-map.spec.js

@ -87,8 +87,6 @@ const getRoadmapRoutes = () => {
}, {});
};
console.log(getRoadmapRoutes());
/**
* Generates the path-map understood by next.js
* @returns {{}}

@ -1,5 +1,6 @@
const path = require('path');
const fs = require('fs');
const glob = require('glob');
const guides = require('../storage/guides');
const roadmaps = require('../storage/roadmaps');
@ -57,29 +58,5 @@ describe("Build scripts tests", () => {
})
});
test('it should generate valid roadmap routes', () => {
const expectedPathMap = roadmaps.reduce((roadmapAcc, roadmap) => {
// Routes for each of the versions of this roadmap
const versionRoutes = (roadmap.versions || []).reduce((versionAcc, version) => ({
...versionAcc,
[`${roadmap.url}/${version}`]: {
page: '/[roadmap]/[version]',
query: `${roadmap.url.split('/')[1]}/${version}`,
}
}), {});
// Route for the route roadmap itself
return {
...roadmapAcc,
[roadmap.url]: {
page: '/[roadmap]',
query: roadmap.url.split('/')[1]
},
// Expected roadmap for versions
...versionRoutes
};
}, {});
expect(getRoadmapRoutes()).toEqual(expectedPathMap);
})
// @todo add tests for roadmap pathmap
});

Loading…
Cancel
Save