first commit

This commit is contained in:
baozaotumao2025
2026-07-18 21:10:39 +08:00
commit 1b90e552a5
91 changed files with 9056 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
import { describe, expect, it } from 'vitest'
import { AppError, normalizeError } from '../../../src/errors'
describe('normalizeError', () => {
it('preserves backend diagnostics in a safe application error', () => {
const error = normalizeError({
status: 409,
body: { error: { code: 'CONFLICT', message: '运行状态冲突', request_id: 'req-42' } },
})
expect(error).toBeInstanceOf(AppError)
expect(error).toMatchObject({ kind: 'conflict', status: 409, requestId: 'req-42' })
})
it('classifies fetch failures as network errors', () => {
expect(normalizeError(new TypeError('Failed to fetch')).kind).toBe('network')
})
})