From 3e2585de48a5baec886f3d93750ee48c3da81c6b Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 25 Feb 2024 11:14:39 +0000 Subject: [PATCH] Merge pull request #1589 from hydephp/improved-view-testing Improve and add more view tests https://github.com/hydephp/develop/commit/843f4613ef3c432c0ce06c60ec47aed87879b0c5 --- tests/Feature/Views/SidebarBrandViewTest.php | 71 ++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 tests/Feature/Views/SidebarBrandViewTest.php diff --git a/tests/Feature/Views/SidebarBrandViewTest.php b/tests/Feature/Views/SidebarBrandViewTest.php new file mode 100644 index 00000000..10b840bf --- /dev/null +++ b/tests/Feature/Views/SidebarBrandViewTest.php @@ -0,0 +1,71 @@ +test(view('hyde::components.docs.sidebar-brand')); + + $view->assertSee('HydePHP Docs'); + $view->assertSee('theme-toggle-button'); + $view->assertDontSee('href'); + } + + public function testSidebarBrandViewWithHomeRoute() + { + Hyde::routes()->addRoute((new DocumentationPage('index'))->getRoute()); + + $view = $this->test(view('hyde::components.docs.sidebar-brand')); + + $view->assertSee('HydePHP Docs'); + $view->assertSee('theme-toggle-button'); + $view->assertSeeHtml('HydePHP Docs', true); + } + + public function testSidebarBrandViewWithDefaultHeaderText() + { + config(['docs.sidebar' => []]); + + $view = $this->test(view('hyde::components.docs.sidebar-brand')); + + $view->assertSee('Documentation'); + $view->assertDontSee('HydePHP Docs'); + } + + public function testSidebarBrandViewWithDefaultHeaderTextAndHomeRoute() + { + Hyde::routes()->addRoute((new DocumentationPage('index'))->getRoute()); + + config(['docs.sidebar' => []]); + + $view = $this->test(view('hyde::components.docs.sidebar-brand')); + + $view->assertSee('Documentation'); + $view->assertSeeHtml('Documentation', true); + $view->assertDontSee('HydePHP Docs'); + } + + public function testSidebarBrandViewWithoutDarkmodeFeature() + { + $mock = $this->mock(HydeKernel::class)->makePartial(); + $mock->shouldReceive('hasFeature')->with('darkmode')->andReturn(false); + HydeKernel::setInstance($mock); + + $view = $this->test(view('hyde::components.docs.sidebar-brand')); + + $view->assertSee('HydePHP Docs'); + $view->assertDontSee('theme-toggle-button'); + } +}