mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-19 11:12:36 +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
|
@ -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