import React from "react";
import { render, fireEvent } from "@testing-library/react";
import Chip from "../Chip";

describe("Chip Component Tests", () => {
  it("renders without crashing", () => {
    const { container } = render(<Chip text="Test Chip" />);
    expect(container).toBeTruthy();
  });

  it("displays the provided text", () => {
    const { getByText } = render(<Chip text="Test Chip" />);
    expect(getByText("Test Chip")).toBeInTheDocument();
  });

  it("handles click events", () => {
    const handleClick = jest.fn();
    const { getByText } = render(
      <Chip text="Clickable Chip" onClick={handleClick} />
    );
    fireEvent.click(getByText("Clickable Chip"));
    expect(handleClick).toHaveBeenCalled();
  });

  it("matches snapshot", () => {
    const { asFragment } = render(<Chip text="Test Chip" />);
    expect(asFragment()).toMatchSnapshot();
  });
});
