From 1cef907f73ea24e00603ee906d397d7f6aaa961e Mon Sep 17 00:00:00 2001 From: sebastien Date: Wed, 21 Oct 2026 12:02:16 +0200 Subject: [PATCH] refactor(blog): remove test-only validateAuthorsMap duplicate (AI-assisted) validateAuthorsMap() was an exact copy of validateAuthorsMapInput(), and only tests used it. Co-Authored-By: Claude Opus 5.5 --- .../src/__tests__/authorsMap.test.ts | 13 ++++++------- .../src/authorsMap.ts | 8 -------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/packages/docusaurus-plugin-content-blog/src/__tests__/authorsMap.test.ts b/packages/docusaurus-plugin-content-blog/src/__tests__/authorsMap.test.ts index 9384bf6259a0..1522c5c3f55b 100644 --- a/packages/docusaurus-plugin-content-blog/src/__tests__/authorsMap.test.ts +++ b/packages/docusaurus-plugin-content-blog/src/__tests__/authorsMap.test.ts @@ -11,7 +11,6 @@ import { type AuthorsMapInput, checkAuthorsMapPermalinkCollisions, getAuthorsMap, - validateAuthorsMap, validateAuthorsMapInput, } from '../authorsMap'; import type {AuthorsMap} from '@docusaurus/plugin-content-blog'; @@ -305,7 +304,7 @@ describe('authors socials', () => { }, }; - expect(validateAuthorsMap(authorsMap)).toEqual(authorsMap); + expect(validateAuthorsMapInput(authorsMap)).toEqual(authorsMap); }); it('throw socials that are not strings', () => { @@ -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.]`, ); @@ -366,7 +365,7 @@ describe('authors socials', () => { }; expect(() => - validateAuthorsMap(authorsMap), + validateAuthorsMapInput(authorsMap), ).toThrowErrorMatchingInlineSnapshot( `[ValidationError: "ozaki.socials.twitter" must be a string]`, ); @@ -384,6 +383,6 @@ describe('authors socials', () => { }, }; - expect(validateAuthorsMap(authorsMap)).toEqual(authorsMap); + expect(validateAuthorsMapInput(authorsMap)).toEqual(authorsMap); }); }); diff --git a/packages/docusaurus-plugin-content-blog/src/authorsMap.ts b/packages/docusaurus-plugin-content-blog/src/authorsMap.ts index e5c358b422f5..fd8f2eece562 100644 --- a/packages/docusaurus-plugin-content-blog/src/authorsMap.ts +++ b/packages/docusaurus-plugin-content-blog/src/authorsMap.ts @@ -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; -}