mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 15:47:23 +02:00
test(theme-common): improve test coverage (#6902)
* test(theme-common): improve test coverage * revert
This commit is contained in:
parent
aa5a2d4c04
commit
f6baaa6b75
59 changed files with 1183 additions and 755 deletions
|
@ -16,6 +16,29 @@ Object {
|
|||
}
|
||||
`;
|
||||
|
||||
exports[`sidebar site with wrong sidebar content 1`] = `
|
||||
"Invalid sidebar file at \\"packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/simple-site/wrong-sidebars.json\\".
|
||||
These sidebar document ids do not exist:
|
||||
- goku
|
||||
|
||||
Available document ids are:
|
||||
- doc with space
|
||||
- foo/bar
|
||||
- foo/baz
|
||||
- headingAsTitle
|
||||
- hello
|
||||
- ipsum
|
||||
- lorem
|
||||
- rootAbsoluteSlug
|
||||
- rootRelativeSlug
|
||||
- rootResolvedSlug
|
||||
- rootTryToEscapeSlug
|
||||
- slugs/absoluteSlug
|
||||
- slugs/relativeSlug
|
||||
- slugs/resolvedSlug
|
||||
- slugs/tryToEscapeSlug"
|
||||
`;
|
||||
|
||||
exports[`simple website content 1`] = `
|
||||
Object {
|
||||
"description": "Images",
|
||||
|
|
|
@ -176,7 +176,7 @@ describe('simple site', () => {
|
|||
context,
|
||||
options,
|
||||
});
|
||||
expect(versionsMetadata.length).toEqual(1);
|
||||
expect(versionsMetadata).toHaveLength(1);
|
||||
const [currentVersion] = versionsMetadata;
|
||||
|
||||
const defaultTestUtils = createTestUtils({
|
||||
|
@ -533,7 +533,7 @@ describe('versioned site', () => {
|
|||
context,
|
||||
options,
|
||||
});
|
||||
expect(versionsMetadata.length).toEqual(4);
|
||||
expect(versionsMetadata).toHaveLength(4);
|
||||
const [currentVersion, version101, version100, versionWithSlugs] =
|
||||
versionsMetadata;
|
||||
|
||||
|
@ -947,28 +947,28 @@ describe('isConventionalDocIndex', () => {
|
|||
directories: ['doesNotMatter'],
|
||||
extension: '.md',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
expect(
|
||||
isCategoryIndex({
|
||||
fileName: 'readme',
|
||||
directories: ['doesNotMatter'],
|
||||
extension: '.mdx',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
expect(
|
||||
isCategoryIndex({
|
||||
fileName: 'README',
|
||||
directories: ['doesNotMatter'],
|
||||
extension: '.md',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
expect(
|
||||
isCategoryIndex({
|
||||
fileName: 'ReAdMe',
|
||||
directories: ['doesNotMatter'],
|
||||
extension: '',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('supports index', () => {
|
||||
|
@ -978,28 +978,28 @@ describe('isConventionalDocIndex', () => {
|
|||
directories: ['doesNotMatter'],
|
||||
extension: '.md',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
expect(
|
||||
isCategoryIndex({
|
||||
fileName: 'index',
|
||||
directories: ['doesNotMatter'],
|
||||
extension: '.mdx',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
expect(
|
||||
isCategoryIndex({
|
||||
fileName: 'INDEX',
|
||||
directories: ['doesNotMatter'],
|
||||
extension: '.md',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
expect(
|
||||
isCategoryIndex({
|
||||
fileName: 'InDeX',
|
||||
directories: ['doesNotMatter'],
|
||||
extension: '',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('supports <categoryName>/<categoryName>.md', () => {
|
||||
|
@ -1009,35 +1009,35 @@ describe('isConventionalDocIndex', () => {
|
|||
directories: ['someCategory', 'doesNotMatter'],
|
||||
extension: '',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
expect(
|
||||
isCategoryIndex({
|
||||
fileName: 'someCategory',
|
||||
directories: ['someCategory'],
|
||||
extension: '.md',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
expect(
|
||||
isCategoryIndex({
|
||||
fileName: 'someCategory',
|
||||
directories: ['someCategory'],
|
||||
extension: '.mdx',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
expect(
|
||||
isCategoryIndex({
|
||||
fileName: 'SOME_CATEGORY',
|
||||
directories: ['some_category'],
|
||||
extension: '.md',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
expect(
|
||||
isCategoryIndex({
|
||||
fileName: 'some_category',
|
||||
directories: ['some_category'],
|
||||
extension: '',
|
||||
}),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('reject other cases', () => {
|
||||
|
@ -1047,20 +1047,20 @@ describe('isConventionalDocIndex', () => {
|
|||
directories: ['someCategory'],
|
||||
extension: '',
|
||||
}),
|
||||
).toEqual(false);
|
||||
).toBe(false);
|
||||
expect(
|
||||
isCategoryIndex({
|
||||
fileName: 'read_me',
|
||||
directories: ['doesNotMatter'],
|
||||
extension: '',
|
||||
}),
|
||||
).toEqual(false);
|
||||
).toBe(false);
|
||||
expect(
|
||||
isCategoryIndex({
|
||||
fileName: 'the index',
|
||||
directories: ['doesNotMatter'],
|
||||
extension: '',
|
||||
}),
|
||||
).toEqual(false);
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -123,29 +123,7 @@ describe('sidebar', () => {
|
|||
sidebarPath,
|
||||
}),
|
||||
);
|
||||
await expect(plugin.loadContent!()).rejects
|
||||
.toThrowErrorMatchingInlineSnapshot(`
|
||||
"Invalid sidebar file at \\"packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/simple-site/wrong-sidebars.json\\".
|
||||
These sidebar document ids do not exist:
|
||||
- goku
|
||||
|
||||
Available document ids are:
|
||||
- doc with space
|
||||
- foo/bar
|
||||
- foo/baz
|
||||
- headingAsTitle
|
||||
- hello
|
||||
- ipsum
|
||||
- lorem
|
||||
- rootAbsoluteSlug
|
||||
- rootRelativeSlug
|
||||
- rootResolvedSlug
|
||||
- rootTryToEscapeSlug
|
||||
- slugs/absoluteSlug
|
||||
- slugs/relativeSlug
|
||||
- slugs/resolvedSlug
|
||||
- slugs/tryToEscapeSlug"
|
||||
`);
|
||||
await expect(plugin.loadContent!()).rejects.toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
|
||||
it('site with wrong sidebar file path', async () => {
|
||||
|
@ -281,17 +259,17 @@ describe('simple website', () => {
|
|||
posixPath(path.relative(siteDir, filepath)),
|
||||
);
|
||||
expect(matchPattern).toMatchSnapshot();
|
||||
expect(isMatch('docs/hello.md', matchPattern)).toEqual(true);
|
||||
expect(isMatch('docs/hello.mdx', matchPattern)).toEqual(true);
|
||||
expect(isMatch('docs/foo/bar.md', matchPattern)).toEqual(true);
|
||||
expect(isMatch('docs/hello.js', matchPattern)).toEqual(false);
|
||||
expect(isMatch('docs/super.mdl', matchPattern)).toEqual(false);
|
||||
expect(isMatch('docs/mdx', matchPattern)).toEqual(false);
|
||||
expect(isMatch('docs/headingAsTitle.md', matchPattern)).toEqual(true);
|
||||
expect(isMatch('sidebars.json', matchPattern)).toEqual(true);
|
||||
expect(isMatch('versioned_docs/hello.md', matchPattern)).toEqual(false);
|
||||
expect(isMatch('hello.md', matchPattern)).toEqual(false);
|
||||
expect(isMatch('super/docs/hello.md', matchPattern)).toEqual(false);
|
||||
expect(isMatch('docs/hello.md', matchPattern)).toBe(true);
|
||||
expect(isMatch('docs/hello.mdx', matchPattern)).toBe(true);
|
||||
expect(isMatch('docs/foo/bar.md', matchPattern)).toBe(true);
|
||||
expect(isMatch('docs/hello.js', matchPattern)).toBe(false);
|
||||
expect(isMatch('docs/super.mdl', matchPattern)).toBe(false);
|
||||
expect(isMatch('docs/mdx', matchPattern)).toBe(false);
|
||||
expect(isMatch('docs/headingAsTitle.md', matchPattern)).toBe(true);
|
||||
expect(isMatch('sidebars.json', matchPattern)).toBe(true);
|
||||
expect(isMatch('versioned_docs/hello.md', matchPattern)).toBe(false);
|
||||
expect(isMatch('hello.md', matchPattern)).toBe(false);
|
||||
expect(isMatch('super/docs/hello.md', matchPattern)).toBe(false);
|
||||
});
|
||||
|
||||
it('configureWebpack', async () => {
|
||||
|
@ -319,7 +297,7 @@ describe('simple website', () => {
|
|||
it('content', async () => {
|
||||
const {plugin, pluginContentDir} = await loadSite();
|
||||
const content = await plugin.loadContent!();
|
||||
expect(content.loadedVersions.length).toEqual(1);
|
||||
expect(content.loadedVersions).toHaveLength(1);
|
||||
const [currentVersion] = content.loadedVersions;
|
||||
|
||||
expect(findDocById(currentVersion, 'foo/baz')).toMatchSnapshot();
|
||||
|
@ -398,42 +376,42 @@ describe('versioned website', () => {
|
|||
);
|
||||
expect(matchPattern).not.toEqual([]);
|
||||
expect(matchPattern).toMatchSnapshot();
|
||||
expect(isMatch('docs/hello.md', matchPattern)).toEqual(true);
|
||||
expect(isMatch('docs/hello.mdx', matchPattern)).toEqual(true);
|
||||
expect(isMatch('docs/foo/bar.md', matchPattern)).toEqual(true);
|
||||
expect(isMatch('sidebars.json', matchPattern)).toEqual(true);
|
||||
expect(
|
||||
isMatch('versioned_docs/version-1.0.0/hello.md', matchPattern),
|
||||
).toEqual(true);
|
||||
expect(isMatch('docs/hello.md', matchPattern)).toBe(true);
|
||||
expect(isMatch('docs/hello.mdx', matchPattern)).toBe(true);
|
||||
expect(isMatch('docs/foo/bar.md', matchPattern)).toBe(true);
|
||||
expect(isMatch('sidebars.json', matchPattern)).toBe(true);
|
||||
expect(isMatch('versioned_docs/version-1.0.0/hello.md', matchPattern)).toBe(
|
||||
true,
|
||||
);
|
||||
expect(
|
||||
isMatch('versioned_docs/version-1.0.0/foo/bar.md', matchPattern),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
expect(
|
||||
isMatch('versioned_sidebars/version-1.0.0-sidebars.json', matchPattern),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
|
||||
// Non existing version
|
||||
expect(
|
||||
isMatch('versioned_docs/version-2.0.0/foo/bar.md', matchPattern),
|
||||
).toEqual(false);
|
||||
expect(
|
||||
isMatch('versioned_docs/version-2.0.0/hello.md', matchPattern),
|
||||
).toEqual(false);
|
||||
).toBe(false);
|
||||
expect(isMatch('versioned_docs/version-2.0.0/hello.md', matchPattern)).toBe(
|
||||
false,
|
||||
);
|
||||
expect(
|
||||
isMatch('versioned_sidebars/version-2.0.0-sidebars.json', matchPattern),
|
||||
).toEqual(false);
|
||||
).toBe(false);
|
||||
|
||||
expect(isMatch('docs/hello.js', matchPattern)).toEqual(false);
|
||||
expect(isMatch('docs/super.mdl', matchPattern)).toEqual(false);
|
||||
expect(isMatch('docs/mdx', matchPattern)).toEqual(false);
|
||||
expect(isMatch('hello.md', matchPattern)).toEqual(false);
|
||||
expect(isMatch('super/docs/hello.md', matchPattern)).toEqual(false);
|
||||
expect(isMatch('docs/hello.js', matchPattern)).toBe(false);
|
||||
expect(isMatch('docs/super.mdl', matchPattern)).toBe(false);
|
||||
expect(isMatch('docs/mdx', matchPattern)).toBe(false);
|
||||
expect(isMatch('hello.md', matchPattern)).toBe(false);
|
||||
expect(isMatch('super/docs/hello.md', matchPattern)).toBe(false);
|
||||
});
|
||||
|
||||
it('content', async () => {
|
||||
const {plugin, pluginContentDir} = await loadSite();
|
||||
const content = await plugin.loadContent!();
|
||||
expect(content.loadedVersions.length).toEqual(4);
|
||||
expect(content.loadedVersions).toHaveLength(4);
|
||||
const [currentVersion, version101, version100, versionWithSlugs] =
|
||||
content.loadedVersions;
|
||||
|
||||
|
@ -529,32 +507,32 @@ describe('versioned website (community)', () => {
|
|||
);
|
||||
expect(matchPattern).not.toEqual([]);
|
||||
expect(matchPattern).toMatchSnapshot();
|
||||
expect(isMatch('community/team.md', matchPattern)).toEqual(true);
|
||||
expect(isMatch('community/team.md', matchPattern)).toBe(true);
|
||||
expect(
|
||||
isMatch('community_versioned_docs/version-1.0.0/team.md', matchPattern),
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
|
||||
// Non existing version
|
||||
expect(
|
||||
isMatch('community_versioned_docs/version-2.0.0/team.md', matchPattern),
|
||||
).toEqual(false);
|
||||
).toBe(false);
|
||||
expect(
|
||||
isMatch(
|
||||
'community_versioned_sidebars/version-2.0.0-sidebars.json',
|
||||
matchPattern,
|
||||
),
|
||||
).toEqual(false);
|
||||
).toBe(false);
|
||||
|
||||
expect(isMatch('community/team.js', matchPattern)).toEqual(false);
|
||||
expect(isMatch('community/team.js', matchPattern)).toBe(false);
|
||||
expect(
|
||||
isMatch('community_versioned_docs/version-1.0.0/team.js', matchPattern),
|
||||
).toEqual(false);
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('content', async () => {
|
||||
const {plugin, pluginContentDir} = await loadSite();
|
||||
const content = await plugin.loadContent!();
|
||||
expect(content.loadedVersions.length).toEqual(2);
|
||||
expect(content.loadedVersions).toHaveLength(2);
|
||||
const [currentVersion, version100] = content.loadedVersions;
|
||||
|
||||
expect(getDocById(currentVersion, 'team')).toMatchSnapshot();
|
||||
|
@ -600,7 +578,7 @@ describe('site with doc label', () => {
|
|||
const loadedVersion = content.loadedVersions[0];
|
||||
const sidebarProps = toSidebarsProp(loadedVersion);
|
||||
|
||||
expect(sidebarProps.docs[0].label).toEqual('Hello One');
|
||||
expect(sidebarProps.docs[0].label).toBe('Hello One');
|
||||
});
|
||||
|
||||
it('sidebar_label in doc has higher precedence over label in sidebar.json', async () => {
|
||||
|
@ -608,7 +586,7 @@ describe('site with doc label', () => {
|
|||
const loadedVersion = content.loadedVersions[0];
|
||||
const sidebarProps = toSidebarsProp(loadedVersion);
|
||||
|
||||
expect(sidebarProps.docs[1].label).toEqual('Hello 2 From Doc');
|
||||
expect(sidebarProps.docs[1].label).toBe('Hello 2 From Doc');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -70,45 +70,37 @@ describe('stripNumberPrefix', () => {
|
|||
}
|
||||
|
||||
it('strips number prefix if present', () => {
|
||||
expect(stripNumberPrefixDefault('1-My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('01-My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('001-My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 - My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 - My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('999 - My Doc')).toEqual(
|
||||
expect(stripNumberPrefixDefault('1-My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('01-My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('001-My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 - My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 - My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('999 - My Doc')).toBe('My Doc');
|
||||
//
|
||||
expect(stripNumberPrefixDefault('1---My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('01---My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('001---My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 --- My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 --- My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('999 --- My Doc')).toBe(
|
||||
'My Doc',
|
||||
);
|
||||
//
|
||||
expect(stripNumberPrefixDefault('1---My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('01---My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('001---My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 --- My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 --- My Doc')).toEqual(
|
||||
'My Doc',
|
||||
);
|
||||
expect(stripNumberPrefixDefault('999 --- My Doc')).toEqual(
|
||||
expect(stripNumberPrefixDefault('1___My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('01___My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('001___My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 ___ My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 ___ My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('999 ___ My Doc')).toBe(
|
||||
'My Doc',
|
||||
);
|
||||
//
|
||||
expect(stripNumberPrefixDefault('1___My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('01___My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('001___My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 ___ My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 ___ My Doc')).toEqual(
|
||||
'My Doc',
|
||||
);
|
||||
expect(stripNumberPrefixDefault('999 ___ My Doc')).toEqual(
|
||||
'My Doc',
|
||||
);
|
||||
//
|
||||
expect(stripNumberPrefixDefault('1.My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('01.My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('001.My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 . My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 . My Doc')).toEqual('My Doc');
|
||||
expect(stripNumberPrefixDefault('999 . My Doc')).toEqual(
|
||||
'My Doc',
|
||||
);
|
||||
expect(stripNumberPrefixDefault('1.My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('01.My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('001.My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 . My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('001 . My Doc')).toBe('My Doc');
|
||||
expect(stripNumberPrefixDefault('999 . My Doc')).toBe('My Doc');
|
||||
});
|
||||
|
||||
it('does not strip number prefix if pattern does not match', () => {
|
||||
|
@ -125,7 +117,7 @@ describe('stripPathNumberPrefix', () => {
|
|||
'0-MyRootFolder0/1 - MySubFolder1/2. MyDeepFolder2/3 _MyDoc3',
|
||||
DefaultNumberPrefixParser,
|
||||
),
|
||||
).toEqual('MyRootFolder0/MySubFolder1/MyDeepFolder2/MyDoc3');
|
||||
).toBe('MyRootFolder0/MySubFolder1/MyDeepFolder2/MyDoc3');
|
||||
});
|
||||
|
||||
it('strips number prefixes in paths with custom parser', () => {
|
||||
|
@ -138,7 +130,7 @@ describe('stripPathNumberPrefix', () => {
|
|||
|
||||
expect(
|
||||
stripPathNumberPrefixes('aaaa/bbbb/cccc', stripPathNumberPrefixCustom),
|
||||
).toEqual('aaa/bbb/ccc');
|
||||
).toBe('aaa/bbb/ccc');
|
||||
});
|
||||
|
||||
it('does not strip number prefixes in paths with disabled parser', () => {
|
||||
|
@ -147,7 +139,7 @@ describe('stripPathNumberPrefix', () => {
|
|||
'0-MyRootFolder0/1 - MySubFolder1/2. MyDeepFolder2/3 _MyDoc3',
|
||||
DisabledNumberPrefixParser,
|
||||
),
|
||||
).toEqual('0-MyRootFolder0/1 - MySubFolder1/2. MyDeepFolder2/3 _MyDoc3');
|
||||
).toBe('0-MyRootFolder0/1 - MySubFolder1/2. MyDeepFolder2/3 _MyDoc3');
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
it('returns default options for undefined user options', async () => {
|
||||
const {value, error} = await OptionsSchema.validate({});
|
||||
expect(value).toEqual(DEFAULT_OPTIONS);
|
||||
expect(error).toBe(undefined);
|
||||
expect(error).toBeUndefined();
|
||||
});
|
||||
|
||||
it('accepts correctly defined user options', async () => {
|
||||
|
@ -79,7 +79,7 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
};
|
||||
const {value, error} = await OptionsSchema.validate(userOptions);
|
||||
expect(value).toEqual(userOptions);
|
||||
expect(error).toBe(undefined);
|
||||
expect(error).toBeUndefined();
|
||||
});
|
||||
|
||||
it('accepts correctly defined remark and rehype plugin options', async () => {
|
||||
|
@ -95,7 +95,7 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
};
|
||||
const {value, error} = await OptionsSchema.validate(userOptions);
|
||||
expect(value).toEqual(userOptions);
|
||||
expect(error).toBe(undefined);
|
||||
expect(error).toBeUndefined();
|
||||
});
|
||||
|
||||
it('accepts admonitions false', async () => {
|
||||
|
@ -105,7 +105,7 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
};
|
||||
const {value, error} = OptionsSchema.validate(admonitionsFalse);
|
||||
expect(value).toEqual(admonitionsFalse);
|
||||
expect(error).toBe(undefined);
|
||||
expect(error).toBeUndefined();
|
||||
});
|
||||
|
||||
it('accepts numberPrefixParser function', () => {
|
||||
|
@ -256,7 +256,7 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
sidebarCollapsible: true,
|
||||
sidebarCollapsed: undefined,
|
||||
}).sidebarCollapsed,
|
||||
).toEqual(true);
|
||||
).toBe(true);
|
||||
|
||||
expect(
|
||||
testValidateOptions({
|
||||
|
@ -264,7 +264,7 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
sidebarCollapsible: false,
|
||||
sidebarCollapsed: undefined,
|
||||
}).sidebarCollapsed,
|
||||
).toEqual(false);
|
||||
).toBe(false);
|
||||
|
||||
expect(
|
||||
testValidateOptions({
|
||||
|
@ -272,6 +272,6 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
sidebarCollapsible: false,
|
||||
sidebarCollapsed: true,
|
||||
}).sidebarCollapsed,
|
||||
).toEqual(false);
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,14 +15,14 @@ describe('getSlug', () => {
|
|||
source: '@site/docs/dir/doc.md',
|
||||
sourceDirName: '/dir',
|
||||
}),
|
||||
).toEqual('/dir/doc');
|
||||
).toBe('/dir/doc');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'doc',
|
||||
source: '@site/docs/dir/subdir/doc.md',
|
||||
sourceDirName: '/dir/subdir',
|
||||
}),
|
||||
).toEqual('/dir/subdir/doc');
|
||||
).toBe('/dir/subdir/doc');
|
||||
});
|
||||
|
||||
it('handles conventional doc indexes', () => {
|
||||
|
@ -32,42 +32,42 @@ describe('getSlug', () => {
|
|||
source: '@site/docs/dir/subdir/index.md',
|
||||
sourceDirName: '/dir/subdir',
|
||||
}),
|
||||
).toEqual('/dir/subdir/');
|
||||
).toBe('/dir/subdir/');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'doc',
|
||||
source: '@site/docs/dir/subdir/inDEx.mdx',
|
||||
sourceDirName: '/dir/subdir',
|
||||
}),
|
||||
).toEqual('/dir/subdir/');
|
||||
).toBe('/dir/subdir/');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'doc',
|
||||
source: '@site/docs/dir/subdir/readme.md',
|
||||
sourceDirName: '/dir/subdir',
|
||||
}),
|
||||
).toEqual('/dir/subdir/');
|
||||
).toBe('/dir/subdir/');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'doc',
|
||||
source: '@site/docs/dir/subdir/reADMe.mdx',
|
||||
sourceDirName: '/dir/subdir',
|
||||
}),
|
||||
).toEqual('/dir/subdir/');
|
||||
).toBe('/dir/subdir/');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'doc',
|
||||
source: '@site/docs/dir/subdir/subdir.md',
|
||||
sourceDirName: '/dir/subdir',
|
||||
}),
|
||||
).toEqual('/dir/subdir/');
|
||||
).toBe('/dir/subdir/');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'doc',
|
||||
source: '@site/docs/dir/subdir/suBDir.mdx',
|
||||
sourceDirName: '/dir/subdir',
|
||||
}),
|
||||
).toEqual('/dir/subdir/');
|
||||
).toBe('/dir/subdir/');
|
||||
});
|
||||
|
||||
it('ignores conventional doc index when explicit slug front matter is provided', () => {
|
||||
|
@ -78,7 +78,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: '/dir/subdir',
|
||||
frontMatterSlug: '/my/frontMatterSlug',
|
||||
}),
|
||||
).toEqual('/my/frontMatterSlug');
|
||||
).toBe('/my/frontMatterSlug');
|
||||
});
|
||||
|
||||
it('can strip dir number prefixes', () => {
|
||||
|
@ -89,7 +89,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: '/001-dir1/002-dir2',
|
||||
stripDirNumberPrefixes: true,
|
||||
}),
|
||||
).toEqual('/dir1/dir2/doc');
|
||||
).toBe('/dir1/dir2/doc');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'doc',
|
||||
|
@ -97,7 +97,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: '/001-dir1/002-dir2',
|
||||
stripDirNumberPrefixes: false,
|
||||
}),
|
||||
).toEqual('/001-dir1/002-dir2/doc');
|
||||
).toBe('/001-dir1/002-dir2/doc');
|
||||
});
|
||||
|
||||
// See https://github.com/facebook/docusaurus/issues/3223
|
||||
|
@ -108,16 +108,16 @@ describe('getSlug', () => {
|
|||
source: '@site/docs/dir with spâce/hey $hello/doc.md',
|
||||
sourceDirName: '/dir with spâce/hey $hello',
|
||||
}),
|
||||
).toEqual('/dir with spâce/hey $hello/my dôc');
|
||||
).toBe('/dir with spâce/hey $hello/my dôc');
|
||||
});
|
||||
|
||||
it('handles current dir', () => {
|
||||
expect(
|
||||
getSlug({baseID: 'doc', source: '@site/docs/doc.md', sourceDirName: '.'}),
|
||||
).toEqual('/doc');
|
||||
).toBe('/doc');
|
||||
expect(
|
||||
getSlug({baseID: 'doc', source: '@site/docs/doc.md', sourceDirName: '/'}),
|
||||
).toEqual('/doc');
|
||||
).toBe('/doc');
|
||||
});
|
||||
|
||||
it('resolves absolute slug front matter', () => {
|
||||
|
@ -128,7 +128,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: '.',
|
||||
frontMatterSlug: '/abc/def',
|
||||
}),
|
||||
).toEqual('/abc/def');
|
||||
).toBe('/abc/def');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'any',
|
||||
|
@ -136,7 +136,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: './any',
|
||||
frontMatterSlug: '/abc/def',
|
||||
}),
|
||||
).toEqual('/abc/def');
|
||||
).toBe('/abc/def');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'any',
|
||||
|
@ -144,7 +144,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: './any/any',
|
||||
frontMatterSlug: '/abc/def',
|
||||
}),
|
||||
).toEqual('/abc/def');
|
||||
).toBe('/abc/def');
|
||||
});
|
||||
|
||||
it('resolves relative slug front matter', () => {
|
||||
|
@ -155,7 +155,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: '.',
|
||||
frontMatterSlug: 'abc/def',
|
||||
}),
|
||||
).toEqual('/abc/def');
|
||||
).toBe('/abc/def');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'any',
|
||||
|
@ -163,7 +163,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: '/dir',
|
||||
frontMatterSlug: 'abc/def',
|
||||
}),
|
||||
).toEqual('/dir/abc/def');
|
||||
).toBe('/dir/abc/def');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'any',
|
||||
|
@ -171,7 +171,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: 'unslashedDir',
|
||||
frontMatterSlug: 'abc/def',
|
||||
}),
|
||||
).toEqual('/unslashedDir/abc/def');
|
||||
).toBe('/unslashedDir/abc/def');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'any',
|
||||
|
@ -179,7 +179,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: 'dir/subdir',
|
||||
frontMatterSlug: 'abc/def',
|
||||
}),
|
||||
).toEqual('/dir/subdir/abc/def');
|
||||
).toBe('/dir/subdir/abc/def');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'any',
|
||||
|
@ -187,7 +187,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: '/dir',
|
||||
frontMatterSlug: './abc/def',
|
||||
}),
|
||||
).toEqual('/dir/abc/def');
|
||||
).toBe('/dir/abc/def');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'any',
|
||||
|
@ -195,7 +195,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: '/dir',
|
||||
frontMatterSlug: './abc/../def',
|
||||
}),
|
||||
).toEqual('/dir/def');
|
||||
).toBe('/dir/def');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'any',
|
||||
|
@ -203,7 +203,7 @@ describe('getSlug', () => {
|
|||
sourceDirName: '/dir/subdir',
|
||||
frontMatterSlug: '../abc/def',
|
||||
}),
|
||||
).toEqual('/dir/abc/def');
|
||||
).toBe('/dir/abc/def');
|
||||
expect(
|
||||
getSlug({
|
||||
baseID: 'any',
|
||||
|
@ -211,6 +211,6 @@ describe('getSlug', () => {
|
|||
sourceDirName: '/dir/subdir',
|
||||
frontMatterSlug: '../../../../../abc/../def',
|
||||
}),
|
||||
).toEqual('/def');
|
||||
).toBe('/def');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -32,8 +32,8 @@ describe('docsClientUtils', () => {
|
|||
},
|
||||
};
|
||||
|
||||
expect(getActivePlugin(data, '/')).toEqual(undefined);
|
||||
expect(getActivePlugin(data, '/xyz')).toEqual(undefined);
|
||||
expect(getActivePlugin(data, '/')).toBeUndefined();
|
||||
expect(getActivePlugin(data, '/xyz')).toBeUndefined();
|
||||
|
||||
expect(() =>
|
||||
getActivePlugin(data, '/', {failfast: true}),
|
||||
|
@ -73,7 +73,7 @@ describe('docsClientUtils', () => {
|
|||
versions: [],
|
||||
},
|
||||
};
|
||||
expect(getActivePlugin(onePluginAtRoot, '/android/foo').pluginId).toEqual(
|
||||
expect(getActivePlugin(onePluginAtRoot, '/android/foo').pluginId).toBe(
|
||||
'pluginAndroidId',
|
||||
);
|
||||
const onePluginAtRootReversed = {
|
||||
|
@ -88,7 +88,7 @@ describe('docsClientUtils', () => {
|
|||
};
|
||||
expect(
|
||||
getActivePlugin(onePluginAtRootReversed, '/android/foo').pluginId,
|
||||
).toEqual('pluginAndroidId');
|
||||
).toBe('pluginAndroidId');
|
||||
});
|
||||
|
||||
it('getLatestVersion', () => {
|
||||
|
@ -158,19 +158,19 @@ describe('docsClientUtils', () => {
|
|||
],
|
||||
};
|
||||
|
||||
expect(getActiveVersion(data, '/someUnknownPath')).toEqual(undefined);
|
||||
expect(getActiveVersion(data, '/someUnknownPath')).toBeUndefined();
|
||||
|
||||
expect(getActiveVersion(data, '/docs/next')?.name).toEqual('next');
|
||||
expect(getActiveVersion(data, '/docs/next/')?.name).toEqual('next');
|
||||
expect(getActiveVersion(data, '/docs/next/someDoc')?.name).toEqual('next');
|
||||
expect(getActiveVersion(data, '/docs/next')?.name).toBe('next');
|
||||
expect(getActiveVersion(data, '/docs/next/')?.name).toBe('next');
|
||||
expect(getActiveVersion(data, '/docs/next/someDoc')?.name).toBe('next');
|
||||
|
||||
expect(getActiveVersion(data, '/docs')?.name).toEqual('version2');
|
||||
expect(getActiveVersion(data, '/docs/')?.name).toEqual('version2');
|
||||
expect(getActiveVersion(data, '/docs/someDoc')?.name).toEqual('version2');
|
||||
expect(getActiveVersion(data, '/docs')?.name).toBe('version2');
|
||||
expect(getActiveVersion(data, '/docs/')?.name).toBe('version2');
|
||||
expect(getActiveVersion(data, '/docs/someDoc')?.name).toBe('version2');
|
||||
|
||||
expect(getActiveVersion(data, '/docs/version1')?.name).toEqual('version1');
|
||||
expect(getActiveVersion(data, '/docs/version1')?.name).toEqual('version1');
|
||||
expect(getActiveVersion(data, '/docs/version1/someDoc')?.name).toEqual(
|
||||
expect(getActiveVersion(data, '/docs/version1')?.name).toBe('version1');
|
||||
expect(getActiveVersion(data, '/docs/version1')?.name).toBe('version1');
|
||||
expect(getActiveVersion(data, '/docs/version1/someDoc')?.name).toBe(
|
||||
'version1',
|
||||
);
|
||||
});
|
||||
|
|
|
@ -132,18 +132,18 @@ describe('createSidebarsUtils', () => {
|
|||
} = createSidebarsUtils(sidebars);
|
||||
|
||||
it('getFirstDocIdOfFirstSidebar', async () => {
|
||||
expect(getFirstDocIdOfFirstSidebar()).toEqual('doc1');
|
||||
expect(getFirstDocIdOfFirstSidebar()).toBe('doc1');
|
||||
});
|
||||
|
||||
it('getSidebarNameByDocId', async () => {
|
||||
expect(getSidebarNameByDocId('doc1')).toEqual('sidebar1');
|
||||
expect(getSidebarNameByDocId('doc2')).toEqual('sidebar1');
|
||||
expect(getSidebarNameByDocId('doc3')).toEqual('sidebar2');
|
||||
expect(getSidebarNameByDocId('doc4')).toEqual('sidebar2');
|
||||
expect(getSidebarNameByDocId('doc5')).toEqual('sidebar3');
|
||||
expect(getSidebarNameByDocId('doc6')).toEqual('sidebar3');
|
||||
expect(getSidebarNameByDocId('doc7')).toEqual('sidebar3');
|
||||
expect(getSidebarNameByDocId('unknown_id')).toEqual(undefined);
|
||||
expect(getSidebarNameByDocId('doc1')).toBe('sidebar1');
|
||||
expect(getSidebarNameByDocId('doc2')).toBe('sidebar1');
|
||||
expect(getSidebarNameByDocId('doc3')).toBe('sidebar2');
|
||||
expect(getSidebarNameByDocId('doc4')).toBe('sidebar2');
|
||||
expect(getSidebarNameByDocId('doc5')).toBe('sidebar3');
|
||||
expect(getSidebarNameByDocId('doc6')).toBe('sidebar3');
|
||||
expect(getSidebarNameByDocId('doc7')).toBe('sidebar3');
|
||||
expect(getSidebarNameByDocId('unknown_id')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('getDocNavigation', async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue