|
4 | 4 |
|
5 | 5 | namespace Hyde\Framework\Testing\Unit\Views; |
6 | 6 |
|
| 7 | +use Illuminate\Support\Str; |
7 | 8 | use Hyde\Facades\Filesystem; |
8 | 9 | use Hyde\Hyde; |
9 | 10 | use Hyde\Testing\TestCase; |
| 11 | +use Hyde\Pages\MarkdownPage; |
10 | 12 |
|
11 | 13 | /** |
12 | 14 | * @see resources/views/layouts/navigation.blade.php |
@@ -55,6 +57,49 @@ public function testComponentNotContains404HtmlLink() |
55 | 57 | $this->assertStringNotContainsString('href="404.html"', $this->render()); |
56 | 58 | } |
57 | 59 |
|
| 60 | + public function testNavigationMenuWithRootPages() |
| 61 | + { |
| 62 | + $foo = new MarkdownPage('foo'); |
| 63 | + $bar = new MarkdownPage('bar'); |
| 64 | + |
| 65 | + Hyde::routes()->add($foo->getRoute()); |
| 66 | + Hyde::routes()->add($bar->getRoute()); |
| 67 | + |
| 68 | + $this->mockRoute($foo->getRoute()); |
| 69 | + $this->mockPage($foo); |
| 70 | + |
| 71 | + $contents = $foo->compile(); |
| 72 | + |
| 73 | + $this->assertStringContainsString('<a href="foo.html" aria-current="page" class="', $contents); |
| 74 | + $this->assertStringContainsString('<a href="bar.html" class="', $contents); |
| 75 | + } |
| 76 | + |
| 77 | + public function testNavigationMenuWithDropdownPages() |
| 78 | + { |
| 79 | + config(['hyde.navigation.subdirectories' => 'dropdown']); |
| 80 | + |
| 81 | + $foo = new MarkdownPage('foo'); |
| 82 | + $bar = new MarkdownPage('foo/bar'); |
| 83 | + $baz = new MarkdownPage('foo/baz'); |
| 84 | + |
| 85 | + Hyde::routes()->add($foo->getRoute()); |
| 86 | + Hyde::routes()->add($bar->getRoute()); |
| 87 | + Hyde::routes()->add($baz->getRoute()); |
| 88 | + |
| 89 | + $this->mockRoute($foo->getRoute()); |
| 90 | + $this->mockPage($foo); |
| 91 | + |
| 92 | + $contents = $foo->compile(); |
| 93 | + |
| 94 | + $this->assertStringContainsString('dropdown-container', $contents); |
| 95 | + $this->assertStringContainsString('dropdown-button', $contents); |
| 96 | + |
| 97 | + $dropdown = Str::between($contents, '<ul class="dropdown-items', '</ul>'); |
| 98 | + |
| 99 | + $this->assertStringContainsString('<a href="foo/bar.html"', $dropdown); |
| 100 | + $this->assertStringContainsString('<a href="foo/baz.html"', $dropdown); |
| 101 | + } |
| 102 | + |
58 | 103 | public function testNavigationMenuLabelCanBeChangedInFrontMatter() |
59 | 104 | { |
60 | 105 | $this->file('_pages/foo.md', '--- |
|
0 commit comments