Files
claude-code/packages/pokemon/src/__tests__/fallback.test.ts
claude-code-best 1217c453c4 feat: 同步 pkmn Dex 全部 1025 只精灵,新增 SpeciesPicker 搜索选择器
- SpeciesId 从 10 项联合类型改为 string,动态从 @pkmn/sim Dex 加载 1025 只精灵
- getSpecies() 改用 Dex.species.get() 直接查找(gen wrapper 仅覆盖 733/1025)
- SUPPLEMENT/DEX_TO_SPECIES 动态生成,未收录 species 使用默认值兜底
- names/fallback 改为 partial records,缺失时回退到 Dex 英文名/通用 sprite
- 新增 SpeciesPicker 组件(基于 FuzzyPicker),支持中英文/编号搜索选择精灵
- BattleFlow configSelect 阶段替换为 SpeciesPicker,删除旧的上下翻页逻辑
- evolution 移除 ALL_SPECIES_IDS 限制,所有 Dex 物种均可进化

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-22 15:15:19 +08:00

34 lines
1.0 KiB
TypeScript

import { describe, test, expect } from 'bun:test'
import { getFallbackSprite } from '../sprites/fallback'
import { ALL_SPECIES_IDS } from '../types'
describe('getFallbackSprite', () => {
test('returns 5 lines for every species', () => {
for (const id of ALL_SPECIES_IDS) {
const sprite = getFallbackSprite(id)
expect(sprite.length).toBe(5)
}
})
test('returns generic fallback for unknown species', () => {
const sprite = getFallbackSprite('unknowndefinitelynotarealspecies')
expect(sprite.length).toBe(5)
expect(sprite[0]).toContain('.---')
})
test('returns curated sprite for pikachu', () => {
const sprite = getFallbackSprite('pikachu')
expect(sprite[0]).toContain('/\\')
})
test('each line has consistent width', () => {
for (const id of ALL_SPECIES_IDS) {
const sprite = getFallbackSprite(id)
const widths = sprite.map(line => line.length)
const maxWidth = Math.max(...widths)
const minWidth = Math.min(...widths)
expect(maxWidth - minWidth).toBeLessThanOrEqual(2)
}
})
})