mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-21 12:08:03 +02:00
test: improve test coverage; multiple internal refactors (#6912)
This commit is contained in:
parent
12a7305238
commit
ad88f5cc87
78 changed files with 1613 additions and 1149 deletions
1
packages/docusaurus-plugin-content-docs/src/markdown/__tests__/__fixtures__/outside/doc1.md
generated
Normal file
1
packages/docusaurus-plugin-content-docs/src/markdown/__tests__/__fixtures__/outside/doc1.md
generated
Normal file
|
@ -0,0 +1 @@
|
|||
[link](../docs/doc1.md)
|
|
@ -193,4 +193,14 @@ describe('linkify', () => {
|
|||
expect(transformedContent).not.toContain('](../doc2.md)');
|
||||
expect(content).not.toEqual(transformedContent);
|
||||
});
|
||||
|
||||
// See comment in linkify.ts
|
||||
it('throws for file outside version', async () => {
|
||||
const doc1 = path.join(__dirname, '__fixtures__/outside/doc1.md');
|
||||
await expect(() =>
|
||||
transform(doc1),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Unexpected error: Markdown file at \\"<PROJECT_ROOT>/packages/docusaurus-plugin-content-docs/src/markdown/__tests__/__fixtures__/outside/doc1.md\\" does not belong to any docs version!"`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,6 +15,10 @@ function getVersion(filePath: string, options: DocsMarkdownOption) {
|
|||
filePath.startsWith(docsDirPath),
|
||||
),
|
||||
);
|
||||
// At this point, this should never happen, because the MDX loaders' paths are
|
||||
// literally using the version content paths; but if we allow sourcing content
|
||||
// from outside the docs directory (through the `include` option, for example;
|
||||
// is there a compelling use-case?), this would actually be testable
|
||||
if (!versionFound) {
|
||||
throw new Error(
|
||||
`Unexpected error: Markdown file at "${filePath}" does not belong to any docs version!`,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue