import { describe, it, expect } from "vitest";
import { applicationSchema } from "@/lib/membership/application-schema";

const valid = {
  name: "Dr Jane Doe",
  email: "jane@hospital.org",
  password: "supersecret123",
  country: "United Kingdom",
  institution: "Royal Orthopaedic Hospital",
  professionalRole: "consultant",
  motivationText: "I want to collaborate on shoulder research with the OrthoGlobe network.",
  orcidUrl: "https://orcid.org/0000-0001-2345-6789",
  linkedinUrl: "",
};

describe("applicationSchema", () => {
  it("accepts a valid application", () => {
    expect(applicationSchema.parse(valid).email).toBe("jane@hospital.org");
  });
  it("rejects motivation > 200 chars", () => {
    expect(() => applicationSchema.parse({ ...valid, motivationText: "x".repeat(201) })).toThrow();
  });
  it("rejects bad professional role", () => {
    expect(() => applicationSchema.parse({ ...valid, professionalRole: "wizard" })).toThrow();
  });
  it("requires password >= 12 chars", () => {
    expect(() => applicationSchema.parse({ ...valid, password: "short" })).toThrow();
  });
});
