Update pathmap generation for roadmap routes

pull/1657/head
Kamran Ahmed 5 years ago
parent ce984825a5
commit 9b5f23f6f7
  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 * Generates the path-map understood by next.js
* @returns {{}} * @returns {{}}

@ -1,5 +1,6 @@
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const glob = require('glob');
const guides = require('../storage/guides'); const guides = require('../storage/guides');
const roadmaps = require('../storage/roadmaps'); const roadmaps = require('../storage/roadmaps');
@ -57,29 +58,5 @@ describe("Build scripts tests", () => {
}) })
}); });
test('it should generate valid roadmap routes', () => { // @todo add tests for roadmap pathmap
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);
})
}); });

Loading…
Cancel
Save