44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
|
|
import { resolveKuaishouFeifeiClaimUrl } from './index.js'
|
|
|
|
test('resolveKuaishouFeifeiClaimUrl prefers feifei h5 url over local claim url', () => {
|
|
assert.equal(
|
|
resolveKuaishouFeifeiClaimUrl({
|
|
claimUrl: 'https://ks.khhao.com/#/claim/local-token',
|
|
h5: {
|
|
entryUrl: 'https://feifei.example.com/h5/exchange',
|
|
rechargeUrl: 'https://feifei.example.com/h5/bind?code=abc',
|
|
},
|
|
}),
|
|
'https://feifei.example.com/h5/bind?code=abc',
|
|
)
|
|
})
|
|
|
|
test('resolveKuaishouFeifeiClaimUrl does not expose local claim token fallback', () => {
|
|
assert.equal(
|
|
resolveKuaishouFeifeiClaimUrl({
|
|
claimUrl: 'local-token',
|
|
h5: {},
|
|
}),
|
|
'',
|
|
)
|
|
})
|
|
|
|
test('resolveKuaishouFeifeiClaimUrl prefers internal short link', () => {
|
|
assert.equal(
|
|
resolveKuaishouFeifeiClaimUrl({
|
|
shortLink: {
|
|
code: 'AbCd1234',
|
|
url: 'https://ks.khhao.com/s/AbCd1234',
|
|
targetUrl: 'https://feifei.example.com/h5/bind?code=very-long',
|
|
},
|
|
h5: {
|
|
rechargeUrl: 'https://feifei.example.com/h5/bind?code=very-long',
|
|
},
|
|
}),
|
|
'https://ks.khhao.com/s/AbCd1234',
|
|
)
|
|
})
|