computer-scienceangular-roadmapbackend-roadmapblockchain-roadmapdba-roadmapdeveloper-roadmapdevops-roadmapfrontend-roadmapgo-roadmaphactoberfestjava-roadmapjavascript-roadmapnodejs-roadmappython-roadmapqa-roadmapreact-roadmaproadmapstudy-planvue-roadmapweb3-roadmap
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.7 KiB
62 lines
1.7 KiB
const path = require('path'); |
|
const fs = require('fs'); |
|
const glob = require('glob'); |
|
const guides = require('../storage/guides'); |
|
const roadmaps = require('../storage/roadmaps'); |
|
|
|
const { |
|
getPageRoutes, |
|
getGuideRoutes, |
|
getRoadmapRoutes |
|
} = require("../scripts/path-map"); |
|
|
|
describe("Build scripts tests", () => { |
|
test('it should generate valid pathmap for pages', () => { |
|
const pageRoutes = getPageRoutes(); |
|
|
|
expect(pageRoutes).toEqual({ |
|
'/': { page: '/index' }, |
|
'/about': { page: '/about' }, |
|
'/privacy': { page: '/privacy' }, |
|
'/terms': { page: '/terms' }, |
|
'/guides': { page: '/guides/index' }, |
|
'/roadmaps': { page: '/roadmaps' }, |
|
'/signup': { page: '/signup' }, |
|
}); |
|
}); |
|
|
|
test('it should generate valid guides pathmap', () => { |
|
const expectedGuideRoutes = guides.reduce((acc, guide) => { |
|
const [,, slug] = guide.url.split('/'); |
|
return { |
|
...acc, |
|
[guide.url]: { |
|
page: '/guides/[guide]', |
|
query: slug, |
|
} |
|
}; |
|
}, {}); |
|
|
|
// Valid path map is generated |
|
expect(expectedGuideRoutes).toEqual(getGuideRoutes()); |
|
|
|
const pageFilePath = path.join(__dirname, '../pages/guides/[guide].js'); |
|
const foundFilePath = fs.existsSync(pageFilePath) ? pageFilePath : ''; |
|
|
|
// Given page component exists |
|
expect(foundFilePath).toEqual(pageFilePath); |
|
}); |
|
|
|
test('it should have markdown file for each guide', () => { |
|
guides.forEach(guide => { |
|
const [,, slug] = guide.url.split('/'); |
|
|
|
const expectedFile = path.join(__dirname, `../storage/guides/${slug}.md`); |
|
const foundFile = fs.existsSync(expectedFile) ? expectedFile : ''; |
|
|
|
expect(foundFile).toEqual(expectedFile); |
|
}) |
|
}); |
|
|
|
// @todo add tests for roadmap pathmap |
|
});
|
|
|