完善虎牙已有绑定角色确认与重新扫码换绑流程
This commit is contained in:
@@ -44,3 +44,30 @@ test('创建登录会话按真实 Connector 协议发送蛇形字段', async ()
|
||||
globalThis.fetch = originalFetch
|
||||
}
|
||||
})
|
||||
|
||||
test('重新扫码换绑会向 Connector 传递 force_rebind', async () => {
|
||||
const originalFetch = globalThis.fetch
|
||||
let requestBody: Record<string, unknown> = {}
|
||||
globalThis.fetch = (async (_url: string | URL | Request, init?: RequestInit) => {
|
||||
requestBody = JSON.parse(String(init?.body || '{}')) as Record<string, unknown>
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
sessionId: 'session-1',
|
||||
status: 'qr_pending',
|
||||
qrImage: 'data:image/png;base64,AA==',
|
||||
qrExpiresAt: '2026-11-09T00:00:00Z',
|
||||
bindGameAccount: '',
|
||||
bindGameRole: '',
|
||||
bindGameChannel: '',
|
||||
message: '请扫码换绑',
|
||||
}),
|
||||
{ status: 200, headers: { 'Content-Type': 'application/json' } },
|
||||
)
|
||||
}) as typeof fetch
|
||||
try {
|
||||
await connector.startHuyaBinding('session-1', 'external', { forceRebind: true })
|
||||
assert.deepEqual(requestBody, { force_rebind: true })
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user