Repository: facebook/docusaurus
File: packages/docusaurus-plugin-content-blog/src/__tests__/authors.test.ts (TypeScript)

Code before:
            name: 'Sébastien Lorber',
            title: 'maintainer',
            socials: {
              github: 'https://github.com/slorber',
              linkedin: 'https://www.linkedin.com/in/sebastienlorber/',
              stackoverflow: 'https://stackoverflow.com/users/82609',
              twitter: 'https://twitter.com/sebastienlorber',
              x: 'https://x.com/sebastienlorber',
            },
          },
        },
        authorsMap: undefined,
        baseUrl: '/',
      }),
    ).toEqual([
      {
        name: 'Sébastien Lorber',
        title: 'maintainer',
        imageURL: undefined,
        key: null,
        socials: {
          github: 'https://github.com/slorber',
          linkedin: 'https://www.linkedin.com/in/sebastienlorber/',
          stackoverflow: 'https://stackoverflow.com/users/82609',
          twitter: 'https://twitter.com/sebastienlorber',
          x: 'https://x.com/sebastienlorber',
        },
        page: null,
      },
    ]);
  });

  it('can normalize handle socials from Author', () => {
    expect(
      getBlogPostAuthors({
        frontMatter: {
          authors: {
            name: 'Sébastien Lorber',
            title: 'maintainer',
            socials: {
              github: 'slorber',
              x: 'sebastienlorber',
              linkedin: 'sebastienlorber',
              stackoverflow: '82609',
              twitter: 'sebastienlorber',
            },
          },
        },
        authorsMap: undefined,
        baseUrl: '/',
      }),

Review comment (suggestion):
We also need tests for undefined/null/absent social key

As you will see your implementation might not do what you expect

Code after:
      },
    ]);
    expect(() => () => testSocials(undefined)).not.toThrow();
    // @ts-expect-error test
    expect(() => testSocials({twitter: undefined}))
      .toThrowErrorMatchingInlineSnapshot(`
      "Author socials should be usernames/userIds/handles, or fully qualified HTTP(s) absolute URLs.
      Social platform 'twitter' has illegal value 'undefined'"
    `);
    expect(
      // @ts-expect-error test
      () => testSocials({twitter: null}),
    ).toThrowErrorMatchingInlineSnapshot(`
      "Author socials should be usernames/userIds/handles, or fully qualified HTTP(s) absolute URLs.
      Social platform 'twitter' has illegal value 'null'"
    `);
  });

  it('can read empty socials', () => {
    expect(
      getBlogPostAuthors({
        frontMatter: {
          authors: {
            name: 'Sébastien Lorber',
            title: 'maintainer',
            socials: {},
          },
        },
        authorsMap: undefined,
        baseUrl: '/',
      }),
    ).toEqual([
      {
        name: 'Sébastien Lorber',
        title: 'maintainer',
        imageURL: undefined,
        socials: {},
        key: null,
        page: null,
      },
    ]);
  });

  it('can normalize full socials from Author', () => {
    expect(
      getBlogPostAuthors({
        frontMatter: {
          authors: {
            name: 'Sébastien Lorber',
            title: 'maintainer',
            socials: {