Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vineethasok committed Jan 7, 2025
1 parent 684daee commit 0fa7832
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/components/CardHorizontal/CardHorizontal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand All @@ -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();
});
});
});
1 change: 1 addition & 0 deletions src/components/CardHorizontal/CardHorizontal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export const CardHorizontal = ({
isResponsive={false}
justifyContent="end"
fillWidth={false}
data-testid="horizontal-card-badge"
>
<Badge
text={badgeText}
Expand Down

0 comments on commit 0fa7832

Please sign in to comment.