976bde37cc
与 REST/OpenAPI 并存,按实例权限自动 tools/list,免手填工具。 Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
941 B
TypeScript
27 lines
941 B
TypeScript
import { BadRequestException } from '@nestjs/common';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { wecomPluginCaller, wecomPluginMcpErrorText, wecomPluginQueryArg } from './wecom-plugin.util';
|
|
|
|
describe('wecomPluginCaller', () => {
|
|
it('prefers X-WeCom-User-Id', () => {
|
|
expect(wecomPluginCaller({ headers: { 'x-wecom-userid': 'alice', userid: 'bob' } })).toBe('alice');
|
|
});
|
|
|
|
it('falls back to plugin', () => {
|
|
expect(wecomPluginCaller({ headers: {} })).toBe('plugin');
|
|
});
|
|
});
|
|
|
|
describe('wecomPluginMcpErrorText', () => {
|
|
it('unwraps Nest HttpException message', () => {
|
|
expect(wecomPluginMcpErrorText(new BadRequestException('请提供查询关键词 q'))).toBe('请提供查询关键词 q');
|
|
});
|
|
});
|
|
|
|
describe('wecomPluginQueryArg', () => {
|
|
it('stringifies numbers and drops empty', () => {
|
|
expect(wecomPluginQueryArg(2)).toBe('2');
|
|
expect(wecomPluginQueryArg(' ')).toBeUndefined();
|
|
});
|
|
});
|