import { describe, it, expect } from "vitest"
import { formSchema } from "./exam-form-types"

describe("formSchema", () => {
  it("should validate manual mode with required fields", () => {
    const result = formSchema.safeParse({
      mode: "manual",
      title: "Test Exam",
      subject: "math",
      grade: "g1",
      difficulty: "3",
      totalScore: 100,
      durationMin: 90,
    })
    expect(result.success).toBe(true)
  })

  it("should reject manual mode without title", () => {
    const result = formSchema.safeParse({
      mode: "manual",
      title: "",
      subject: "math",
      grade: "g1",
      difficulty: "3",
      totalScore: 100,
      durationMin: 90,
    })
    expect(result.success).toBe(false)
  })

  it("should validate AI mode with source text", () => {
    const result = formSchema.safeParse({
      mode: "ai",
      aiSourceText: "Some exam text content here",
    })
    expect(result.success).toBe(true)
  })

  it("should reject AI mode without source text", () => {
    const result = formSchema.safeParse({
      mode: "ai",
      aiSourceText: "",
    })
    expect(result.success).toBe(false)
  })
})
