Files
memind/mindspace-page-tag.test.mjs
T
john 722b18326f feat(mindspace): 0630004 空间 UI、聊天连接、微信分享与 Agent 能力
含 MindSpace 三列布局与统计修复、聊天加载态与连接降级、平台页脚标记与 og:site_name 微信卡片、勾选资料删除 Agent 接口及内部话术过滤。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 18:08:06 +08:00

30 lines
1.2 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import {
MINDSPACE_PAGE_TAG_ATTR,
MINDSPACE_PAGE_TAG_PLATFORM_BRAND,
ensurePlatformBrandPageTags,
normalizePlatformBrandHtml,
prepareHtmlPageBrandMarkers,
} from './mindspace-page-tag.mjs';
test('normalizePlatformBrandHtml rewrites tkmind.ai to tkmind.cn', () => {
const html = '<a href="mailto:contact@tkmind.ai">📧 contact@tkmind.ai</a>';
const result = normalizePlatformBrandHtml(html);
assert.match(result, /contact@tkmind\.cn/);
assert.doesNotMatch(result, /tkmind\.ai/i);
});
test('ensurePlatformBrandPageTags adds platform-brand marker to contact line', () => {
const html = '<footer><p>📧 contact@tkmind.ai</p></footer>';
const result = ensurePlatformBrandPageTags(html);
assert.match(result, new RegExp(`${MINDSPACE_PAGE_TAG_ATTR}="${MINDSPACE_PAGE_TAG_PLATFORM_BRAND}"`));
assert.match(result, /contact@tkmind\.cn/);
});
test('prepareHtmlPageBrandMarkers keeps existing marker', () => {
const html = `<p ${MINDSPACE_PAGE_TAG_ATTR}="${MINDSPACE_PAGE_TAG_PLATFORM_BRAND}">📧 contact@tkmind.cn</p>`;
const result = prepareHtmlPageBrandMarkers(html);
assert.equal(result.match(new RegExp(MINDSPACE_PAGE_TAG_ATTR, 'g'))?.length, 1);
});