Files
dsh-telegram-channel/tests/apiproxy.test.ts
T
owoandCursor 5dbe833205 fix: resolve apiProxy via ctx.get for /model (v0.3.2)
Cordis throws on ctx.apiProxy without inject; use ctx.get and declare apiProxy inject so catalog and model APIs work under dsh web.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-14 20:20:55 +08:00

26 lines
747 B
TypeScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { resolveApiProxy } from '../src/apiproxy.ts'
test('resolveApiProxy uses ctx.get and avoids bare ctx.apiProxy', () => {
const api = { sessions: {} }
let touchedBare = false
const ctx = {
get(name: string) {
return name === 'apiProxy' ? api : undefined
},
get apiProxy() {
touchedBare = true
throw new Error('cannot get property "apiProxy" without inject')
},
}
assert.equal(resolveApiProxy(ctx as any), api)
assert.equal(touchedBare, false)
})
test('resolveApiProxy falls back to own-property mock', () => {
const api = { sessions: {} }
const ctx = { apiProxy: api }
assert.equal(resolveApiProxy(ctx as any), api)
})