장수 55종과 수뇌 35종의 상태, 로그, 메시지, 예약 턴 비교를 닫습니다. 실제 시나리오 프로필과 대표 PostgreSQL 수명주기, 즉시 외교와 출병 회귀를 추가하고 발견된 Ref 로그 및 생성 장수 저장 차이를 교정합니다.
94 lines
3.2 KiB
TypeScript
94 lines
3.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { LEGACY_RANK_DATA_TYPES, RANK_DATA_TYPES } from '@sammo-ts/common';
|
|
|
|
import {
|
|
applyPersistedRankRowsToMeta,
|
|
buildInitialRankRows,
|
|
buildLegacyComparableInitialRankRows,
|
|
buildLegacyComparableRankRows,
|
|
buildPersistedRankRows,
|
|
rankMetaKey,
|
|
} from '../src/turn/rankData.js';
|
|
|
|
describe('rank data projection', () => {
|
|
it('projects every core row while preserving legacy key and integer semantics', () => {
|
|
const rows = buildPersistedRankRows({
|
|
id: 7,
|
|
nationId: 2,
|
|
experience: 10.5,
|
|
dedication: 20.49,
|
|
meta: {
|
|
rank_warnum: '3.5',
|
|
ttw: 4.5,
|
|
inherit_earned: '9',
|
|
dex1: 12,
|
|
},
|
|
});
|
|
|
|
expect(rows).toHaveLength(RANK_DATA_TYPES.length);
|
|
expect(rows).toEqual(
|
|
expect.arrayContaining([
|
|
{ generalId: 7, nationId: 2, type: 'experience', value: 11 },
|
|
{ generalId: 7, nationId: 2, type: 'dedication', value: 20 },
|
|
{ generalId: 7, nationId: 2, type: 'warnum', value: 4 },
|
|
{ generalId: 7, nationId: 2, type: 'ttw', value: 5 },
|
|
{ generalId: 7, nationId: 2, type: 'inherit_earned', value: 9 },
|
|
{ generalId: 7, nationId: 2, type: 'dex1', value: 12 },
|
|
])
|
|
);
|
|
expect(
|
|
buildLegacyComparableRankRows({
|
|
id: 7,
|
|
nationId: 2,
|
|
experience: 10.5,
|
|
dedication: 20.49,
|
|
meta: {},
|
|
})
|
|
).toHaveLength(LEGACY_RANK_DATA_TYPES.length);
|
|
|
|
const initialRows = buildInitialRankRows({
|
|
id: 8,
|
|
nationId: 2,
|
|
experience: 100,
|
|
dedication: 200,
|
|
meta: { rank_warnum: 9, inherit_spent_dyn: 7 },
|
|
});
|
|
expect(initialRows).toEqual(
|
|
expect.arrayContaining([
|
|
{ generalId: 8, nationId: 0, type: 'experience', value: 0 },
|
|
{ generalId: 8, nationId: 0, type: 'warnum', value: 0 },
|
|
{ generalId: 8, nationId: 0, type: 'inherit_spent_dyn', value: 7 },
|
|
])
|
|
);
|
|
expect(
|
|
buildLegacyComparableInitialRankRows({
|
|
id: 8,
|
|
nationId: 2,
|
|
experience: 100,
|
|
dedication: 200,
|
|
meta: {},
|
|
})
|
|
).toHaveLength(LEGACY_RANK_DATA_TYPES.length);
|
|
});
|
|
|
|
it('loads persisted rows into the same raw and prefixed meta keys used by commands', () => {
|
|
const meta: Record<string, unknown> = {};
|
|
applyPersistedRankRowsToMeta(meta, [
|
|
{ type: 'warnum', value: 3 },
|
|
{ type: 'ttw', value: 4 },
|
|
{ type: 'inherit_spent', value: 5 },
|
|
{ type: 'dex1', value: 6 },
|
|
{ type: 'unknown', value: 99 },
|
|
]);
|
|
|
|
expect(meta).toEqual({
|
|
rank_warnum: 3,
|
|
ttw: 4,
|
|
inherit_spent: 5,
|
|
dex1: 6,
|
|
});
|
|
expect(rankMetaKey('warnum')).toBe('rank_warnum');
|
|
expect(rankMetaKey('betgold')).toBe('betgold');
|
|
});
|
|
});
|