Files
digital-me-history/digital-me-backend/test/zhaoyaojing.test.js
T
admin 0593ff7e62
nginx serve /uploads direct (audio speed) / patch-nginx (push) Failing after 1m34s
数字我 Digital Me:全量入库(大文件走 Git LFS)
2026-10-10 16:24:43 +08:00

28 lines
1.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import test from 'node:test';
import assert from 'node:assert/strict';
import { buildDebunkPrompt, parseVerdict, VERDICTS } from '../src/zhaoyaojing.js';
test('buildDebunkPrompt:三档定义 + 敢说查不实 + 只输出JSON', () => {
const msgs = buildDebunkPrompt('诸葛亮借东风');
assert.equal(msgs[0].role, 'system');
assert.ok(/shizheng/.test(msgs[0].content) && /yanyi/.test(msgs[0].content) && /cunyi/.test(msgs[0].content));
assert.ok(/查不實|查不实|存疑/.test(msgs[0].content), '须含敢说查不实的铁律');
assert.ok(/JSON/.test(msgs[0].content));
assert.ok(msgs[1].content.includes('诸葛亮借东风'));
});
test('parseVerdict:从LLM输出宽松解析(容围栏/前后缀)', () => {
const raw = '好的,判定如下:\n```json\n{"verdict":"yanyi","title":"借东风是演义虚构","explain":"《三国演义》桥段,正史无。","real":"《三国志·周瑜传》载『时风盛猛』为自然大风。","cites":["《三国志·吴书·周瑜传》"]}\n```';
const v = parseVerdict(raw);
assert.equal(v.verdict, 'yanyi');
assert.equal(v.label, VERDICTS.yanyi.label);
assert.equal(v.tone, 'crit');
assert.ok(v.title && v.real && v.cites.length === 1);
});
test('parseVerdict:非法/无verdict → null(前端回落显 raw)', () => {
assert.equal(parseVerdict('我不确定'), null);
assert.equal(parseVerdict('{"verdict":"nonsense"}'), null);
assert.equal(parseVerdict(''), null);
});