Files
Jyotisha/frontend/tests/chat-definition-lists.test.ts
T

45 lines
1.9 KiB
TypeScript
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 assert from "node:assert/strict";
import test from "node:test";
import { promoteDefinitionLists } from "../src/lib/chat-definition-lists.ts";
test("consecutive label-colon paragraphs become a markdown list", () => {
const promoted = promoteDefinitionLists([
"行运焦点:",
"",
"月亮行运三分本命太阳(orb 0.29°):情绪与精力契合。",
"",
"天王星行运三分本命月亮(orb 0.75°):突发灵感可能冒出来。",
"",
"海王星行运对本命月亮(orb 0.87°):注意信息模糊。",
].join("\n"));
assert.match(promoted, /^- \*\*月亮行运三分本命太阳(orb 0\.29°)\*\*:情绪与精力契合。$/m);
assert.match(promoted, /^- \*\*天王星行运三分本命月亮(orb 0\.75°)\*\*:突发灵感可能冒出来。$/m);
assert.match(promoted, /行运焦点:/);
assert.equal(promoted.includes("- **行运焦点**"), false);
});
test("code fences and existing lists are left alone", () => {
const source = [
"```",
"标签:不要动",
"```",
"",
"- 已有列表:保持原样",
].join("\n");
assert.equal(promoteDefinitionLists(source), source);
});
test("spoken four-heading prose with a colon stays paragraphs", () => {
const prose = [
"你这半年的事业是「外刚内不承」:表面硬气是真的硬——你确实扛得住场面,底下却承不住。别人看见的是硬气,盘上撑着的是另一层。",
"",
"推的是火星:事情由你自己起动、自己顶上去。别人帮不上忙,你也没法把责任分出去,更别指望场面自己圆。",
"",
"所以别去应火星的「硬顶」,也别去应土星弱位的「拖」。去扮演太阳的「署名」:把事做成一件能签字的作品,而不是一场硬顶。",
].join("\n");
const result = promoteDefinitionLists(prose);
assert.equal(result, prose);
assert.equal(result.includes("- **"), false);
});