Skip to content

Commit

Permalink
Adds more markdown tests
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed Jan 15, 2024
1 parent 6fa6be8 commit 387541e
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions tests/Parse/MarkdownTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<?php

use October\Rain\Parse\Markdown;
use October\Rain\Events\FakeDispatcher;
use October\Rain\Events\Dispatcher;

/**
* MarkdownTest
*/
class MarkdownTest extends TestCase
{
public function setUp(): void
{
parent::setUp();

Event::swap(new FakeDispatcher(new Dispatcher));
}

/**
* testParseIndent
*/
Expand Down Expand Up @@ -67,4 +76,79 @@ public function testParseHtml()
$normal = $parser->parse($text);
$this->assertEquals("<div><p>Foo</p><p>Bar</p></div>", $normal);
}

public function testParseNonHtml()
{
$parser = new Markdown;

$text = <<<TEXT
<table
some other text
## hello
TEXT;

$expected = '<p>&lt;table</p>
<p>some other text</p>
<h2>hello</h2>';

$normal = $parser->parse($text);

// Only accepting one node per line
$this->assertEquals($expected, $normal);
}

public function testParseMultilineHtml()
{
$parser = new Markdown;

$text = <<<HTML
<div>
<table width="100%"
align="center"
border="0"
cellpadding="0"
cellspacing="0"
style="background: red; min-height: 500px;">
<thead>
<tr>
<th>Test</th>
<th>123</th>
</tr>
</thead>
<tbody>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
</tr>
</tbody>
</table>
</div>
HTML;

$expected = <<<HTML
<div>
<table width="100%" align="center" border="0" cellpadding="0" cellspacing="0" style="background: red; min-height: 500px;">
<thead>
<tr>
<th>Test</th>
<th>123</th>
</tr>
</thead>
<tbody>
<tr>
<td>Lorem</td>
<td>Ipsum</td>
</tr>
</tbody>
</table>
</div>
HTML;

$normal = $parser->parse($text);

$this->assertEquals($expected, $normal);
}
}

0 comments on commit 387541e

Please sign in to comment.