Skip to content

Commit

Permalink
Expand feature testing
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 2, 2024
1 parent e67a640 commit 6fe5cb8
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion packages/framework/tests/Feature/MarkdownHeadingRendererTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,37 @@ public function testHeadingsWithCustomAttributes()
### Another Heading {data-test="value"}
MARKDOWN;

$html = (new MarkdownService($markdown, DocumentationPage::class))->parse();
$html = (new MarkdownService($markdown, MarkdownPage::class))->parse();

$this->assertStringContainsString('id="custom-id"', $html);
$this->assertStringContainsString('class="custom-class"', $html);
$this->assertStringContainsString('data-test="value"', $html);

$this->assertSame(<<<'HTML'
<h2 class="custom-class" id="custom-id">Heading</h2>
<h3 data-test="value">Another Heading</h3>

HTML, $html);
}

public function testHeadingsWithCustomAttributesAndPermalinks()
{
$markdown = <<<'MARKDOWN'
## Heading {.custom-class #custom-id}
### Another Heading {data-test="value"}
MARKDOWN;

$html = (new MarkdownService($markdown, DocumentationPage::class))->parse();

$this->assertStringContainsString('id="custom-id"', $html);
$this->assertStringContainsString('class="custom-class"', $html);
$this->assertStringContainsString('data-test="value"', $html);

$this->assertSame(<<<'HTML'
<h2 class="custom-class" id="custom-id">Heading<a id="heading" href="#heading" class="heading-permalink" title="Permalink"></a></h2>
<h3 data-test="value">Another Heading<a id="another-heading" href="#another-heading" class="heading-permalink" title="Permalink"></a></h3>

HTML, $html);
}

public function testPermalinkConfigurationLevels()
Expand All @@ -124,6 +150,16 @@ public function testPermalinkConfigurationLevels()
$this->assertStringContainsString('<h4>H4 Has Permalink<a', $html);
$this->assertStringNotContainsString('<h5>H5 No Permalink</h1><a', $html);
$this->assertStringNotContainsString('<h6>H6 No Permalink</h1><a', $html);

$this->assertSame(<<<'HTML'
<h1>H1 No Permalink</h1>
<h2>H2 Has Permalink<a id="h2-has-permalink" href="#h2-has-permalink" class="heading-permalink" title="Permalink"></a></h2>
<h3>H3 Has Permalink<a id="h3-has-permalink" href="#h3-has-permalink" class="heading-permalink" title="Permalink"></a></h3>
<h4>H4 Has Permalink<a id="h4-has-permalink" href="#h4-has-permalink" class="heading-permalink" title="Permalink"></a></h4>
<h5>H5 No Permalink</h5>
<h6>H6 No Permalink</h6>

HTML, $html);
}

public function testDisablingPermalinksGlobally()
Expand All @@ -147,6 +183,12 @@ public function testHeadingsWithSpecialCharacters()

$this->assertStringContainsString('Heading with &amp; special &lt; &gt; &quot;characters&quot;', $html);
$this->assertStringContainsString('Heading with émojis 🎉', $html);

$this->assertSame(<<<'HTML'
<h2>Heading with &amp; special &lt; &gt; &quot;characters&quot;<a id="heading-with-amp-special-lt-gt-quotcharactersquot" href="#heading-with-amp-special-lt-gt-quotcharactersquot" class="heading-permalink" title="Permalink"></a></h2>
<h3>Heading with émojis 🎉<a id="heading-with-emojis" href="#heading-with-emojis" class="heading-permalink" title="Permalink"></a></h3>

HTML, $html);
}

public function testCustomPageClassConfiguration()
Expand Down

0 comments on commit 6fe5cb8

Please sign in to comment.