import { describe, expect, test } from "vitest";
import { FormValidationError, parseForm } from "@/shared/forms/validation";
import { teamFormSchema } from "./schema";

describe("team form schema", () => {
  test("normalizes team payload", () => {
    expect(parseForm(teamFormSchema, { description: " 平台运营 ", name: " 运营一部 ", parentId: "2", sort: "2" })).toEqual({
      description: "平台运营",
      name: "运营一部",
      parentId: 2,
      sort: 2
    });
  });

  test("rejects empty team name", () => {
    expect(() => parseForm(teamFormSchema, { description: "", name: "", sort: 0 })).toThrow(FormValidationError);
  });
});
