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:
Teik Jun 2020-07-29 22:23:11 +08:00 committed by GitHub
parent ee2d1b42f6
commit e7ec93b0b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 144 additions and 69 deletions

View file

@ -63,10 +63,20 @@ export const PluginOptionSchema = Joi.object({
truncateMarker: Joi.object().default(DEFAULT_OPTIONS.truncateMarker),
admonitions: Joi.object().default(DEFAULT_OPTIONS.admonitions),
beforeDefaultRemarkPlugins: Joi.array()
.items(Joi.object())
.items(
Joi.array()
.items(Joi.function().required(), Joi.object().required())
.length(2),
Joi.function(),
)
.default(DEFAULT_OPTIONS.beforeDefaultRemarkPlugins),
beforeDefaultRehypePlugins: Joi.array()
.items(Joi.object())
.items(
Joi.array()
.items(Joi.function().required(), Joi.object().required())
.length(2),
Joi.function(),
)
.default(DEFAULT_OPTIONS.beforeDefaultRehypePlugins),
feedOptions: Joi.object({
type: Joi.alternatives().conditional(
@ -75,8 +85,8 @@ export const PluginOptionSchema = Joi.object({
then: Joi.custom((val) => (val === 'all' ? ['rss', 'atom'] : [val])),
},
),
title: Joi.string(),
description: Joi.string(),
title: Joi.string().allow(''),
description: Joi.string().allow(''),
copyright: Joi.string(),
language: Joi.string(),
}).default(DEFAULT_OPTIONS.feedOptions),