mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 16:17:25 +02:00
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
This commit is contained in:
parent
ee2d1b42f6
commit
e7ec93b0b9
7 changed files with 144 additions and 69 deletions
|
@ -18,6 +18,9 @@ export default function normalizePluginOptions(options) {
|
|||
}
|
||||
}
|
||||
|
||||
// the type of remark/rehype plugins is function
|
||||
const remarkRehypePluginStub = () => {};
|
||||
|
||||
describe('normalizeDocsPluginOptions', () => {
|
||||
test('should return default options for undefined user options', async () => {
|
||||
const {value} = await PluginOptionSchema.validate({});
|
||||
|
@ -34,14 +37,26 @@ describe('normalizeDocsPluginOptions', () => {
|
|||
docLayoutComponent: '@theme/DocPage',
|
||||
docItemComponent: '@theme/DocItem',
|
||||
remarkPlugins: [],
|
||||
rehypePlugins: [],
|
||||
rehypePlugins: [remarkRehypePluginStub],
|
||||
showLastUpdateTime: true,
|
||||
showLastUpdateAuthor: true,
|
||||
admonitions: {},
|
||||
excludeNextVersionDocs: true,
|
||||
disableVersioning: true,
|
||||
};
|
||||
const {value} = await PluginOptionSchema.validate(userOptions);
|
||||
expect(value).toEqual(userOptions);
|
||||
});
|
||||
|
||||
test('should accept correctly defined remark and rehype plugin options', async () => {
|
||||
const userOptions = {
|
||||
...DEFAULT_OPTIONS,
|
||||
remarkPlugins: [remarkRehypePluginStub, {option1: '42'}],
|
||||
rehypePlugins: [
|
||||
remarkRehypePluginStub,
|
||||
[remarkRehypePluginStub, {option1: '42'}],
|
||||
],
|
||||
};
|
||||
const {value} = await PluginOptionSchema.validate(userOptions);
|
||||
expect(value).toEqual(userOptions);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue