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>
26 lines
747 B
TypeScript
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)
|
|
})
|