Files
deepseek-harness/packages/client/connection/tests/api-helpers.spec.ts
T

22 lines
883 B
TypeScript
Raw Normal View History

/**
* Contract-layer helpers: transport-error folding and response unwrapping.
* (The assistant block classifier half of the legacy spec lives in
* runtime/tests — the classifier moved there.)
*/
import { describe, expect, it } from 'vitest'
import { RpcId, resultOf, transportError } from '../src/client/api.ts'
describe('transportError', () => {
it('folds an Error to internal keeping the message, and stringifies non-Errors', () => {
expect(transportError(new Error('线断了'))).toEqual({ ok: false, error: { code: 'internal', message: '线断了', details: {} } })
expect(transportError('raw string')).toMatchObject({ ok: false, error: { message: 'raw string' } })
})
})
describe('resultOf', () => {
it('unwraps the result slot', () => {
expect(resultOf({ rpcId: RpcId('r'), result: { ok: true, value: 7 } })).toEqual({ ok: true, value: 7 })
})
})