mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-22 02:57:45 +02:00
fix all docs tests
This commit is contained in:
parent
35e676096c
commit
f8d1d49a82
2 changed files with 66 additions and 43 deletions
|
@ -3316,23 +3316,6 @@ exports[`versioned website (community) content: route config 1`] = `
|
||||||
]
|
]
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`versioned website (community) getPathToWatch 1`] = `
|
|
||||||
[
|
|
||||||
"community_sidebars.json",
|
|
||||||
"i18n/en/docusaurus-plugin-content-docs-community/current/**/*.{md,mdx}",
|
|
||||||
"community/**/*.{md,mdx}",
|
|
||||||
"i18n/en/docusaurus-plugin-content-docs-community/current/tags.yml",
|
|
||||||
"community/tags.yml",
|
|
||||||
"community/**/_category_.{json,yml,yaml}",
|
|
||||||
"community_versioned_sidebars/version-1.0.0-sidebars.json",
|
|
||||||
"i18n/en/docusaurus-plugin-content-docs-community/version-1.0.0/**/*.{md,mdx}",
|
|
||||||
"community_versioned_docs/version-1.0.0/**/*.{md,mdx}",
|
|
||||||
"i18n/en/docusaurus-plugin-content-docs-community/version-1.0.0/tags.yml",
|
|
||||||
"community_versioned_docs/version-1.0.0/tags.yml",
|
|
||||||
"community_versioned_docs/version-1.0.0/**/_category_.{json,yml,yaml}",
|
|
||||||
]
|
|
||||||
`;
|
|
||||||
|
|
||||||
exports[`versioned website content 1`] = `
|
exports[`versioned website content 1`] = `
|
||||||
{
|
{
|
||||||
"description": "This is next version of bar.",
|
"description": "This is next version of bar.",
|
||||||
|
|
|
@ -583,6 +583,13 @@ describe('versioned website (community)', () => {
|
||||||
options,
|
options,
|
||||||
plugin,
|
plugin,
|
||||||
pluginContentDir,
|
pluginContentDir,
|
||||||
|
|
||||||
|
getPathsToWatch: () => {
|
||||||
|
const pathToWatch = plugin.getPathsToWatch!();
|
||||||
|
return pathToWatch.map((filepath) =>
|
||||||
|
posixPath(path.relative(siteDir, filepath)),
|
||||||
|
);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -599,34 +606,67 @@ describe('versioned website (community)', () => {
|
||||||
mock.mockRestore();
|
mock.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('getPathToWatch', async () => {
|
describe('getPathToWatch', () => {
|
||||||
const {siteDir, plugin} = await loadSite();
|
it('translate: false', async () => {
|
||||||
const pathToWatch = plugin.getPathsToWatch!();
|
const {getPathsToWatch} = await loadSite({translate: false});
|
||||||
const matchPattern = pathToWatch.map((filepath) =>
|
expect(getPathsToWatch()).toMatchInlineSnapshot(`
|
||||||
posixPath(path.relative(siteDir, filepath)),
|
[
|
||||||
);
|
"community_sidebars.json",
|
||||||
expect(matchPattern).not.toEqual([]);
|
"community/**/*.{md,mdx}",
|
||||||
expect(matchPattern).toMatchSnapshot();
|
"community/tags.yml",
|
||||||
expect(isMatch('community/team.md', matchPattern)).toBe(true);
|
"community/**/_category_.{json,yml,yaml}",
|
||||||
expect(
|
"community_versioned_sidebars/version-1.0.0-sidebars.json",
|
||||||
isMatch('community_versioned_docs/version-1.0.0/team.md', matchPattern),
|
"community_versioned_docs/version-1.0.0/**/*.{md,mdx}",
|
||||||
).toBe(true);
|
"community_versioned_docs/version-1.0.0/tags.yml",
|
||||||
|
"community_versioned_docs/version-1.0.0/**/_category_.{json,yml,yaml}",
|
||||||
|
]
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
// Non existing version
|
it('translate: true', async () => {
|
||||||
expect(
|
const {getPathsToWatch} = await loadSite({translate: true});
|
||||||
isMatch('community_versioned_docs/version-2.0.0/team.md', matchPattern),
|
expect(getPathsToWatch()).toMatchInlineSnapshot(`
|
||||||
).toBe(false);
|
[
|
||||||
expect(
|
"community_sidebars.json",
|
||||||
isMatch(
|
"i18n/en/docusaurus-plugin-content-docs-community/current/**/*.{md,mdx}",
|
||||||
'community_versioned_sidebars/version-2.0.0-sidebars.json',
|
"community/**/*.{md,mdx}",
|
||||||
matchPattern,
|
"i18n/en/docusaurus-plugin-content-docs-community/current/tags.yml",
|
||||||
),
|
"community/tags.yml",
|
||||||
).toBe(false);
|
"community/**/_category_.{json,yml,yaml}",
|
||||||
|
"community_versioned_sidebars/version-1.0.0-sidebars.json",
|
||||||
|
"i18n/en/docusaurus-plugin-content-docs-community/version-1.0.0/**/*.{md,mdx}",
|
||||||
|
"community_versioned_docs/version-1.0.0/**/*.{md,mdx}",
|
||||||
|
"i18n/en/docusaurus-plugin-content-docs-community/version-1.0.0/tags.yml",
|
||||||
|
"community_versioned_docs/version-1.0.0/tags.yml",
|
||||||
|
"community_versioned_docs/version-1.0.0/**/_category_.{json,yml,yaml}",
|
||||||
|
]
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
expect(isMatch('community/team.js', matchPattern)).toBe(false);
|
it('returns patterns matching docs', async () => {
|
||||||
expect(
|
const {getPathsToWatch} = await loadSite();
|
||||||
isMatch('community_versioned_docs/version-1.0.0/team.js', matchPattern),
|
const matchPattern = getPathsToWatch();
|
||||||
).toBe(false);
|
expect(isMatch('community/team.md', matchPattern)).toBe(true);
|
||||||
|
expect(
|
||||||
|
isMatch('community_versioned_docs/version-1.0.0/team.md', matchPattern),
|
||||||
|
).toBe(true);
|
||||||
|
|
||||||
|
// Non existing version
|
||||||
|
expect(
|
||||||
|
isMatch('community_versioned_docs/version-2.0.0/team.md', matchPattern),
|
||||||
|
).toBe(false);
|
||||||
|
expect(
|
||||||
|
isMatch(
|
||||||
|
'community_versioned_sidebars/version-2.0.0-sidebars.json',
|
||||||
|
matchPattern,
|
||||||
|
),
|
||||||
|
).toBe(false);
|
||||||
|
|
||||||
|
expect(isMatch('community/team.js', matchPattern)).toBe(false);
|
||||||
|
expect(
|
||||||
|
isMatch('community_versioned_docs/version-1.0.0/team.js', matchPattern),
|
||||||
|
).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('content', async () => {
|
it('content', async () => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue