import assert from "node:assert/strict";
import test from "node:test";
import { parseClaimantIdentifier } from "../lib/claimant-identifier.ts";

test("normalizes mainland mobile numbers into one unique identity", () => {
  assert.deepEqual(parseClaimantIdentifier("+86 138-0013-8000"), {
    canonical: "phone:13800138000",
    display: "13800138000",
    kind: "phone",
  });
  assert.deepEqual(parseClaimantIdentifier("手机号：13800138000"), {
    canonical: "phone:13800138000",
    display: "13800138000",
    kind: "phone",
  });
});

test("normalizes WeChat IDs case-insensitively while preserving display", () => {
  assert.deepEqual(parseClaimantIdentifier("微信号：Koc_User-01"), {
    canonical: "wechat:koc_user-01",
    display: "Koc_User-01",
    kind: "wechat",
  });
});

test("rejects nicknames and malformed identifiers", () => {
  assert.equal(parseClaimantIdentifier("巫凤萍"), null);
  assert.equal(parseClaimantIdentifier("1380013800"), null);
  assert.equal(parseClaimantIdentifier("123456"), null);
});
