Files
deepseek-harness/packages/client/connection/tests/api-helpers.client.spec.ts
T
imccyu 804b1ffbfc refactor(api): converge the Remote failure vocabulary and client surface
Single RemoteError with a merge-extensible, domain-prefixed code map;
owners throw at the failure point; streams surface marked failures;
clients consume ctx.remote directly with isRemoteFailure as the only
discrimination point and construct no failure instances.
2026-08-28 22:37:36 +08:00

22 lines
891 B
TypeScript

/**
* 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: 'gateway/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 })
})
})