import { describe, expect, it } from "vitest";
import {
  buildSystemRoleConfigUpdateData,
  systemRoleConfigUpdateInputSchema,
} from "../router/system-role-config-support.js";

describe("system role config support", () => {
  it("validates the update input schema", () => {
    expect(systemRoleConfigUpdateInputSchema.parse({
      role: "ADMIN",
      label: "Administrators",
      description: null,
      color: "#000000",
      defaultPermissions: ["users.read"],
    })).toEqual({
      role: "ADMIN",
      label: "Administrators",
      description: null,
      color: "#000000",
      defaultPermissions: ["users.read"],
    });
  });

  it("builds sparse update payloads", () => {
    expect(buildSystemRoleConfigUpdateData({
      role: "MANAGER",
      description: null,
      defaultPermissions: ["projects.write"],
    })).toEqual({
      description: null,
      defaultPermissions: ["projects.write"],
    });
  });
});
