Files
joywayer 35216f75e7 feat: integrate room framework and isolated subgame bundles
Complete room UI and protocol integration, move game definitions and resources behind bundle entries, publish authoritative version XML, and document single-game builds. Include all current resource changes and experiment artifacts.
2026-09-09 03:13:18 +08:00

39 lines
1.5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { resolveIdentity } from '../../YouleNexus/assets/framework/config/identity.ts';
import { BUILD_IDENTITY } from '../fixtures/build-identity.ts';
test('BUILD_IDENTITY 含全部字段且 gameid 为固定 token', () => {
assert.ok(BUILD_IDENTITY.gameid.length > 0);
assert.ok('agentid' in BUILD_IDENTITY);
assert.ok('channelid' in BUILD_IDENTITY);
assert.ok('marketid' in BUILD_IDENTITY);
assert.equal(typeof BUILD_IDENTITY.version, 'number'); // 协议 version = 数字 versionCode
});
test('resolveIdentity:后面的 source 覆盖前面的', () => {
const id = resolveIdentity([
() => BUILD_IDENTITY,
() => ({ agentid: 'A2' }),
() => ({ agentid: 'A3', channelid: 'C3' }),
]);
assert.equal(id.agentid, 'A3');
assert.equal(id.channelid, 'C3');
assert.equal(id.gameid, BUILD_IDENTITY.gameid); // 未被覆盖
});
test('resolveIdentity:undefined / null / 空串 不覆盖', () => {
const id = resolveIdentity([
() => BUILD_IDENTITY,
() => ({ agentid: undefined as any, channelid: '' , marketid: null as any }),
]);
assert.equal(id.agentid, BUILD_IDENTITY.agentid);
assert.equal(id.channelid, BUILD_IDENTITY.channelid);
assert.equal(id.marketid, BUILD_IDENTITY.marketid);
});
test('resolveIdentity:marketid=0 是有效值,应覆盖', () => {
const id = resolveIdentity([() => BUILD_IDENTITY, () => ({ marketid: 0 })]);
assert.equal(id.marketid, 0);
});