mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-01 07:49:43 +02:00
chore: disable string escaping in snapshots (#7131)
This commit is contained in:
parent
4134ebb3fb
commit
9145ae88cc
60 changed files with 1881 additions and 1884 deletions
File diff suppressed because it is too large
Load diff
|
@ -82,12 +82,12 @@ describe('docsVersion', () => {
|
|||
await expect(() =>
|
||||
cliDocsVersionCommand('..', DEFAULT_OPTIONS, {siteDir: simpleSiteDir}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"[docs]: invalid version tag specified! Do not name your version \\".\\" or \\"..\\". Try something like: 1.0.0."`,
|
||||
`"[docs]: invalid version tag specified! Do not name your version "." or "..". Try something like: 1.0.0."`,
|
||||
);
|
||||
await expect(() =>
|
||||
cliDocsVersionCommand('.', DEFAULT_OPTIONS, {siteDir: simpleSiteDir}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"[docs]: invalid version tag specified! Do not name your version \\".\\" or \\"..\\". Try something like: 1.0.0."`,
|
||||
`"[docs]: invalid version tag specified! Do not name your version "." or "..". Try something like: 1.0.0."`,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -133,7 +133,7 @@ describe('docsVersion', () => {
|
|||
i18n: {locales: ['en', 'zh-Hans'], defaultLocale: 'en'},
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"[docs]: no docs found in [36m[4m\\"<PROJECT_ROOT>/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/empty-site/docs\\"[24m[39m."`,
|
||||
`"[docs]: no docs found in "<PROJECT_ROOT>/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/empty-site/docs"."`,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -249,7 +249,7 @@ describe('docsVersion', () => {
|
|||
),
|
||||
);
|
||||
expect(warnMock.mock.calls[0][0]).toMatchInlineSnapshot(
|
||||
`"[33m[1m[WARNING][22m [docs]: no docs found in [36m[4m\\"<PROJECT_ROOT>/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/versioned-site/i18n/zh-Hans/docusaurus-plugin-content-docs/current\\"[24m[39m[33m. Skipping.[39m"`,
|
||||
`"[WARNING] [docs]: no docs found in "<PROJECT_ROOT>/packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/versioned-site/i18n/zh-Hans/docusaurus-plugin-content-docs/current". Skipping."`,
|
||||
);
|
||||
|
||||
warnMock.mockRestore();
|
||||
|
|
|
@ -487,7 +487,7 @@ describe('simple site', () => {
|
|||
}),
|
||||
),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Document id \\"Hello/world\\" cannot include slash."`,
|
||||
`"Document id "Hello/world" cannot include slash."`,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -143,10 +143,11 @@ describe('sidebar', () => {
|
|||
},
|
||||
}),
|
||||
);
|
||||
|
||||
await plugin.loadContent!();
|
||||
}).rejects.toThrowErrorMatchingInlineSnapshot(`
|
||||
"The path to the sidebar file does not exist at \\"wrong-path-sidebar.json\\".
|
||||
Please set the docs \\"sidebarPath\\" field in your config file to:
|
||||
"The path to the sidebar file does not exist at "wrong-path-sidebar.json".
|
||||
Please set the docs "sidebarPath" field in your config file to:
|
||||
- a sidebars path that exists
|
||||
- false: to disable the sidebar
|
||||
- undefined: for Docusaurus to generate it automatically"
|
||||
|
@ -203,7 +204,7 @@ describe('empty/no docs website', () => {
|
|||
await expect(
|
||||
plugin.loadContent!(),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Docs version \\"current\\" has no docs! At least one doc should exist at \\"docs\\"."`,
|
||||
`"Docs version "current" has no docs! At least one doc should exist at "docs"."`,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -220,7 +221,7 @@ describe('empty/no docs website', () => {
|
|||
}),
|
||||
),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"The docs folder does not exist for version \\"current\\". A docs folder is expected to be found at path/does/not/exist."`,
|
||||
`"The docs folder does not exist for version "current". A docs folder is expected to be found at path/does/not/exist."`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -117,7 +117,7 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
expect(() =>
|
||||
testValidate(admonitionsTrue),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"\\"admonitions\\" contains an invalid value"`,
|
||||
`""admonitions" contains an invalid value"`,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -151,9 +151,9 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
remarkPlugins: [[{option1: '42'}, markdownPluginsFunctionStub]],
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`
|
||||
"\\"remarkPlugins[0]\\" does not look like a valid MDX plugin config. A plugin config entry should be one of:
|
||||
- A tuple, like \`[require(\\"rehype-katex\\"), { strict: false }]\`, or
|
||||
- A simple module, like \`require(\\"remark-math\\")\`"
|
||||
""remarkPlugins[0]" does not look like a valid MDX plugin config. A plugin config entry should be one of:
|
||||
- A tuple, like \`[require("rehype-katex"), { strict: false }]\`, or
|
||||
- A simple module, like \`require("remark-math")\`"
|
||||
`);
|
||||
});
|
||||
|
||||
|
@ -169,46 +169,42 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
],
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`
|
||||
"\\"rehypePlugins[0]\\" does not look like a valid MDX plugin config. A plugin config entry should be one of:
|
||||
- A tuple, like \`[require(\\"rehype-katex\\"), { strict: false }]\`, or
|
||||
- A simple module, like \`require(\\"remark-math\\")\`"
|
||||
""rehypePlugins[0]" does not look like a valid MDX plugin config. A plugin config entry should be one of:
|
||||
- A tuple, like \`[require("rehype-katex"), { strict: false }]\`, or
|
||||
- A simple module, like \`require("remark-math")\`"
|
||||
`);
|
||||
});
|
||||
|
||||
it('rejects bad path inputs', () => {
|
||||
expect(() => testValidate({path: 2})).toThrowErrorMatchingInlineSnapshot(
|
||||
`"\\"path\\" must be a string"`,
|
||||
`""path" must be a string"`,
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects bad include inputs', () => {
|
||||
expect(() =>
|
||||
testValidate({include: '**/*.{md,mdx}'}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`"\\"include\\" must be an array"`);
|
||||
).toThrowErrorMatchingInlineSnapshot(`""include" must be an array"`);
|
||||
});
|
||||
|
||||
it('rejects bad showLastUpdateTime inputs', () => {
|
||||
expect(() =>
|
||||
testValidate({showLastUpdateTime: 'true'}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"\\"showLastUpdateTime\\" must be a boolean"`,
|
||||
`""showLastUpdateTime" must be a boolean"`,
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects bad remarkPlugins input', () => {
|
||||
expect(() =>
|
||||
testValidate({remarkPlugins: 'remark-math'}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"\\"remarkPlugins\\" must be an array"`,
|
||||
);
|
||||
).toThrowErrorMatchingInlineSnapshot(`""remarkPlugins" must be an array"`);
|
||||
});
|
||||
|
||||
it('rejects bad lastVersion', () => {
|
||||
expect(() =>
|
||||
testValidate({lastVersion: false}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"\\"lastVersion\\" must be a string"`,
|
||||
);
|
||||
).toThrowErrorMatchingInlineSnapshot(`""lastVersion" must be a string"`);
|
||||
});
|
||||
|
||||
it('rejects bad versions', () => {
|
||||
|
@ -218,6 +214,7 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
current: {
|
||||
hey: 3,
|
||||
},
|
||||
|
||||
version1: {
|
||||
path: 'hello',
|
||||
label: 'world',
|
||||
|
@ -225,7 +222,7 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
},
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"\\"versions.current.hey\\" is not allowed"`,
|
||||
`""versions.current.hey" is not allowed"`,
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ describe('getSlug', () => {
|
|||
frontMatterSlug: '//',
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`
|
||||
"We couldn't compute a valid slug for document with ID \\"my dôc\\" in \\"/dir with spâce/hey $hello\\" directory.
|
||||
"We couldn't compute a valid slug for document with ID "my dôc" in "/dir with spâce/hey $hello" directory.
|
||||
The slug we computed looks invalid: //.
|
||||
Maybe your slug front matter is incorrect or there are special characters in the file path?
|
||||
By using front matter to set a custom slug, you should be able to fix this error:
|
||||
|
|
|
@ -187,10 +187,11 @@ describe('readVersionsMetadata', () => {
|
|||
unknownVersionName2: {label: 'unknownVersionName2'},
|
||||
},
|
||||
},
|
||||
|
||||
context: defaultContext,
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid docs option \\"versions\\": unknown versions (unknownVersionName1,unknownVersionName2) found. Available version names are: current"`,
|
||||
`"Invalid docs option "versions": unknown versions (unknownVersionName1,unknownVersionName2) found. Available version names are: current"`,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -203,7 +204,7 @@ describe('readVersionsMetadata', () => {
|
|||
context: defaultContext,
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Docs: using \\"disableVersioning: true\\" option on a non-versioned site does not make sense."`,
|
||||
`"Docs: using "disableVersioning: true" option on a non-versioned site does not make sense."`,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -216,7 +217,7 @@ describe('readVersionsMetadata', () => {
|
|||
context: defaultContext,
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"It is not possible to use docs without any version. Please check the configuration of these options: \\"includeCurrentVersion: false\\", \\"disableVersioning: false\\"."`,
|
||||
`"It is not possible to use docs without any version. Please check the configuration of these options: "includeCurrentVersion: false", "disableVersioning: false"."`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -557,10 +558,11 @@ describe('readVersionsMetadata', () => {
|
|||
includeCurrentVersion: false,
|
||||
disableVersioning: true,
|
||||
},
|
||||
|
||||
context: defaultContext,
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"It is not possible to use docs without any version. Please check the configuration of these options: \\"includeCurrentVersion: false\\", \\"disableVersioning: true\\"."`,
|
||||
`"It is not possible to use docs without any version. Please check the configuration of these options: "includeCurrentVersion: false", "disableVersioning: true"."`,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -573,10 +575,11 @@ describe('readVersionsMetadata', () => {
|
|||
...defaultOptions,
|
||||
onlyIncludeVersions: [],
|
||||
},
|
||||
|
||||
context: defaultContext,
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid docs option \\"onlyIncludeVersions\\": an empty array is not allowed, at least one version is needed."`,
|
||||
`"Invalid docs option "onlyIncludeVersions": an empty array is not allowed, at least one version is needed."`,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -589,10 +592,11 @@ describe('readVersionsMetadata', () => {
|
|||
...defaultOptions,
|
||||
onlyIncludeVersions: ['unknownVersion1', 'unknownVersion2'],
|
||||
},
|
||||
|
||||
context: defaultContext,
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid docs option \\"onlyIncludeVersions\\": unknown versions (unknownVersion1,unknownVersion2) found. Available version names are: current, 1.0.1, 1.0.0, withSlugs"`,
|
||||
`"Invalid docs option "onlyIncludeVersions": unknown versions (unknownVersion1,unknownVersion2) found. Available version names are: current, 1.0.1, 1.0.0, withSlugs"`,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -606,10 +610,11 @@ describe('readVersionsMetadata', () => {
|
|||
lastVersion: '1.0.1',
|
||||
onlyIncludeVersions: ['current', '1.0.0'],
|
||||
},
|
||||
|
||||
context: defaultContext,
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid docs option \\"lastVersion\\": if you use both the \\"onlyIncludeVersions\\" and \\"lastVersion\\" options, then \\"lastVersion\\" must be present in the provided \\"onlyIncludeVersions\\" array."`,
|
||||
`"Invalid docs option "lastVersion": if you use both the "onlyIncludeVersions" and "lastVersion" options, then "lastVersion" must be present in the provided "onlyIncludeVersions" array."`,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -627,7 +632,7 @@ describe('readVersionsMetadata', () => {
|
|||
context: defaultContext,
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"The versions file should contain an array of version names! Found content: {\\"invalid\\":\\"json\\"}"`,
|
||||
`"The versions file should contain an array of version names! Found content: {"invalid":"json"}"`,
|
||||
);
|
||||
jsonMock.mockImplementationOnce(() => [1.1]);
|
||||
|
||||
|
@ -637,7 +642,7 @@ describe('readVersionsMetadata', () => {
|
|||
context: defaultContext,
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Versions should be strings. Found type \\"number\\" for version \\"1.1\\"."`,
|
||||
`"Versions should be strings. Found type "number" for version "1.1"."`,
|
||||
);
|
||||
jsonMock.mockImplementationOnce(() => [' ']);
|
||||
|
||||
|
@ -646,9 +651,7 @@ describe('readVersionsMetadata', () => {
|
|||
options: defaultOptions,
|
||||
context: defaultContext,
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid version \\" \\"."`,
|
||||
);
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(`"Invalid version " "."`);
|
||||
jsonMock.mockRestore();
|
||||
});
|
||||
});
|
||||
|
@ -772,10 +775,11 @@ describe('readVersionsMetadata', () => {
|
|||
includeCurrentVersion: false,
|
||||
disableVersioning: true,
|
||||
},
|
||||
|
||||
context: defaultContext,
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"It is not possible to use docs without any version. Please check the configuration of these options: \\"includeCurrentVersion: false\\", \\"disableVersioning: true\\"."`,
|
||||
`"It is not possible to use docs without any version. Please check the configuration of these options: "includeCurrentVersion: false", "disableVersioning: true"."`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue