Skip to content

Commit

Permalink
feat(chore): add badge test
Browse files Browse the repository at this point in the history
  • Loading branch information
mnlfischer committed Sep 26, 2023
1 parent 2a06c6d commit fbe47e6
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 fbe47e6

Please sign in to comment.