mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-02 02:42:41 +02:00
test: load pages
This commit is contained in:
parent
cfd11fbb6d
commit
8f493605ad
6 changed files with 43 additions and 0 deletions
1
test/load/__fixtures__/simple-pages/bar/baz.js
Normal file
1
test/load/__fixtures__/simple-pages/bar/baz.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export default () => <div>Baz</div>;
|
1
test/load/__fixtures__/simple-pages/foo.js
Normal file
1
test/load/__fixtures__/simple-pages/foo.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export default () => <div>Foo</div>;
|
1
test/load/__fixtures__/simple-pages/foo/index.js
Normal file
1
test/load/__fixtures__/simple-pages/foo/index.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export default () => <div>Foo in subfolder</div>;
|
1
test/load/__fixtures__/simple-pages/index.js
Normal file
1
test/load/__fixtures__/simple-pages/index.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export default () => <div>Index</div>;
|
22
test/load/__snapshots__/pages.test.js.snap
Normal file
22
test/load/__snapshots__/pages.test.js.snap
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`loadPages valid pages 1`] = `
|
||||||
|
Array [
|
||||||
|
Object {
|
||||||
|
"path": "/foo",
|
||||||
|
"source": "foo.js",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"path": "/",
|
||||||
|
"source": "index.js",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"path": "/bar/baz",
|
||||||
|
"source": "bar/baz.js",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"path": "/foo/",
|
||||||
|
"source": "foo/index.js",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
`;
|
17
test/load/pages.test.js
Normal file
17
test/load/pages.test.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import loadPages from '@lib/load/pages.js';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
describe('loadPages', () => {
|
||||||
|
test('valid pages', async () => {
|
||||||
|
const pagesDir = path.join(__dirname, '__fixtures__', 'simple-pages');
|
||||||
|
const pagesData = await loadPages(pagesDir);
|
||||||
|
expect(pagesData).toMatchSnapshot();
|
||||||
|
expect(pagesData).not.toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('invalid pages', async () => {
|
||||||
|
const nonExistingDir = path.join(__dirname, '__fixtures__', 'nonExisting');
|
||||||
|
const pagesData = await loadPages(nonExistingDir);
|
||||||
|
expect(pagesData).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Add table
Add a link
Reference in a new issue