diff options
| author | Somhairle H. Marisol <[email protected]> | 2026-09-17 14:32:37 +0800 |
|---|---|---|
| committer | Somhairle H. Marisol <[email protected]> | 2026-09-17 14:32:37 +0800 |
| commit | 5c0ba37eda80d39e6ceca59bb1d5f4942f858995 (patch) | |
| tree | 948723f9cedf7ccb0707fa6ee516bd30fe20fd10 /frontend/src/lib/__tests__ | |
| download | strategy-lab-5c0ba37eda80d39e6ceca59bb1d5f4942f858995.tar.gz | |
chore: establish Strategy Lab source baseline (development, not release)
Diffstat (limited to 'frontend/src/lib/__tests__')
| -rw-r--r-- | frontend/src/lib/__tests__/state.test.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/frontend/src/lib/__tests__/state.test.ts b/frontend/src/lib/__tests__/state.test.ts new file mode 100644 index 0000000..245c38c --- /dev/null +++ b/frontend/src/lib/__tests__/state.test.ts @@ -0,0 +1,21 @@ +import { describe, expect, it, vi, afterEach } from 'vitest'; +import { extractStatusMessage } from '../state'; + +afterEach(() => vi.unstubAllGlobals()); + +describe('extractStatusMessage', () => { + it('prefers ApiError.code-mapped Chinese text', () => { + const msg = extractStatusMessage({ + status: 409, + code: 'stale_generation', + message: '草稿已被其他修改更新' + }); + expect(msg).toContain('409'); + expect(msg).toContain('草稿已被其他修改更新'); + }); + + it('handles unknown errors without leaking internals', () => { + const msg = extractStatusMessage({ message: 'boom' }); + expect(msg).toContain('出错'); + }); +}); |
