// @vitest-environment node

import { describe, expect, it, vi } from "vitest";
import {
  normalizeUserStatusValue,
  userStatusLabel,
  userStatusValues,
} from "./userStatus";

vi.mock("../../lib/i18n", () => ({
  t: (key: string, fallback?: string) => fallback ?? key,
}));

describe("userStatus", () => {
  it("exposes canonical user status values", () => {
    expect(userStatusValues).toEqual([
      "active",
      "temporary_leave",
      "suspended",
      "preboarding",
      "baron_guest",
      "extended_leave",
      "archived",
    ]);
  });

  it("normalizes legacy status values", () => {
    expect(normalizeUserStatusValue("inactive")).toBe("preboarding");
    expect(normalizeUserStatusValue("leave_of_absence")).toBe(
      "temporary_leave",
    );
    expect(normalizeUserStatusValue("baron_only")).toBe("baron_guest");
  });

  it("falls back to preboarding when status is missing", () => {
    expect(normalizeUserStatusValue(undefined)).toBe("preboarding");
    expect(normalizeUserStatusValue(null)).toBe("preboarding");
  });

  it("uses canonical labels for legacy status values", () => {
    expect(userStatusLabel("baron_only")).toBe("baron_guest");
  });
});
