first commit
This commit is contained in:
@@ -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')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user