diff --git a/tests/Prime/Response/Presenter/HtmlPresenterTest.php b/tests/Prime/Response/Presenter/HtmlPresenterTest.php index 422daab2..66b57e21 100644 --- a/tests/Prime/Response/Presenter/HtmlPresenterTest.php +++ b/tests/Prime/Response/Presenter/HtmlPresenterTest.php @@ -12,6 +12,7 @@ use Flasher\Prime\Notification\Notification; use Flasher\Prime\Response\Presenter\HtmlPresenter; use Flasher\Prime\Response\Response; use Flasher\Tests\Prime\TestCase; +use Livewire\LivewireManager; class HtmlPresenterTest extends TestCase { @@ -34,6 +35,8 @@ class HtmlPresenterTest extends TestCase $notification->setType('warning'); $envelopes[] = new Envelope($notification); + $livewireListener = $this->getLivewireListenerScript(); + $response = << (function() { @@ -88,6 +91,8 @@ class HtmlPresenterTest extends TestCase document.addEventListener('flasher:render', function (event) { render(event.detail); }); + + {$livewireListener} } if (window.hasOwnProperty('flasher') || !rootScript || document.querySelector('script[src="' + rootScript + '"]')) { @@ -136,4 +141,25 @@ JAVASCRIPT; $this->assertEquals($response, $presenter->render(new Response($envelopes, array('envelopes_only' => true)))); } + + /** + * Generate the script for Livewire event handling. + * + * @return string + */ + private function getLivewireListenerScript() + { + if (!class_exists(LivewireManager::class)) { + return ''; + } + + return <<add($envelopes); $responseManager = new ResponseManager(null, $storageManager); + $livewireListener = $this->getLivewireListenerScript(); $response = << @@ -101,6 +103,8 @@ class ResponseManagerTest extends TestCase document.addEventListener('flasher:render', function (event) { render(event.detail); }); + + {$livewireListener} } if (window.hasOwnProperty('flasher') || !rootScript || document.querySelector('script[src="' + rootScript + '"]')) { @@ -132,4 +136,25 @@ JAVASCRIPT; $responseManager = new ResponseManager(); $responseManager->render(array(), 'xml'); } + + /** + * Generate the script for Livewire event handling. + * + * @return string + */ + private function getLivewireListenerScript() + { + if (!class_exists(LivewireManager::class)) { + return ''; + } + + return <<