Files
digital-me-history/digital-me-web/test/careerHistory.test.ts
T
admin 0593ff7e62
nginx serve /uploads direct (audio speed) / patch-nginx (push) Failing after 1m34s
数字我 Digital Me:全量入库(大文件走 Git LFS)
2026-10-10 16:24:43 +08:00

61 lines
2.9 KiB
TypeScript
Raw 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 { careerTrajectoryStories } from '../src/data/careerTrajectories.ts';
import {
applyCareerDynastyStoryline,
careerDynastyStoryline,
curatedCareerDynastyStorylineCount,
curatedCareerIds,
curatedDynastyCodes,
} from '../src/data/careerDynastyStorylines.ts';
import { careerHistoryIdForProfession, normalizeCareerHistoryId } from '../src/lib/careerHistory.ts';
test('all 79 modern professions keep their own life trajectory', () => {
assert.equal(careerTrajectoryStories.length, 79);
assert.equal(careerHistoryIdForProfession('game_blogger'), 'game_blogger');
assert.equal(careerHistoryIdForProfession('developer'), 'developer');
assert.equal(careerHistoryIdForProfession('photographer'), 'photographer');
assert.equal(careerHistoryIdForProfession('therapist'), 'therapist');
assert.equal(careerHistoryIdForProfession('beauty_blogger'), 'beauty_blogger');
assert.equal(careerHistoryIdForProfession('esports'), 'esports');
assert.equal(careerHistoryIdForProfession('makeup_artist'), 'makeup_artist');
assert.equal(careerHistoryIdForProfession('lawyer'), 'lawyer');
});
test('shared legacy links still resolve to the new profession ids', () => {
assert.equal(normalizeCareerHistoryId('game-blogger'), 'game_blogger');
assert.equal(normalizeCareerHistoryId('programmer'), 'developer');
assert.equal(normalizeCareerHistoryId('psychologist'), 'therapist');
assert.equal(normalizeCareerHistoryId('makeup-blogger'), 'beauty_blogger');
assert.equal(careerHistoryIdForProfession('not-a-profession'), undefined);
assert.equal(careerHistoryIdForProfession(undefined), undefined);
});
test('first curated batch contains 40 complete career-by-dynasty storylines', () => {
assert.equal(curatedCareerDynastyStorylineCount, 40);
for (const careerId of curatedCareerIds) {
for (const dynastyCode of curatedDynastyCodes) {
const storyline = careerDynastyStoryline(careerId, dynastyCode);
assert.ok(storyline, `${careerId}/${dynastyCode} should exist`);
assert.equal(storyline.acts.length, 4);
assert.ok(storyline.acts.every((act) => act.length >= 12));
assert.ok(storyline.choice.includes('?'));
assert.ok(storyline.result.length >= 12);
}
}
});
test('one profession receives genuinely different roles and actions across dynasties', () => {
const developer = careerTrajectoryStories.find((story) => story.id === 'developer');
assert.ok(developer);
const liao = applyCareerDynastyStoryline(developer, 'liao', '辽');
const tang = applyCareerDynastyStoryline(developer, 'tang', '唐');
const ming = applyCareerDynastyStoryline(developer, 'ming', '明');
assert.equal(liao.ancientRole, '北枢密院军簿计吏');
assert.equal(tang.ancientRole, '军中计吏');
assert.equal(ming.ancientRole, '户部黄册勾稽吏');
assert.notDeepEqual(liao.acts, tang.acts);
assert.notEqual(liao.choice, ming.choice);
});