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);
|
||||
});
|
||||
@@ -108,6 +108,10 @@ test("issues external task links and supports one-to-one note submissions", asyn
|
||||
assert.match(partnerRoute, /请填写正确的曝光量和阅读量/);
|
||||
assert.match(partnerRoute, /笔记与领取凭证不匹配/);
|
||||
assert.match(partnerRoute, /action === "recover"/);
|
||||
assert.match(partnerRoute, /parseClaimantIdentifier/);
|
||||
assert.match(partnerRoute, /claimantIdentifier\.canonical/);
|
||||
assert.match(partnerRoute, /legacyPartnerId/);
|
||||
assert.match(partnerRoute, /微信号或手机号/);
|
||||
assert.match(partnerRoute, /extractXhsPublishUrl/);
|
||||
assert.match(partnerRoute, /小红书长链或短链/);
|
||||
assert.match(partnerRoute, /没有找到领取记录/);
|
||||
|
||||
Reference in New Issue
Block a user