import { describe, expect, it } from "vitest";
import { fmtCredits, ASSIGNABLE_ROLES } from "./api";

describe("fmtCredits", () => {
  it("micro → 人类可读", () => {
    expect(fmtCredits(0)).toBe("0");
    expect(fmtCredits(1_500_000)).toBe("1.5"); // 1.5 积分
    expect(fmtCredits(2_000_000)).toBe("2"); // 整数不留小数尾巴
    expect(fmtCredits(1_234_000_000)).toBe("1.2K");
    expect(fmtCredits(5_000_000_000_000)).toBe("5.0M");
  });
  it("负余额（软扣可为负）不丢符号", () => {
    expect(fmtCredits(-1_500_000)).toBe("-1.5");
  });
});

describe("ASSIGNABLE_ROLES", () => {
  it("不含 owner —— owner 只能转让，后端同样拦", () => {
    expect(ASSIGNABLE_ROLES).not.toContain("owner");
  });
});
