Skip to content

Commit

Permalink
Merge pull request #41 from abusix/pla-507-hailstorm-component-tests-…
Browse files Browse the repository at this point in the history
…badge

feat(chore): add badge test
  • Loading branch information
mnlfischer authored Sep 27, 2023
2 parents c8eccc0 + 684eb8c commit 797c941
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/components/badge/badge.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { render, screen } from "@testing-library/react";
import React from "react";
import { describe, expect, it } from "vitest";
import { Badge } from "./badge";

describe("Badge", () => {
it("renders a badge with default appearance and passed string", () => {
const text = "Default Badge";
// ARRANGE
render(<Badge>{text}</Badge>);

// ASSERT
const badge = screen.getByText(text);
expect(badge).toBeInTheDocument();
expect(badge).toHaveAttribute("role", "button");
expect(badge).toHaveClass("rounded");
});

it("renders a badge with rounded appearance and passed string", () => {
const text = "Rounded Badge";
// ARRANGE
render(<Badge shape="rounded">{text}</Badge>);

// ASSERT
const badge = screen.getByText(text);
expect(badge).toBeInTheDocument();
expect(badge).toHaveAttribute("role", "button");
expect(badge).toHaveClass("rounded-full");
});
});

0 comments on commit 797c941

Please sign in to comment.