import test from "node:test";
import assert from "node:assert/strict";
import { usageAccountLabel } from "./usage-account-label.js";

test("usage account labels include the public ID only when login identities repeat", () => {
  const accounts = [
    { id: "managed-a", label: "New account", email: "Person@Example.com" },
    { id: "managed-b", label: "New account", displayName: " person@example.com " },
    { id: "work", label: "Work", email: "work@example.com" }
  ];

  assert.equal(usageAccountLabel(accounts[0], accounts), "Person@Example.com · managed-a");
  assert.equal(usageAccountLabel(accounts[1], accounts), "person@example.com · managed-b");
  assert.equal(usageAccountLabel(accounts[2], accounts), "work@example.com");
});
