-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathHeadingRendererTest.php
More file actions
60 lines (44 loc) · 1.64 KB
/
HeadingRendererTest.php
File metadata and controls
60 lines (44 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace Tests\Feature;
use App\Support\CommonMark\CommonMark;
use Tests\TestCase;
class HeadingRendererTest extends TestCase
{
public function test_heading_hash_appears_after_text(): void
{
$html = CommonMark::convertToHtml('## My Heading');
$this->assertStringContainsString('My Heading<a', $html);
$this->assertStringNotContainsString('#</span></a>My Heading', $html);
}
public function test_heading_anchor_has_correct_class(): void
{
$html = CommonMark::convertToHtml('## Test Heading');
$this->assertStringContainsString('heading-anchor', $html);
$this->assertStringContainsString('ml-2', $html);
}
public function test_heading_has_id_attribute(): void
{
$html = CommonMark::convertToHtml('## My Section');
$this->assertStringContainsString('id="my-section"', $html);
}
public function test_heading_anchor_links_to_id(): void
{
$html = CommonMark::convertToHtml('## My Section');
$this->assertStringContainsString('href="#my-section"', $html);
}
public function test_h1_gets_anchor(): void
{
$html = CommonMark::convertToHtml('# Title');
$this->assertStringContainsString('heading-anchor', $html);
}
public function test_h3_gets_anchor(): void
{
$html = CommonMark::convertToHtml('### Sub Section');
$this->assertStringContainsString('heading-anchor', $html);
}
public function test_h4_does_not_get_anchor(): void
{
$html = CommonMark::convertToHtml('#### Deep Heading');
$this->assertStringNotContainsString('heading-anchor', $html);
}
}