Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
  • Loading branch information
Josh-Cena committed Aug 20, 2021
1 parent fcd539c commit 8ae7dfa
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test('should accept correctly defined user options', () => {
const {value, error} = PluginOptionSchema.validate(userOptions);
expect(value).toEqual({
...userOptions,
feedOptions: {type: ['rss'], title: 'myTitle'},
feedOptions: {type: ['rss'], title: 'myTitle', copyright: ''},
});
expect(error).toBe(undefined);
});
Expand Down Expand Up @@ -78,7 +78,7 @@ test('should convert all feed type to array with other feed type', () => {
});
expect(value).toEqual({
...DEFAULT_OPTIONS,
feedOptions: {type: ['rss', 'atom']},
feedOptions: {type: ['rss', 'atom'], copyright: ''},
});
});

Expand Down Expand Up @@ -106,7 +106,7 @@ test('should have array with rss + atom, title for missing feed type', () => {
});
expect(value).toEqual({
...DEFAULT_OPTIONS,
feedOptions: {type: ['rss', 'atom'], title: 'title'},
feedOptions: {type: ['rss', 'atom'], title: 'title', copyright: ''},
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-content-blog/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ export default function pluginContentBlog(
},

async postBuild({outDir}: Props) {
if (!options.feedOptions?.type) {
if (!options.feedOptions.type) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,14 @@ export const PluginOptionSchema = Joi.object<PluginOptions>({
.default(DEFAULT_OPTIONS.feedOptions.type),
title: Joi.string().allow(''),
description: Joi.string().allow(''),
copyright: Joi.string(),
// only add default value when user actually wants a feed (type is not null)
copyright: Joi.when('type', {
is: Joi.any().valid(null),
then: Joi.string().optional(),
otherwise: Joi.string()
.allow('')
.default(DEFAULT_OPTIONS.feedOptions.copyright),
}),
language: Joi.string(),
}).default(DEFAULT_OPTIONS.feedOptions),
});

0 comments on commit 8ae7dfa

Please sign in to comment.