import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { Label } from "./label";

describe("Label Component", () => {
  it("renders correctly with children", () => {
    render(<Label>Username</Label>);
    expect(screen.getByText("Username")).toBeInTheDocument();
  });

  it("applies custom className", () => {
    render(<Label className="custom-label">Password</Label>);
    const label = screen.getByText("Password");
    expect(label).toHaveClass("custom-label");
  });

  it("is associated with an input via htmlFor", () => {
    render(
      <>
        <Label htmlFor="test-input">Label Text</Label>
        <input id="test-input" />
      </>,
    );
    const label = screen.getByText("Label Text");
    expect(label).toHaveAttribute("for", "test-input");
  });
});
