import { describe, it, expect } from 'vitest'; import { renderMarkdown, stripMarkdown } from './markdown.js'; describe('renderMarkdown', () => { it('should render bold text', () => { const html = renderMarkdown('**bold**'); expect(html).toContain('bold'); }); it('should render italic text', () => { const html = renderMarkdown('*italic*'); expect(html).toContain('italic'); }); it('should render headings', () => { const html = renderMarkdown('# Heading 1'); expect(html).toContain('
');
expect(html).toContain('const x = 1;');
});
it('should syntax-highlight a fenced block that names its language', () => {
const html = renderMarkdown('```ts\nconst x: number = 1;\n```');
expect(html).toContain('');
expect(html).toContain('const');
expect(html).toContain('1');
});
it('should leave an unlabelled fence as plain text rather than guessing a language', () => {
const html = renderMarkdown('```\nSELECT * FROM users;\n```');
expect(html).toContain('SELECT * FROM users;');
expect(html).not.toContain('hljs-');
});
it('should leave a fence with an unknown language as plain text but keep its label', () => {
const html = renderMarkdown('```brainfuck\n+++\n```');
expect(html).toContain('+++');
expect(html).not.toContain('hljs-');
});
it('should keep code in a highlighted fence escaped', () => {
const html = renderMarkdown('```html\n\n```');
expect(html).not.toContain('
');
expect(html).not.toContain('