-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(v2): add tests for config validation (#3142)
* test(v2): add tests for correctly defined fields * test(v2): add test for remarkPlugins and rehypePlugins validation * test(v2): modify tests and comments
- Loading branch information
Showing
7 changed files
with
143 additions
and
68 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...ocusaurus-plugin-content-blog/src/__tests__/__snapshots__/pluginOptionSchema.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`throw Error in case of invalid feedtype 1`] = `[ValidationError: "feedOptions.type" does not match any of the allowed types]`; | ||
exports[`should throw Error in case of invalid feedtype 1`] = `[ValidationError: "feedOptions.type" does not match any of the allowed types]`; | ||
|
||
exports[`throw Error in case of invalid options 1`] = `[ValidationError: "postsPerPage" must be larger than or equal to 1]`; | ||
exports[`should throw Error in case of invalid options 1`] = `[ValidationError: "postsPerPage" must be larger than or equal to 1]`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 10 additions & 9 deletions
19
packages/docusaurus/src/server/__tests__/__snapshots__/configValidation.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,51 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`validateConfig throw error for baseUrl without trailing \`/\` 1`] = ` | ||
exports[`normalizeConfig should throw error for baseUrl without trailing \`/\` 1`] = ` | ||
"\\"baseUrl\\" must be a string with a trailing \`/\` | ||
" | ||
`; | ||
|
||
exports[`validateConfig throw error for required fields 1`] = ` | ||
exports[`normalizeConfig should throw error for required fields 1`] = ` | ||
"\\"baseUrl\\" is required | ||
\\"favicon\\" is required | ||
\\"title\\" is required | ||
\\"url\\" is required | ||
\\"themes\\" must be an array | ||
\\"presets\\" must be an array | ||
\\"scripts\\" must be an array | ||
\\"stylesheets\\" must be an array | ||
These field(s) [\\"invalid\\",\\"preset\\",] are not recognized in docusaurus.config.js. | ||
These field(s) [\\"invalidField\\",] are not recognized in docusaurus.config.js. | ||
If you still want these fields to be in your configuration, put them in the 'customFields' attribute. | ||
See https://v2.docusaurus.io/docs/docusaurus.config.js/#customfields" | ||
`; | ||
|
||
exports[`validateConfig throw error for unknown field 1`] = ` | ||
exports[`normalizeConfig should throw error for unknown field 1`] = ` | ||
"These field(s) [\\"invalid\\",] are not recognized in docusaurus.config.js. | ||
If you still want these fields to be in your configuration, put them in the 'customFields' attribute. | ||
See https://v2.docusaurus.io/docs/docusaurus.config.js/#customfields" | ||
`; | ||
|
||
exports[`validateConfig throw error if css doesn't have href 1`] = ` | ||
exports[`normalizeConfig should throw error if css doesn't have href 1`] = ` | ||
"\\"stylesheets[1]\\" does not match any of the allowed types | ||
" | ||
`; | ||
|
||
exports[`validateConfig throw error if plugins is not array 1`] = ` | ||
exports[`normalizeConfig should throw error if plugins is not array 1`] = ` | ||
"\\"plugins\\" must be an array | ||
" | ||
`; | ||
|
||
exports[`validateConfig throw error if presets is not array 1`] = ` | ||
exports[`normalizeConfig should throw error if presets is not array 1`] = ` | ||
"\\"presets\\" must be an array | ||
" | ||
`; | ||
|
||
exports[`validateConfig throw error if scripts doesn't have src 1`] = ` | ||
exports[`normalizeConfig should throw error if scripts doesn't have src 1`] = ` | ||
"\\"scripts[1]\\" does not match any of the allowed types | ||
" | ||
`; | ||
|
||
exports[`validateConfig throw error if themes is not array 1`] = ` | ||
exports[`normalizeConfig should throw error if themes is not array 1`] = ` | ||
"\\"themes\\" must be an array | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters