mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-13 06:48:08 +02:00
test: genRoutesConfig
This commit is contained in:
parent
084063eabe
commit
8a5807418d
3 changed files with 209 additions and 1 deletions
39
test/load/routes.test.js
Normal file
39
test/load/routes.test.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
import genRoutesConfig from '@lib/load/routes';
|
||||
import loadDocs from '@lib/load/docs';
|
||||
import loadPages from '@lib/load/pages';
|
||||
import path from 'path';
|
||||
|
||||
describe('genRoutesConfig', () => {
|
||||
const pagesDir = path.join(__dirname, '__fixtures__', 'simple-pages');
|
||||
const docsDir = path.join(__dirname, '__fixtures__', 'simple-docs');
|
||||
|
||||
test('website with pages and docs', async () => {
|
||||
const props = {
|
||||
docsData: await loadDocs(docsDir),
|
||||
pagesData: await loadPages(pagesDir)
|
||||
};
|
||||
const routes = await genRoutesConfig(props);
|
||||
expect(routes).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('website with only pages', async () => {
|
||||
const props = {
|
||||
pagesData: await loadPages(pagesDir)
|
||||
};
|
||||
const routes = await genRoutesConfig(props);
|
||||
expect(routes).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('website with only docs', async () => {
|
||||
const props = {
|
||||
docsData: await loadDocs(docsDir)
|
||||
};
|
||||
const routes = await genRoutesConfig(props);
|
||||
expect(routes).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('website with no docs/pages', async () => {
|
||||
const routes = await genRoutesConfig({});
|
||||
expect(routes).toMatchSnapshot();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue