feat(framework): config 调试 profiles + ?profile= 切换
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { test } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { resolveActiveProfile, PROFILES, ACTIVE_PROFILE } from '../../YouleNexus/assets/framework/config/profiles.ts';
|
||||
|
||||
test('默认返回 ACTIVE_PROFILE', () => {
|
||||
const p = resolveActiveProfile('');
|
||||
assert.equal(p.name, ACTIVE_PROFILE);
|
||||
});
|
||||
|
||||
test('prod profile 无调试覆盖、isDebugger=false', () => {
|
||||
const prod = PROFILES['prod'];
|
||||
assert.equal(prod.isDebugger, false);
|
||||
assert.equal(prod.server, undefined);
|
||||
assert.equal(prod.identity, undefined);
|
||||
assert.ok(prod.gameserver && prod.gameserver.length > 0);
|
||||
});
|
||||
|
||||
test('?profile=local 切到 local,含调试服地址', () => {
|
||||
const p = resolveActiveProfile('?profile=local');
|
||||
assert.equal(p.name, 'local');
|
||||
assert.ok(p.server && p.server.startsWith('ws://'));
|
||||
});
|
||||
|
||||
test('未知 profile 回退到 ACTIVE_PROFILE', () => {
|
||||
const p = resolveActiveProfile('?profile=nope');
|
||||
assert.equal(p.name, ACTIVE_PROFILE);
|
||||
});
|
||||
Reference in New Issue
Block a user