mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 00:27:21 +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"."`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -38,12 +38,12 @@ describe('docsClientUtils', () => {
|
|||
expect(() =>
|
||||
getActivePlugin(data, '/', {failfast: true}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Can't find active docs plugin for \\"/\\" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: /ios, /android"`,
|
||||
`"Can't find active docs plugin for "/" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: /ios, /android"`,
|
||||
);
|
||||
expect(() =>
|
||||
getActivePlugin(data, '/xyz', {failfast: true}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Can't find active docs plugin for \\"/xyz\\" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: /ios, /android"`,
|
||||
`"Can't find active docs plugin for "/xyz" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: /ios, /android"`,
|
||||
);
|
||||
|
||||
const activePluginIos: ActivePlugin = {
|
||||
|
|
|
@ -200,7 +200,7 @@ describe('linkify', () => {
|
|||
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!"`,
|
||||
`"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!"`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -62,7 +62,7 @@ describe('loadSidebars', () => {
|
|||
await expect(() =>
|
||||
loadSidebars(sidebarPath, params),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid sidebar items collection [36m\`\\"doc1\\"\`[39m in [36m\`items\`[39m of the category [34m[1mCategory Label[22m[39m: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a [36m\`type\`[39m property). See [36m[4mhttps://docusaurus.io/docs/sidebar/items[24m[39m for all valid syntaxes."`,
|
||||
`"Invalid sidebar items collection \`"doc1"\` in \`items\` of the category Category Label: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a \`type\` property). See https://docusaurus.io/docs/sidebar/items for all valid syntaxes."`,
|
||||
);
|
||||
});
|
||||
|
||||
|
@ -131,7 +131,7 @@ describe('loadSidebars', () => {
|
|||
contentPathLocalized: path.join(fixtureDir, 'invalid-docs'),
|
||||
},
|
||||
}),
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(`"\\"foo\\" is not allowed"`);
|
||||
).rejects.toThrowErrorMatchingInlineSnapshot(`""foo" is not allowed"`);
|
||||
expect(consoleWarnMock).toBeCalledWith(
|
||||
expect.stringMatching(
|
||||
/.*\[WARNING\].* There are more than one category metadata files for .*foo.*: foo\/_category_.json, foo\/_category_.yml. The behavior is undetermined./,
|
||||
|
|
|
@ -46,7 +46,7 @@ describe('normalization', () => {
|
|||
},
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid sidebar items collection [36m\`{\\"type\\":\\"autogenerated\\",\\"dirName\\":\\"foo\\"}\`[39m in [36m\`items\`[39m of the category [34m[1mCategory[22m[39m: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a [36m\`type\`[39m property). See [36m[4mhttps://docusaurus.io/docs/sidebar/items[24m[39m for all valid syntaxes."`,
|
||||
`"Invalid sidebar items collection \`{"type":"autogenerated","dirName":"foo"}\` in \`items\` of the category Category: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a \`type\` property). See https://docusaurus.io/docs/sidebar/items for all valid syntaxes."`,
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
|
@ -62,7 +62,7 @@ describe('normalization', () => {
|
|||
],
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid sidebar items collection [36m\`{\\"type\\":\\"category\\",\\"items\\":[\\"bar\\",\\"baz\\"]}\`[39m in [36m\`items\`[39m of the category [34m[1mCategory[22m[39m: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a [36m\`type\`[39m property). See [36m[4mhttps://docusaurus.io/docs/sidebar/items[24m[39m for all valid syntaxes."`,
|
||||
`"Invalid sidebar items collection \`{"type":"category","items":["bar","baz"]}\` in \`items\` of the category Category: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a \`type\` property). See https://docusaurus.io/docs/sidebar/items for all valid syntaxes."`,
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
|
@ -75,7 +75,7 @@ describe('normalization', () => {
|
|||
],
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"Invalid sidebar items collection [36m\`\\"bar\\"\`[39m in [36m\`items\`[39m of the category [34m[1mCategory[22m[39m: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a [36m\`type\`[39m property). See [36m[4mhttps://docusaurus.io/docs/sidebar/items[24m[39m for all valid syntaxes."`,
|
||||
`"Invalid sidebar items collection \`"bar"\` in \`items\` of the category Category: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a \`type\` property). See https://docusaurus.io/docs/sidebar/items for all valid syntaxes."`,
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
|
@ -83,8 +83,7 @@ describe('normalization', () => {
|
|||
sidebar: 'item',
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
// cSpell:ignore msidebar
|
||||
`"Invalid sidebar items collection [36m\`\\"item\\"\`[39m in sidebar [34m[1msidebar[22m[39m: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a [36m\`type\`[39m property). See [36m[4mhttps://docusaurus.io/docs/sidebar/items[24m[39m for all valid syntaxes."`,
|
||||
`"Invalid sidebar items collection \`"item"\` in sidebar sidebar: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a \`type\` property). See https://docusaurus.io/docs/sidebar/items for all valid syntaxes."`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,11 +13,11 @@ describe('validateSidebars', () => {
|
|||
expect(() => validateSidebars({sidebar: [{type: 42}]}))
|
||||
.toThrowErrorMatchingInlineSnapshot(`
|
||||
"{
|
||||
\\"type\\": 42,
|
||||
[41m\\"undefined\\"[0m[31m [1]: -- missing --[0m
|
||||
"type": 42,
|
||||
"undefined" [1]: -- missing --
|
||||
}
|
||||
[31m
|
||||
[1] Unknown sidebar item type \\"42\\".[0m"
|
||||
|
||||
[1] Unknown sidebar item type "42"."
|
||||
`);
|
||||
});
|
||||
|
||||
|
@ -53,20 +53,21 @@ describe('validateSidebars', () => {
|
|||
},
|
||||
],
|
||||
}),
|
||||
|
||||
// eslint-disable-next-line jest/no-large-snapshots
|
||||
).toThrowErrorMatchingInlineSnapshot(`
|
||||
"{
|
||||
\\"type\\": \\"category\\",
|
||||
\\"items\\": [
|
||||
"type": "category",
|
||||
"items": [
|
||||
{
|
||||
\\"type\\": \\"doc\\",
|
||||
\\"id\\": \\"doc1\\"
|
||||
"type": "doc",
|
||||
"id": "doc1"
|
||||
}
|
||||
],
|
||||
\\"label\\" [31m[1][0m: true
|
||||
"label" [1]: true
|
||||
}
|
||||
[31m
|
||||
[1] \\"label\\" must be a string[0m"
|
||||
|
||||
[1] "label" must be a string"
|
||||
`);
|
||||
});
|
||||
|
||||
|
@ -82,14 +83,14 @@ describe('validateSidebars', () => {
|
|||
],
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`
|
||||
"{
|
||||
\\"type\\": \\"link\\",
|
||||
\\"href\\": \\"https://github.com\\",
|
||||
\\"label\\" [31m[1][0m: false
|
||||
}
|
||||
[31m
|
||||
[1] \\"label\\" must be a string[0m"
|
||||
`);
|
||||
"{
|
||||
"type": "link",
|
||||
"href": "https://github.com",
|
||||
"label" [1]: false
|
||||
}
|
||||
|
||||
[1] "label" must be a string"
|
||||
`);
|
||||
});
|
||||
|
||||
it('sidebars link wrong href', () => {
|
||||
|
@ -104,16 +105,16 @@ describe('validateSidebars', () => {
|
|||
],
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`
|
||||
"{
|
||||
\\"type\\": \\"link\\",
|
||||
\\"label\\": \\"GitHub\\",
|
||||
\\"href\\" [31m[1][0m: [
|
||||
\\"example.com\\"
|
||||
]
|
||||
}
|
||||
[31m
|
||||
[1] \\"href\\" contains an invalid value[0m"
|
||||
`);
|
||||
"{
|
||||
"type": "link",
|
||||
"label": "GitHub",
|
||||
"href" [1]: [
|
||||
"example.com"
|
||||
]
|
||||
}
|
||||
|
||||
[1] "href" contains an invalid value"
|
||||
`);
|
||||
});
|
||||
|
||||
it('sidebars with unknown sidebar item type', () => {
|
||||
|
@ -126,13 +127,13 @@ describe('validateSidebars', () => {
|
|||
],
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`
|
||||
"{
|
||||
\\"type\\": \\"superman\\",
|
||||
[41m\\"undefined\\"[0m[31m [1]: -- missing --[0m
|
||||
}
|
||||
[31m
|
||||
[1] Unknown sidebar item type \\"superman\\".[0m"
|
||||
`);
|
||||
"{
|
||||
"type": "superman",
|
||||
"undefined" [1]: -- missing --
|
||||
}
|
||||
|
||||
[1] Unknown sidebar item type "superman"."
|
||||
`);
|
||||
});
|
||||
|
||||
it('sidebars category missing items', () => {
|
||||
|
@ -152,12 +153,12 @@ describe('validateSidebars', () => {
|
|||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`
|
||||
"{
|
||||
\\"type\\": \\"category\\",
|
||||
\\"label\\": \\"category\\",
|
||||
[41m\\"items\\"[0m[31m [1]: -- missing --[0m
|
||||
"type": "category",
|
||||
"label": "category",
|
||||
"items" [1]: -- missing --
|
||||
}
|
||||
[31m
|
||||
[1] \\"items\\" is required[0m"
|
||||
|
||||
[1] "items" is required"
|
||||
`);
|
||||
});
|
||||
|
||||
|
@ -180,13 +181,13 @@ describe('validateSidebars', () => {
|
|||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`
|
||||
"{
|
||||
\\"type\\": \\"category\\",
|
||||
\\"label\\": \\"category\\",
|
||||
\\"items\\": [],
|
||||
\\"href\\" [31m[1][0m: \\"https://google.com\\"
|
||||
"type": "category",
|
||||
"label": "category",
|
||||
"items": [],
|
||||
"href" [1]: "https://google.com"
|
||||
}
|
||||
[31m
|
||||
[1] \\"href\\" is not allowed[0m"
|
||||
|
||||
[1] "href" is not allowed"
|
||||
`);
|
||||
});
|
||||
|
||||
|
@ -217,15 +218,15 @@ describe('validateSidebars', () => {
|
|||
],
|
||||
}),
|
||||
).toThrowErrorMatchingInlineSnapshot(`
|
||||
"{
|
||||
\\"type\\": \\"doc\\",
|
||||
\\"id\\" [31m[1][0m: [
|
||||
\\"doc1\\"
|
||||
]
|
||||
}
|
||||
[31m
|
||||
[1] \\"id\\" must be a string[0m"
|
||||
`);
|
||||
"{
|
||||
"type": "doc",
|
||||
"id" [1]: [
|
||||
"doc1"
|
||||
]
|
||||
}
|
||||
|
||||
[1] "id" must be a string"
|
||||
`);
|
||||
});
|
||||
|
||||
it('html type requires a value', () => {
|
||||
|
@ -240,11 +241,11 @@ describe('validateSidebars', () => {
|
|||
expect(() => validateSidebars(sidebars))
|
||||
.toThrowErrorMatchingInlineSnapshot(`
|
||||
"{
|
||||
\\"type\\": \\"html\\",
|
||||
[41m\\"value\\"[0m[31m [1]: -- missing --[0m
|
||||
"type": "html",
|
||||
"value" [1]: -- missing --
|
||||
}
|
||||
[31m
|
||||
[1] \\"value\\" is required[0m"
|
||||
|
||||
[1] "value" is required"
|
||||
`);
|
||||
});
|
||||
|
||||
|
@ -269,9 +270,7 @@ describe('validateCategoryMetadataFile', () => {
|
|||
it('throw for bad value', async () => {
|
||||
expect(() =>
|
||||
validateCategoryMetadataFile(42),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"\\"value\\" must be of type object"`,
|
||||
);
|
||||
).toThrowErrorMatchingInlineSnapshot(`""value" must be of type object"`);
|
||||
});
|
||||
|
||||
it('accept empty object', async () => {
|
||||
|
@ -314,8 +313,6 @@ describe('validateCategoryMetadataFile', () => {
|
|||
};
|
||||
expect(() =>
|
||||
validateCategoryMetadataFile(content),
|
||||
).toThrowErrorMatchingInlineSnapshot(
|
||||
`"\\"link.permalink\\" is not allowed"`,
|
||||
);
|
||||
).toThrowErrorMatchingInlineSnapshot(`""link.permalink" is not allowed"`);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue