68 lines
2.1 KiB
TypeScript
68 lines
2.1 KiB
TypeScript
import { parseMarkdown } from '../../lib/markdown';
|
|
|
|
describe('Markdown Module', () => {
|
|
describe('parseMarkdown', () => {
|
|
it('should parse basic markdown', () => {
|
|
const markdown = '# Titre\n\nContenu **gras** et *italique*.';
|
|
const result = parseMarkdown(markdown);
|
|
|
|
expect(result).toContain('<h1>Titre</h1>');
|
|
expect(result).toContain('<strong>gras</strong>');
|
|
expect(result).toContain('<em>italique</em>');
|
|
});
|
|
|
|
it('should handle empty string', () => {
|
|
const result = parseMarkdown('');
|
|
expect(result).toBe('');
|
|
});
|
|
|
|
it('should handle null/undefined', () => {
|
|
expect(parseMarkdown(null as any)).toBe('');
|
|
expect(parseMarkdown(undefined as any)).toBe('');
|
|
});
|
|
|
|
it('should handle links', () => {
|
|
const markdown = '[Lien](https://example.com)';
|
|
const result = parseMarkdown(markdown);
|
|
|
|
expect(result).toContain('<a href="https://example.com"');
|
|
expect(result).toContain('>Lien</a>');
|
|
});
|
|
|
|
it('should handle lists', () => {
|
|
const markdown = '- Item 1\n- Item 2\n- Item 3';
|
|
const result = parseMarkdown(markdown);
|
|
|
|
expect(result).toContain('<ul>');
|
|
expect(result).toContain('<li>Item 1</li>');
|
|
expect(result).toContain('<li>Item 2</li>');
|
|
expect(result).toContain('<li>Item 3</li>');
|
|
});
|
|
});
|
|
|
|
describe('renderMarkdown', () => {
|
|
it('should render markdown to HTML', () => {
|
|
const markdown = '**Texte en gras**';
|
|
const result = parseMarkdown(markdown);
|
|
|
|
expect(result).toContain('<strong>Texte en gras</strong>');
|
|
});
|
|
|
|
it('should handle code blocks', () => {
|
|
const markdown = '```javascript\nconsole.log("test");\n```';
|
|
const result = parseMarkdown(markdown);
|
|
|
|
expect(result).toContain('```javascript');
|
|
expect(result).toContain('console.log("test");');
|
|
expect(result).toContain('```');
|
|
});
|
|
|
|
it('should handle inline code', () => {
|
|
const markdown = 'Utilisez `console.log()` pour afficher.';
|
|
const result = parseMarkdown(markdown);
|
|
|
|
expect(result).toContain('`console.log()`');
|
|
});
|
|
});
|
|
});
|