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('
Titre
');
expect(result).toContain('gras');
expect(result).toContain('italique');
});
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('Lien');
});
it('should handle lists', () => {
const markdown = '- Item 1\n- Item 2\n- Item 3';
const result = parseMarkdown(markdown);
expect(result).toContain('');
expect(result).toContain('- Item 1
');
expect(result).toContain('- Item 2
');
expect(result).toContain('- Item 3
');
});
});
describe('renderMarkdown', () => {
it('should render markdown to HTML', () => {
const markdown = '**Texte en gras**';
const result = parseMarkdown(markdown);
expect(result).toContain('Texte en gras');
});
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()`');
});
});
});