import test from 'node:test';
import assert from 'node:assert/strict';
import {
buildSubscribeWelcomeText,
buildWechatTextLink,
DEFAULT_PRODUCTION_BIND_URL,
DEFAULT_SUBSCRIBE_INTRO_URL,
} from './sync-replies.mjs';
test('buildWechatTextLink renders WeChat anchor without exposing raw url', () => {
assert.equal(
buildWechatTextLink(DEFAULT_PRODUCTION_BIND_URL, '点我绑定'),
`点我绑定`,
);
});
test('buildSubscribeWelcomeText uses clickable anchors instead of raw urls', () => {
const text = buildSubscribeWelcomeText({ bindUrl: DEFAULT_PRODUCTION_BIND_URL });
assert.match(text, /欢迎关注 TKMind 智趣/);
assert.match(text, /生成精美网页并给链接/);
assert.match(text, /📖 了解更多:/);
assert.match(
text,
/点击链接<\/a>/,
);
assert.match(text, /👉 先完成绑定再开始对话:/);
assert.match(
text,
/点我绑定<\/a>/,
);
assert.doesNotMatch(text, /\nhttps:\/\/m\.tkmind\.cn/);
assert.match(text, /帮我做一个读书笔记页面/);
});
test('buildSubscribeWelcomeText omits intro section when introUrl is empty', () => {
const text = buildSubscribeWelcomeText({
bindUrl: 'https://m.tkmind.cn/bind',
introUrl: '',
});
assert.doesNotMatch(text, /📖 了解更多:/);
assert.doesNotMatch(text, /tkmind-deep-intro\.html/);
});