58 lines
2.1 KiB
JavaScript
58 lines
2.1 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
buildPlazaDiscoveryLines,
|
|
buildSubscribeWelcomeText,
|
|
buildWechatTextLink,
|
|
DEFAULT_PRODUCTION_BIND_URL,
|
|
DEFAULT_SUBSCRIBE_PLAZA_PICKS,
|
|
DEFAULT_SUBSCRIBE_WELCOME_EXAMPLES,
|
|
} from './sync-replies.mjs';
|
|
|
|
test('buildWechatTextLink renders WeChat anchor without exposing raw url', () => {
|
|
assert.equal(
|
|
buildWechatTextLink(DEFAULT_PRODUCTION_BIND_URL, '点我绑定'),
|
|
`<a href="${DEFAULT_PRODUCTION_BIND_URL}">点我绑定</a>`,
|
|
);
|
|
});
|
|
|
|
test('buildSubscribeWelcomeText asks for a page and a shareable link', () => {
|
|
const text = buildSubscribeWelcomeText({ bindUrl: DEFAULT_PRODUCTION_BIND_URL });
|
|
|
|
assert.match(text, /欢迎关注 tkmind 智趣/);
|
|
assert.match(text, /把想法和资料,变成可以分享的页面。/);
|
|
for (const prompt of ['咖啡店介绍', '周末徒步活动邀请', '把以下资料整理成个人介绍']) {
|
|
assert.ok(text.includes(`「生成页面:${prompt}」`));
|
|
}
|
|
assert.match(text, /✨ 案例查看:/);
|
|
for (const example of DEFAULT_SUBSCRIBE_WELCOME_EXAMPLES) {
|
|
assert.ok(text.includes(`<a href="${example.url}">${example.label}</a>`));
|
|
}
|
|
assert.match(
|
|
text,
|
|
/<a href="[^" ]*auth\/wechat\/authorize\?intent=login">点我绑定,开始制作<\/a>/,
|
|
);
|
|
assert.doesNotMatch(text, /\nhttps:\/\/m\.tkmind\.cn/);
|
|
assert.doesNotMatch(text, /每日推送订阅/);
|
|
assert.doesNotMatch(text, /M发现/);
|
|
assert.doesNotMatch(text, /问答、写作、翻译/);
|
|
});
|
|
|
|
test('buildPlazaDiscoveryLines renders curated plaza category links', () => {
|
|
const lines = buildPlazaDiscoveryLines();
|
|
const text = lines.join('\n');
|
|
assert.match(text, /M发现/);
|
|
for (const pick of DEFAULT_SUBSCRIBE_PLAZA_PICKS) {
|
|
assert.ok(text.includes(pick.label));
|
|
assert.ok(text.includes(`<a href="${pick.url}">${pick.label}</a>`));
|
|
}
|
|
});
|
|
|
|
test('buildSubscribeWelcomeText omits the bind line when bindUrl is empty', () => {
|
|
const text = buildSubscribeWelcomeText({ bindUrl: '' });
|
|
|
|
assert.match(text, /生成页面/);
|
|
assert.doesNotMatch(text, /点我绑定/);
|
|
});
|