@@ -2,7 +2,7 @@ import "@testing-library/jest-dom";
22import { usePathname } from "next/navigation" ;
33import { render , screen } from "@testing-library/react" ;
44import { themeDefaultSampleData } from "@/theme/sampleData" ;
5- import { generateSocialUrl } from "@/util/social" ;
5+ import { generateSocialUrl , getSocialMediaPlatformByPlatformName } from "@/util/social" ;
66import { ResumeHeading } from "./ResumeHeading" ;
77
88// Mock the usePathname hook
@@ -42,10 +42,14 @@ describe("ResumeHeading", () => {
4242 // Check if all social links are rendered
4343 sampleSocials . forEach ( ( social ) => {
4444 const expectedUrl = generateSocialUrl ( social ) ;
45- const links = screen . getAllByRole ( "link" , { name : "" } ) ;
46- const link = links . find ( ( link ) => link . getAttribute ( "href" ) === expectedUrl ) ;
45+ const platformName = getSocialMediaPlatformByPlatformName ( social . platform ) . name ;
46+ const expectedAriaLabel = `${ platformName } profile for ${ sampleUser . name } ` ;
47+
48+ const link = screen . getByRole ( "link" , { name : expectedAriaLabel } ) ;
4749 expect ( link ) . toBeInTheDocument ( ) ;
50+ expect ( link ) . toHaveAttribute ( "href" , expectedUrl ) ;
4851 expect ( link ) . toHaveAttribute ( "target" , "_blank" ) ;
52+ expect ( link ) . toHaveAttribute ( "aria-label" , expectedAriaLabel ) ;
4953 } ) ;
5054 } ) ;
5155
0 commit comments