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

describe("Toast", () => {
  it("renders message when provided", () => {
    render(<Toast message="操作成功" />);
    expect(screen.getByText("操作成功")).toBeInTheDocument();
  });

  it("does not render when message is empty", () => {
    const { container } = render(<Toast message="" />);
    expect(container.textContent).toBe("");
  });

  it("applies top position class by default", () => {
    render(<Toast message="test" />);
    const el = screen.getByText("test").closest("div[class*='fixed']");
    expect(el?.className).toContain("top-10");
  });

  it("applies bottom position class", () => {
    render(<Toast message="test" position="bottom" />);
    const el = screen.getByText("test").closest("div[class*='fixed']");
    expect(el?.className).toContain("bottom-8");
  });
});
