diff --git a/src/components/CardHorizontal/CardHorizontal.test.tsx b/src/components/CardHorizontal/CardHorizontal.test.tsx index 15d37302..936acd8b 100644 --- a/src/components/CardHorizontal/CardHorizontal.test.tsx +++ b/src/components/CardHorizontal/CardHorizontal.test.tsx @@ -13,9 +13,11 @@ describe("CardHorizontal Component", () => { title, icon: "warning", description: "", + badgeText: "", }); expect(screen.getByText(title)).toBeDefined(); + expect(screen.queryByTestId("horizontal-card-badge")).toBeNull(); }); it("should render the description when provided", () => { @@ -28,5 +30,29 @@ describe("CardHorizontal Component", () => { expect(screen.getByText(description)).toBeDefined(); }); + + it("should render the badge when provided", () => { + const description = "This is the card description"; + renderCard({ + icon: "warning", + title: "title", + description, + badgeText: "Badge", + }); + + expect(screen.getByText("title")).toBeDefined(); + expect(screen.getByTestId("horizontal-card-badge")).toBeDefined(); + }); + it("should not render the badge when badgeText is provided and not title", () => { + const description = "This is the card description"; + renderCard({ + icon: "warning", + title: "", + description, + badgeText: "Badge", + }); + + expect(screen.queryByTestId("horizontal-card-badge")).toBeNull(); + }); }); }); diff --git a/src/components/CardHorizontal/CardHorizontal.tsx b/src/components/CardHorizontal/CardHorizontal.tsx index e4876e46..4c98b032 100644 --- a/src/components/CardHorizontal/CardHorizontal.tsx +++ b/src/components/CardHorizontal/CardHorizontal.tsx @@ -186,6 +186,7 @@ export const CardHorizontal = ({ isResponsive={false} justifyContent="end" fillWidth={false} + data-testid="horizontal-card-badge" >