test: 新增数据层测试 + 引擎修复

- 新增 pkmn.test.ts: stat 映射测试
- 新增 species.test.ts: 物种数据测试
- 新增 xpTable.test.ts: XP 公式测试
- 新增 evMapping.test.ts: EV 映射测试
- 新增 names.test.ts: 多语言名称测试
- 新增 fallback.test.ts: 精灵 fallback 测试
- 修复 engine.ts 类型

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
claude-code-best
2026-04-22 00:45:57 +08:00
parent 96e6d33414
commit fa8e45e933
7 changed files with 316 additions and 6 deletions

View File

@@ -0,0 +1,28 @@
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 pikachu fallback for unknown species', () => {
const sprite = getFallbackSprite('unknown' as any)
expect(sprite).toEqual(getFallbackSprite('pikachu'))
})
test('each line has consistent width', () => {
for (const id of ALL_SPECIES_IDS) {
const sprite = getFallbackSprite(id)
const widths = sprite.map(line => line.length)
// All lines should be roughly the same width
const maxWidth = Math.max(...widths)
const minWidth = Math.min(...widths)
expect(maxWidth - minWidth).toBeLessThanOrEqual(2)
}
})
})