import { describe, test, expect } from "vitest"
import { validateBrand } from "../src/config"

describe("config — validateBrand", () => {
  test("valid brand passes", () => {
    const brand = validateBrand({
      base: "#0a0a0a",
      surface: "#121212",
      fg: "#ededed",
      muted: "#a1a1aa",
      accent: "#ccff00",
      line: "rgba(255,255,255,0.06)",
    })
    expect(brand.accent).toBe("#ccff00")
    expect(brand.base).toBe("#0a0a0a")
  })

  test("missing accent rejected", () => {
    expect(() => validateBrand({ base: "#0a0a0a", surface: "#121212", fg: "#ededed", muted: "#a1a1aa" }))
      .toThrow(/accent/)
  })

  test("non-hex accent rejected", () => {
    expect(() => validateBrand({ base: "#0a0a0a", surface: "#121212", fg: "#ededed", muted: "#a1a1aa", accent: "green" }))
      .toThrow(/hex/)
  })

  test("short hex rejected", () => {
    expect(() => validateBrand({ base: "#0a0", surface: "#121212", fg: "#ededed", muted: "#a1a1aa", accent: "#ccff00" }))
      .toThrow(/hex/)
  })

  test("non-object rejected", () => {
    expect(() => validateBrand("not an object")).toThrow(/object/)
    expect(() => validateBrand(null)).toThrow(/object/)
  })

  test("line defaults when missing", () => {
    const brand = validateBrand({ base: "#0a0a0a", surface: "#121212", fg: "#ededed", muted: "#a1a1aa", accent: "#ccff00" })
    expect(brand.line).toBe("rgba(255,255,255,0.06)")
  })
})