mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 16:17:25 +02:00
fix(v2): fix validation rejecting admonitions false (#4629)
Prevents disabling default admonitions as documented under https://docusaurus.io/docs/presets#official-presets
This commit is contained in:
parent
808b0fa62a
commit
5088a1e48f
2 changed files with 24 additions and 1 deletions
|
@ -74,6 +74,27 @@ describe('normalizeDocsPluginOptions', () => {
|
||||||
expect(error).toBe(undefined);
|
expect(error).toBe(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should accept admonitions false', async () => {
|
||||||
|
const admonitionsFalse = {
|
||||||
|
...DEFAULT_OPTIONS,
|
||||||
|
admonitions: false,
|
||||||
|
};
|
||||||
|
const {value, error} = OptionsSchema.validate(admonitionsFalse);
|
||||||
|
expect(value).toEqual(admonitionsFalse);
|
||||||
|
expect(error).toBe(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should reject admonitions true', async () => {
|
||||||
|
const admonitionsTrue = {
|
||||||
|
...DEFAULT_OPTIONS,
|
||||||
|
admonitions: true,
|
||||||
|
};
|
||||||
|
const {error} = OptionsSchema.validate(admonitionsTrue);
|
||||||
|
expect(error).toMatchInlineSnapshot(
|
||||||
|
`[ValidationError: "admonitions" contains an invalid value]`,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test('should reject invalid remark plugin options', () => {
|
test('should reject invalid remark plugin options', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
normalizePluginOptions(OptionsSchema, {
|
normalizePluginOptions(OptionsSchema, {
|
||||||
|
|
|
@ -76,7 +76,9 @@ export const OptionsSchema = Joi.object({
|
||||||
beforeDefaultRehypePlugins: RehypePluginsSchema.default(
|
beforeDefaultRehypePlugins: RehypePluginsSchema.default(
|
||||||
DEFAULT_OPTIONS.beforeDefaultRehypePlugins,
|
DEFAULT_OPTIONS.beforeDefaultRehypePlugins,
|
||||||
),
|
),
|
||||||
admonitions: AdmonitionsSchema.default(DEFAULT_OPTIONS.admonitions),
|
admonitions: Joi.alternatives()
|
||||||
|
.try(AdmonitionsSchema, Joi.boolean().invalid(true))
|
||||||
|
.default(DEFAULT_OPTIONS.admonitions),
|
||||||
showLastUpdateTime: Joi.bool().default(DEFAULT_OPTIONS.showLastUpdateTime),
|
showLastUpdateTime: Joi.bool().default(DEFAULT_OPTIONS.showLastUpdateTime),
|
||||||
showLastUpdateAuthor: Joi.bool().default(
|
showLastUpdateAuthor: Joi.bool().default(
|
||||||
DEFAULT_OPTIONS.showLastUpdateAuthor,
|
DEFAULT_OPTIONS.showLastUpdateAuthor,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue