"use strict";

const {
  markdownParser
} = require('../markdownLoader'); // Replace './your-file' with the correct file path


describe('markdownParser', () => {
  test('For {}(braces) case', () => {
    const source = `
    /* MD:START
    # {Hi, This is Test Case :)}
    MD:END */
    `;
    const expectedOutput = `
    <><div class="markDown"><h1>&#123;Hi, This is Test Case :)&#125;</h1>
</div></>
    `;
    expect(markdownParser(source)).toEqual(expectedOutput);
  });
  test('For $ (dollor) case', () => {
    const source = `
    /* MD:START
    # $Hi, This is Test Case :)
    MD:END */
    `;
    const expectedOutput = `
    <><div class="markDown"><h1>&#36;Hi, This is Test Case :)</h1>
</div></>
    `;
    expect(markdownParser(source)).toEqual(expectedOutput);
  });
  test('For All kind of Tag Cases', () => {
    const source = `
    /* MD:START
    # Markdown File with Variety of Data

    ## Text
    
    This is a paragraph of text.
    
    ## Headings
    
    ### Heading 1
    
    ### Heading 2
    
    #### Heading 2.1
    
    #### Heading 2.2
    
    ## Lists
    
    ### Unordered List
    
    - Item 1
    - Item 2
    - Item 3
    
    ### Ordered List
    
    1. First item
    2. Second item
    3. Third item
    
    ## Links
    
    Here's a link to [OpenAI's website](https://openai.com).
    
    ## Images
    
    ![Markdown Logo](https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg)
    
    ## Tables
    
    | Name  | Age | Gender |
    |-------|-----|--------|
    | John  | 25  | Male   |
    | Sarah | 30  | Female |
    | Mark  | 35  | Male   |
    
    MD:END */
    `;
    const expectedOutput = `
    <><div class="markDown"><h1>Markdown File with Variety of Data</h1>
<h2>Text</h2>
<p>This is a paragraph of text.</p>
<h2>Headings</h2>
<h3>Heading 1</h3>
<h3>Heading 2</h3>
<h4>Heading 2.1</h4>
<h4>Heading 2.2</h4>
<h2>Lists</h2>
<h3>Unordered List</h3>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<h3>Ordered List</h3>
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
<h2>Links</h2>
<p>Here's a link to <a href="https://openai.com">OpenAI's website</a>.</p>
<h2>Images</h2>
<p><img src="https://upload.wikimedia.org/wikipedia/commons/4/48/Markdown-mark.svg" alt="Markdown Logo"/></p>
<h2>Tables</h2>
<table>
<thead>
<tr>
<th>Name</th>
<th>Age</th>
<th>Gender</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>25</td>
<td>Male</td>
</tr>
<tr>
<td>Sarah</td>
<td>30</td>
<td>Female</td>
</tr>
<tr>
<td>Mark</td>
<td>35</td>
<td>Male</td>
</tr>
</tbody>
</table>
</div></>
    `;
    expect(markdownParser(source)).toEqual(expectedOutput);
  });
  test('For Source null case', () => {
    expect(markdownParser(null)).toEqual('');
    expect(markdownParser('')).toEqual('');
  });
});