Files
youle_cocos/cocoscreator_projects/framework-tests/platform-login/lobby-links.test.ts
T

17 lines
1.1 KiB
TypeScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { openLobbyUrl, resolveLobbyLaunchMode } from '../../YouleNexus/assets/framework/adapters/native/lobby-links.ts';
test('launch mode uses original query or injected bridge field and rejects invalid values',()=>{
assert.equal(resolveLobbyLaunchMode('',false,undefined),0);
assert.equal(resolveLobbyLaunchMode('?Launchtype=1',false,0),1);
assert.equal(resolveLobbyLaunchMode('?Launchtype=0',true,'1'),1);
assert.throws(()=>resolveLobbyLaunchMode('',true,undefined),/Launchtype/);
assert.throws(()=>resolveLobbyLaunchMode('?Launchtype=bad',false,undefined),/Launchtype/);
});
test('announcement links preserve fixUrl and distinct native timestamp conventions',()=>{
const calls:unknown[]=[];
openLobbyUrl('https://example.test/?a=1?b=2',{kind:'settings',browser:u=>calls.push(u)},()=>123);
openLobbyUrl('https://example.test/?a=1?b=2',{kind:'bridge',call:(n,d)=>calls.push([n,d])},()=>123);
assert.deepEqual(calls,['https://example.test/?a=1&b=2&timestamp=123',['browser','https://example.test/?a=1&b=2']]);
});