feat(半自动履约): 补齐微博游戏角色绑定流程
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { buildServerZone, compareBindingIdentity, resolveServerZone } from './binding-identity.js'
|
||||
import { getAccountBindingPolicy } from './platform-policy.js'
|
||||
|
||||
test('平台能力声明统一描述角色查询、确认与换绑方式', () => {
|
||||
const huya = getAccountBindingPolicy('huya')
|
||||
assert.equal(huya.bindingKind, 'game_role')
|
||||
assert.equal(huya.queryOwner, 'order_site')
|
||||
assert.equal(huya.confirmationMode, 'customer_match')
|
||||
assert.equal(huya.rebindMode, 'platform_confirm')
|
||||
|
||||
const douyu = getAccountBindingPolicy('douyu')
|
||||
assert.equal(douyu.bindingKind, 'game_role')
|
||||
assert.equal(douyu.queryOwner, 'live_hub')
|
||||
assert.deepEqual(douyu.requiredFields, ['roleName', 'serverZone'])
|
||||
|
||||
const weibo = getAccountBindingPolicy('weibo')
|
||||
assert.equal(weibo.bindingKind, 'game_role')
|
||||
assert.equal(weibo.bindingRequired, true)
|
||||
assert.equal(weibo.requiresCustomerProfile, false)
|
||||
assert.equal(weibo.confirmationMode, 'platform_verified')
|
||||
assert.equal(weibo.rebindMode, 'rescan_qr')
|
||||
assert.deepEqual(weibo.requiredFields, ['roleName'])
|
||||
})
|
||||
|
||||
test('区服规范化为同一口径', () => {
|
||||
assert.equal(resolveServerZone('苹果(iOS) · QQ'), '苹果Q区')
|
||||
assert.equal(resolveServerZone('微信 安卓(android)'), '安卓V区')
|
||||
assert.equal(buildServerZone('ios', 'wechat'), '苹果V区')
|
||||
assert.equal(buildServerZone('android', 'qq'), '安卓Q区')
|
||||
})
|
||||
|
||||
test('公共身份比对明确区分 match、mismatch 与 unknown', () => {
|
||||
const fields = ['roleName', 'roleId', 'serverZone'] as const
|
||||
assert.equal(
|
||||
compareBindingIdentity({
|
||||
requiredFields: fields,
|
||||
customer: { roleName: '角色 A', roleId: '1001', serverZone: '安卓Q区' },
|
||||
platform: { roleName: '角色A', roleId: '1001', serverZone: '安卓Q区' },
|
||||
}).verdict,
|
||||
'match',
|
||||
)
|
||||
assert.equal(
|
||||
compareBindingIdentity({
|
||||
requiredFields: fields,
|
||||
customer: { roleName: '角色A', roleId: '1001', serverZone: '安卓Q区' },
|
||||
platform: { roleName: '角色B', roleId: '1001', serverZone: '安卓Q区' },
|
||||
}).verdict,
|
||||
'mismatch',
|
||||
)
|
||||
assert.equal(
|
||||
compareBindingIdentity({
|
||||
requiredFields: fields,
|
||||
customer: { roleName: '角色A', roleId: '', serverZone: '安卓Q区' },
|
||||
platform: { roleName: '角色A', roleId: '1001', serverZone: '安卓Q区' },
|
||||
}).verdict,
|
||||
'unknown',
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user