test: improve test coverage; properly test core client APIs (#6905)

* test: improve test coverage

* fix
This commit is contained in:
Joshua Chen 2022-03-12 23:15:45 +08:00 committed by GitHub
parent 76cb012209
commit d85cee576d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 1400 additions and 753 deletions

View file

@ -391,6 +391,10 @@ export const isCategoryIndex: CategoryIndexMatcher = ({
return eligibleDocIndexNames.includes(fileName.toLowerCase());
};
/**
* `guides/sidebar/autogenerated.md` ->
* `'autogenerated', '.md', ['sidebar', 'guides']`
*/
export function toCategoryIndexMatcherParam({
source,
sourceDirName,
@ -406,28 +410,6 @@ export function toCategoryIndexMatcherParam({
};
}
/**
* `guides/sidebar/autogenerated.md` ->
* `'autogenerated', '.md', ['sidebar', 'guides']`
*/
export function splitPath(str: string): {
/**
* The list of directories, from lowest level to highest.
* If there's no dir name, directories is ['.']
*/
directories: string[];
/** The file name, without extension */
fileName: string;
/** The extension, with a leading dot */
extension: string;
} {
return {
fileName: path.parse(str).name,
extension: path.parse(str).ext,
directories: path.dirname(str).split(path.sep).reverse(),
};
}
// Return both doc ids
// TODO legacy retro-compatibility due to old versioned sidebars using
// versioned doc ids ("id" should be removed & "versionedId" should be renamed