24 lines
884 B
JavaScript
24 lines
884 B
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { apply, name, inject } from '../index.js'
|
|
import { createFakeHost, tempStateFile } from './fake-ctx.js'
|
|
|
|
test('apply 注册提示词与 /api/sansheng 路由并可处理请求', async () => {
|
|
const fake = createFakeHost()
|
|
const statePath = await tempStateFile()
|
|
await apply(fake.ctx, { statePath })
|
|
|
|
assert.equal(name, 'sansheng')
|
|
assert.ok(inject.includes('connection'))
|
|
assert.ok(fake.getPromptSection(), '应注册 systemPrompt section')
|
|
|
|
const route = fake.getRoute()
|
|
assert.equal(route.path, '/api/sansheng')
|
|
assert.deepEqual(route.methods, ['POST'])
|
|
|
|
const res = await route.fetch({ json: async () => ({ endpoint: 'open', payload: { path: '/w', name: '接线项目' } }) })
|
|
const body = await res.json()
|
|
assert.ok(body.ok)
|
|
assert.equal(body.value.project.seats.length, 10)
|
|
})
|