Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
type AuthorsMapInput,
checkAuthorsMapPermalinkCollisions,
getAuthorsMap,
validateAuthorsMap,
validateAuthorsMapInput,
} from '../authorsMap';
import type {AuthorsMap} from '@docusaurus/plugin-content-blog';
Expand Down Expand Up @@ -305,7 +304,7 @@ describe('authors socials', () => {
},
};

expect(validateAuthorsMap(authorsMap)).toEqual(authorsMap);
expect(validateAuthorsMapInput(authorsMap)).toEqual(authorsMap);
});

it('throw socials that are not strings', () => {
Expand Down Expand Up @@ -338,17 +337,17 @@ describe('authors socials', () => {
};

expect(() =>
validateAuthorsMap(socialNumber),
validateAuthorsMapInput(socialNumber),
).toThrowErrorMatchingInlineSnapshot(
`[ValidationError: "ozaki.socials.twitter" must be a string]`,
);
expect(() =>
validateAuthorsMap(socialNull),
validateAuthorsMapInput(socialNull),
).toThrowErrorMatchingInlineSnapshot(
`[ValidationError: "ozaki.socials.twitter" must be a string]`,
);
expect(() =>
validateAuthorsMap(socialNull2),
validateAuthorsMapInput(socialNull2),
).toThrowErrorMatchingInlineSnapshot(
`[ValidationError: "ozaki.socials" should be an author object containing properties like name, title, and imageURL.]`,
);
Expand All @@ -366,7 +365,7 @@ describe('authors socials', () => {
};

expect(() =>
validateAuthorsMap(authorsMap),
validateAuthorsMapInput(authorsMap),
).toThrowErrorMatchingInlineSnapshot(
`[ValidationError: "ozaki.socials.twitter" must be a string]`,
);
Expand All @@ -384,6 +383,6 @@ describe('authors socials', () => {
},
};

expect(validateAuthorsMap(authorsMap)).toEqual(authorsMap);
expect(validateAuthorsMapInput(authorsMap)).toEqual(authorsMap);
});
});
8 changes: 0 additions & 8 deletions packages/docusaurus-plugin-content-blog/src/authorsMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,3 @@ export async function getAuthorsMap(params: {
const authorsMap = normalizeAuthorsMap({authorsMapInput, ...params});
return authorsMap;
}

export function validateAuthorsMap(content: unknown): AuthorsMapInput {
const {error, value} = AuthorsMapInputSchema.validate(content);
if (error) {
throw error;
}
return value;
}
Loading