|
| 1 | +import { render, screen } from "@testing-library/react"; |
| 2 | +import { describe, it, expect } from "vitest"; |
| 3 | +import { |
| 4 | + SocialMedia, |
| 5 | + socialMediaArgs, |
| 6 | + SocialMediaProps, |
| 7 | +} from "../src/components/SocialMedia"; |
| 8 | + |
| 9 | +describe("SocialMedia Component", () => { |
| 10 | + it("renders social media icons", () => { |
| 11 | + render(<SocialMedia {...socialMediaArgs} />); |
| 12 | + expect(screen.getByRole("link", { name: "Bluesky" })).toBeInTheDocument(); |
| 13 | + expect(screen.getByText("x")).toBeInTheDocument(); |
| 14 | + }); |
| 15 | + |
| 16 | + it("renders with a headline", () => { |
| 17 | + render(<SocialMedia {...socialMediaArgs} />); |
| 18 | + expect(screen.getByText("Follow us on social media")).toBeInTheDocument(); |
| 19 | + }); |
| 20 | + |
| 21 | + it("applies the correct theme class", () => { |
| 22 | + render(<SocialMedia {...socialMediaArgs} />); |
| 23 | + const container = screen.getByRole("list").parentElement; |
| 24 | + expect(container).toHaveClass("ilo--social-media__theme__light"); |
| 25 | + }); |
| 26 | + |
| 27 | + it("applies the correct justification class", () => { |
| 28 | + render(<SocialMedia {...socialMediaArgs} />); |
| 29 | + const container = screen.getByRole("list").parentElement; |
| 30 | + expect(container).toHaveClass("ilo--social-media__justify__start"); |
| 31 | + }); |
| 32 | + |
| 33 | + it("applies the correct icon size class", () => { |
| 34 | + render(<SocialMedia {...socialMediaArgs} />); |
| 35 | + const list = screen.getByRole("list"); |
| 36 | + expect(list).toHaveClass("ilo--social-media--list__size__normal"); |
| 37 | + }); |
| 38 | + |
| 39 | + it("applies custom class names to icons", () => { |
| 40 | + const customIcons: SocialMediaProps = { |
| 41 | + iconSize: "normal", |
| 42 | + icons: [ |
| 43 | + { |
| 44 | + icon: "facebook", |
| 45 | + url: "https://facebook.com", |
| 46 | + label: "Facebook", |
| 47 | + className: "custom-class", |
| 48 | + }, |
| 49 | + ], |
| 50 | + }; |
| 51 | + render(<SocialMedia {...customIcons} />); |
| 52 | + const iconItem = screen.getByText("Facebook").parentElement; |
| 53 | + expect(iconItem).toHaveClass("custom-class"); |
| 54 | + }); |
| 55 | +}); |
0 commit comments