Skip to content

Commit 8e2ae1d

Browse files
add tests
Co-authored-by: promptless[bot] <promptless[bot]@users.noreply.github.com>
1 parent 19d5432 commit 8e2ae1d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import test from 'node:test';
2+
import assert from 'node:assert/strict';
3+
4+
import {transformContent} from '../transform.mjs';
5+
6+
const stripFrontmatter = (content) => content.replace(/^---[\s\S]*?---\n\n/, '');
7+
8+
test('compare callout preserves inline markup', () => {
9+
const input = `# Title\n\n<p><span class="compare-better">Better —</span> Keep <code>foo</code> and <a href="https://example.com">link</a>.</p>`;
10+
const output = stripFrontmatter(transformContent(input));
11+
12+
assert.ok(output.includes('<Callout type="success" title="Better">'));
13+
assert.ok(output.includes('`foo`'));
14+
assert.ok(output.includes('[link](https://example.com)'));
15+
assert.ok(output.includes('</Callout>'));
16+
});
17+
18+
test('compare list items retain trailing content', () => {
19+
const input = `# Title\n\n<ul><li><span class="compare-worse">Worse</span> <em>still works</em></li></ul>`;
20+
const output = stripFrontmatter(transformContent(input));
21+
22+
assert.ok(output.includes('- ⚠️ Worse: '));
23+
assert.ok(output.includes('*still works*'));
24+
});
25+
26+
test('braces are readable and escaped for MDX', () => {
27+
const input = '# Title\n\nExample {\'cpu\': \'ppc\'}';
28+
const output = stripFrontmatter(transformContent(input));
29+
30+
assert.ok(output.includes("Example \\{'cpu': 'ppc'\\}"));
31+
});

0 commit comments

Comments
 (0)