Use unique contact identifiers for KOC claims
This commit is contained in:
30
tests/claimant-identifier.test.mjs
Normal file
30
tests/claimant-identifier.test.mjs
Normal file
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user