Files
core2026/app/game-frontend/test/commandGeneralGroups.test.ts
T
Hide_DandClaude Opus 5.5 4a50c354fe 등용·장수대상임관 대상의 타국 장수 정보를 Ref 공개 범위로 제한하고 국가색 묶음 복원
- 명령표의 등용·장수대상임관·공통 장수 fallback에서 타국·재야 장수의 금·쌀·병력·훈련·사기·부대·위치 도시를 제외
- Ref exportJSVars 범위(이름·국가·NPC·통/무/지)만 싣고 국가 묶음용 nationId 추가
- 재야 actor에게는 같은 국가 명령 후보를 보내지 않음
- 등용·장수대상임관 후보를 Ref SelectGeneral groupByNation처럼 국가색 머리와 optgroup으로 묶음
- 증여·포상·몰수·부대탈퇴지시·선양 후보에 Ref의 통/무/지 표시

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-23 14:55:39 +00:00

46 lines
1.7 KiB
TypeScript

import assert from 'node:assert/strict';
import { test } from 'node:test';
import {
groupGeneralOptionsByNation,
NATION_GROUPED_GENERAL_COMMANDS,
} from '../src/components/command/commandGeneralGroups.ts';
const nations = [
{ value: 1, label: '위', color: '#FFD700' },
{ value: 2, label: '오', color: '#000080' },
];
void test('groups general options by nation in first-appearance order like Ref SelectGeneral', () => {
const groups = groupGeneralOptionsByNation(
[
{ value: 11, label: '가 (오)', nationId: 2 },
{ value: 12, label: '나 (재야)', nationId: 0 },
{ value: 13, label: '다 (위)', nationId: 1 },
{ value: 14, label: '라 (오)', nationId: 2 },
{ value: 15, label: '마 (위)', nationId: 1, npcState: 1 },
],
nations
);
assert.deepEqual(
groups.map((group) => [group.name, group.color, group.textColor, group.options.map((option) => option.value)]),
[
['오', '#000080', '#FFFFFF', [11, 14]],
['재야', '#000000', '#FFFFFF', [12]],
['위', '#FFD700', '#000000', [13, 15]],
]
);
});
void test('falls back to the option nation name and the wanderer color for unknown nations', () => {
const [group] = groupGeneralOptionsByNation(
[{ value: 1, label: '가', nationId: 9, targetNames: { name: '가', nationName: '멸망국' } }],
nations
);
assert.deepEqual([group?.name, group?.color], ['멸망국', '#000000']);
assert.deepEqual(groupGeneralOptionsByNation([], nations), []);
});
void test('only Ref groupByNation commands are grouped', () => {
assert.deepEqual([...NATION_GROUPED_GENERAL_COMMANDS], ['che_등용', 'che_장수대상임관']);
});