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.
59 lines
1.7 KiB
59 lines
1.7 KiB
const path = require('path'); |
|
const fs = require('fs'); |
|
const guides = require('../content/guides'); |
|
|
|
const { |
|
getPageRoutes, |
|
getGuideRoutes, |
|
} = 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, `../content/guides/${slug}.md`); |
|
const foundFile = fs.existsSync(expectedFile) ? expectedFile : ''; |
|
|
|
expect(foundFile).toEqual(expectedFile); |
|
}) |
|
}); |
|
|
|
// @todo add tests for roadmap pathmap |
|
});
|
|
|