import { describe, it, expect } from "vitest"
import { cn, formatDate } from "./utils"

describe("cn", () => {
  it("should merge class names", () => {
    expect(cn("foo", "bar")).toBe("foo bar")
  })

  it("should handle conditional classes", () => {
    expect(cn("foo", false && "bar", "baz")).toBe("foo baz")
  })

  it("should resolve tailwind conflicts", () => {
    expect(cn("px-4", "px-6")).toBe("px-6")
  })

  it("should handle undefined and null", () => {
    expect(cn("foo", undefined, null, "bar")).toBe("foo bar")
  })
})

describe("formatDate", () => {
  it("should format a date string with default zh-CN locale", () => {
    const result = formatDate("2024-01-15")
    expect(result).toContain("2024")
    expect(result).toContain("1")
  })

  it("should format a date string with en-US locale", () => {
    const result = formatDate("2024-01-15", "en-US")
    expect(result).toContain("2024")
    expect(result).toContain("Jan")
  })

  it("should format a Date object", () => {
    const result = formatDate(new Date(2024, 5, 15))
    expect(result).toContain("2024")
  })
})
