mirror of
https://github.com/amitwh/markdown-converter.git
synced 2026-08-03 02:11:07 +05:30
30 lines
976 B
TypeScript
30 lines
976 B
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { renderMarkdown } from '@/lib/markdown';
|
|
|
|
describe('renderMarkdown', () => {
|
|
it('renders headings', () => {
|
|
const html = renderMarkdown('# Hello');
|
|
expect(html).toContain('<h1>Hello</h1>');
|
|
});
|
|
|
|
it('renders bold and italic', () => {
|
|
const html = renderMarkdown('**bold** and *italic*');
|
|
expect(html).toContain('<strong>bold</strong>');
|
|
expect(html).toContain('<em>italic</em>');
|
|
});
|
|
|
|
it('renders code blocks with language class', () => {
|
|
const html = renderMarkdown('```js\nconst x = 1;\n```');
|
|
expect(html).toContain('language-js');
|
|
});
|
|
|
|
it('renders mermaid blocks with a placeholder', () => {
|
|
const html = renderMarkdown('```mermaid\ngraph TD\nA-->B\n```');
|
|
expect(html).toContain('data-mermaid-source=');
|
|
});
|
|
|
|
it('sanitizes dangerous HTML', () => {
|
|
const html = renderMarkdown('<script>alert(1)</script>');
|
|
expect(html).not.toContain('<script>');
|
|
});
|
|
}); |