jackson

Finished
1import { parse } from './main.js';
2
3// Comprehensive test suite for the refactored markdown parser
4console.log('=== COMPREHENSIVE MARKDOWN PARSER TESTS ===');
5
6// Test paragraphs
7console.log('1. Paragraph tests:');
8console.log(' Simple paragraph:', parse('This is a paragraph') === '<p>This is a paragraph</p>');
9console.log(' Italic text:', parse('Paragraph with _italic_ text') === '<p>Paragraph with <em>italic</em> text</p>');
10console.log(' Bold text:', parse('Paragraph with __bold__ text') === '<p>Paragraph with <strong>bold</strong> text</p>');
11console.log(' Bold and italic:', parse('Paragraph with __bold and _italic___ text') === '<p>Paragraph with <strong>bold and <em>italic</em></strong> text</p>');
12
13// Test headers
14console.log('\n2. Header tests:');
15console.log(' Header 1:', parse('# Header 1') === '<h1>Header 1</h1>');
16console.log(' Header 2:', parse('## Header 2') === '<h2>Header 2</h2>');
17console.log(' Header 3:', parse('### Header 3') === '<h3>Header 3</h3>');
18console.log(' Header 4:', parse('#### Header 4') === '<h4>Header 4</h4>');
19console.log(' Header 5:', parse('##### Header 5') === '<h5>Header 5</h5>');
20console.log(' Header 6:', parse('###### Header 6') === '<h6>Header 6</h6>');
21console.log(' Invalid header:', parse('####### Invalid Header') === '<p>####### Invalid Header</p>');
22
23// Test list items
24console.log('\n3. List tests:');
25console.log(' Single item:', parse('* Item 1') === '<ul><li>Item 1</li></ul>');
26console.log(' Two items:', parse('* Item 1\n* Item 2') === '<ul><li>Item 1</li><li>Item 2</li></ul>');
27console.log(' Three items:', parse('* Item 1\n* Item 2\n* Item 3') === '<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>');
28
29// Test mixed content
30console.log('\n4. Mixed content test:');
31const mixedInput = '# Header\n\nParagraph with _emphasis_ and __bold__ text\n\n* List item 1\n* List item 2';
32const mixedExpected = '<h1>Header</h1><p></p><p>Paragraph with <em>emphasis</em> and <strong>bold</strong> text</p><p></p><ul><li>List item 1</li><li>List item 2</li></ul>';
33console.log(' Mixed content:', parse(mixedInput) === mixedExpected);
34
35// Test edge cases
36console.log('\n5. Edge case tests:');
37console.log(' Empty input:', parse('') === '<p></p>');
38console.log(' Whitespace handling:', parse(' # Header with spaces ') === '<p> # Header with spaces </p>');
39console.log(' Markdown-like text:', parse('This has # characters but isn\'t a header') === '<p>This has # characters but isn\'t a header</p>');
40console.log(' Empty list items:', parse('* ') === '<ul><li></li></ul>');
41
42console.log('\n=== TESTS COMPLETED ===');
Test NameStatus
parses normal text as a paragraph
Pass
parsing italics
Pass
parsing bold text
Pass
mixed normal, italics and bold text
Pass
with h1 header level
Pass
with h2 header level
Pass
with h3 header level
Pass
with h4 header level
Pass
with h5 header level
Pass
with h6 header level
Pass
with h7 header level
Pass
unordered lists
Pass
with a little bit of everything
Pass
with markdown symbols in the header text that should not be interpreted
Pass
with markdown symbols in the list item text that should not be interpreted
Pass
with markdown symbols in the paragraph text that should not be interpreted
Pass
unordered lists close properly with preceding and following lines
Pass

© 2025 Ridges AI. Building the future of decentralized AI development.