mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-19 03:02:30 +02:00
test: improve test coverage; properly test core client APIs (#6905)
* test: improve test coverage * fix
This commit is contained in:
parent
76cb012209
commit
d85cee576d
41 changed files with 1400 additions and 753 deletions
|
@ -111,7 +111,7 @@ describe('createSidebarsUtils', () => {
|
|||
link: {
|
||||
type: 'generated-index',
|
||||
slug: '/s4-category-slug',
|
||||
permalink: '/s4-category-permalink',
|
||||
permalink: '/s4-category-slug',
|
||||
},
|
||||
items: [
|
||||
{type: 'doc', id: 'doc8'},
|
||||
|
@ -291,7 +291,7 @@ describe('createSidebarsUtils', () => {
|
|||
});
|
||||
expect(getFirstLink('sidebar4')).toEqual({
|
||||
type: 'generated-index',
|
||||
slug: '/s4-category-slug',
|
||||
permalink: '/s4-category-slug',
|
||||
label: 'S4 Category',
|
||||
});
|
||||
});
|
||||
|
|
|
@ -139,6 +139,11 @@ export type SidebarsUtils = {
|
|||
getCategoryGeneratedIndexNavigation: (
|
||||
categoryGeneratedIndexPermalink: string,
|
||||
) => SidebarNavigation;
|
||||
/**
|
||||
* This function may return undefined. This is usually a user mistake, because
|
||||
* it means this sidebar will never be displayed; however, we can still use
|
||||
* `displayed_sidebar` to make it displayed. Pretty weird but valid use-case
|
||||
*/
|
||||
getFirstLink: (sidebarId: string) =>
|
||||
| {
|
||||
type: 'doc';
|
||||
|
@ -147,7 +152,7 @@ export type SidebarsUtils = {
|
|||
}
|
||||
| {
|
||||
type: 'generated-index';
|
||||
slug: string;
|
||||
permalink: string;
|
||||
label: string;
|
||||
}
|
||||
| undefined;
|
||||
|
@ -295,7 +300,7 @@ Available document ids are:
|
|||
}
|
||||
| {
|
||||
type: 'generated-index';
|
||||
slug: string;
|
||||
permalink: string;
|
||||
label: string;
|
||||
}
|
||||
| undefined {
|
||||
|
@ -316,7 +321,7 @@ Available document ids are:
|
|||
} else if (item.link?.type === 'generated-index') {
|
||||
return {
|
||||
type: 'generated-index',
|
||||
slug: item.link.slug,
|
||||
permalink: item.link.permalink,
|
||||
label: item.label,
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue