Files
crm-ai/bridge/test/markdown.test.js
T
2026-10-23 10:35:28 +08:00

21 lines
829 B
JavaScript
Raw Permalink 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.
'use strict';
const test = require('node:test');
const assert = require('node:assert/strict');
const { markdownToHtml } = require('../src/markdown');
test('markdown: bold + link + list', () => {
const html = markdownToHtml('这里有一些 **戒指**:\n- [Rings](https://www.yehwang.com/jewelry/rings)\n- Plain\n\n谢谢');
assert.match(html, /<strong>戒指<\/strong>/);
assert.match(html, /<a href="https:\/\/www\.yehwang\.com\/jewelry\/rings"[^>]*>Rings<\/a>/);
assert.match(html, /<ul><li>/);
assert.match(html, /<p>谢谢<\/p>/);
assert.doesNotMatch(html, /\[Rings\]/);
});
test('markdown: escapes html and autolinks bare urls', () => {
const html = markdownToHtml('<script>x</script> https://a.test/x');
assert.match(html, /&lt;script&gt;/);
assert.match(html, /<a href="https:\/\/a\.test\/x"/);
});