mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
test(v2): test different type of sidebar item
This commit is contained in:
parent
f47059b5bd
commit
badb067b4b
5 changed files with 58 additions and 8 deletions
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"docs": {
|
||||||
|
"Test": [
|
||||||
|
"foo/bar",
|
||||||
|
"foo/baz",
|
||||||
|
{
|
||||||
|
"type": "superman"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"Guides": [
|
||||||
|
"hello"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,16 @@
|
||||||
"docs": {
|
"docs": {
|
||||||
"Test": [
|
"Test": [
|
||||||
"foo/bar",
|
"foo/bar",
|
||||||
"foo/baz"
|
"foo/baz",
|
||||||
|
{
|
||||||
|
"type": "link",
|
||||||
|
"label": "Github",
|
||||||
|
"href": "https://github.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ref",
|
||||||
|
"id": "hello"
|
||||||
|
}
|
||||||
],
|
],
|
||||||
"Guides": [
|
"Guides": [
|
||||||
"hello"
|
"hello"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`loadSidebars normal site with sidebars 1`] = `
|
exports[`loadSidebars sidebars with known sidebar item type 1`] = `
|
||||||
Object {
|
Object {
|
||||||
"docs": Array [
|
"docs": Array [
|
||||||
Object {
|
Object {
|
||||||
|
@ -13,6 +13,15 @@ Object {
|
||||||
"id": "foo/baz",
|
"id": "foo/baz",
|
||||||
"type": "doc",
|
"type": "doc",
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"href": "https://github.com",
|
||||||
|
"label": "Github",
|
||||||
|
"type": "link",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": "hello",
|
||||||
|
"type": "ref",
|
||||||
|
},
|
||||||
],
|
],
|
||||||
"label": "Test",
|
"label": "Test",
|
||||||
"type": "category",
|
"type": "category",
|
||||||
|
@ -30,5 +39,3 @@ Object {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`loadSidebars site without sidebars 1`] = `Object {}`;
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import loadSidebars from '../sidebars';
|
||||||
/* eslint-disable global-require, import/no-dynamic-require */
|
/* eslint-disable global-require, import/no-dynamic-require */
|
||||||
|
|
||||||
describe('loadSidebars', () => {
|
describe('loadSidebars', () => {
|
||||||
test('normal site with sidebars', async () => {
|
test('sidebars with known sidebar item type', async () => {
|
||||||
const sidebarPath = path.join(
|
const sidebarPath = path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
'__fixtures__',
|
'__fixtures__',
|
||||||
|
@ -22,8 +22,20 @@ describe('loadSidebars', () => {
|
||||||
expect(result).toMatchSnapshot();
|
expect(result).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('site without sidebars', () => {
|
test('sidebars with unknown sidebar item type', async () => {
|
||||||
|
const sidebarPath = path.join(
|
||||||
|
__dirname,
|
||||||
|
'__fixtures__',
|
||||||
|
'website',
|
||||||
|
'bad-sidebars.json',
|
||||||
|
);
|
||||||
|
expect(() => loadSidebars(sidebarPath)).toThrowErrorMatchingInlineSnapshot(
|
||||||
|
`"Unknown sidebar item type: superman"`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('no sidebars', () => {
|
||||||
const result = loadSidebars(null);
|
const result = loadSidebars(null);
|
||||||
expect(result).toMatchSnapshot();
|
expect(result).toEqual({});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,7 +14,15 @@ module.exports = {
|
||||||
'deployment',
|
'deployment',
|
||||||
],
|
],
|
||||||
Guides: [
|
Guides: [
|
||||||
'configuration',
|
{
|
||||||
|
type: 'link',
|
||||||
|
label: 'Github',
|
||||||
|
href: 'http://github.com',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'ref',
|
||||||
|
id: 'configuration',
|
||||||
|
},
|
||||||
'creating-pages',
|
'creating-pages',
|
||||||
'writing-documentation',
|
'writing-documentation',
|
||||||
'assets',
|
'assets',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue