Skip to content

Commit

Permalink
adad assertDontSeeLivewire (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
devajmeireles authored Sep 1, 2023
1 parent d5963d2 commit aea9dc6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/VoltServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,15 @@ protected function registerTestingMacros(): void

return $this->assertSeeLivewire($component); // @phpstan-ignore-line
});

TestResponse::macro('assertDontSeeVolt', function ($component) {
Volt::ensureViewsAreCached();

if (FragmentMap::has($component)) {
$component = FragmentMap::get($component);
}

return $this->assertDontSeeLivewire($component); // @phpstan-ignore-line
});
}
}
20 changes: 20 additions & 0 deletions tests/Feature/FunctionalFolioTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Illuminate\Support\Facades\Route;
use Laravel\Folio\Folio;
use Livewire\Volt\Volt;
use PHPUnit\Framework\ExpectationFailedException;
use Tests\Fixtures\User;

beforeEach(function () {
Expand Down Expand Up @@ -140,6 +141,25 @@
->assertOk();
});

test('`assertDontSeeVolt` testing method', function () {
Folio::route(__DIR__.'/resources/views/functional-api-pages');

$this->get('/page-with-fragment')
->assertSeeVolt('fragment-component')
->assertDontSeeVolt('second-component')
->assertOk();
});

test('`assertDontSeeVolt` testing method can fail', function () {
$this->expectException(ExpectationFailedException::class);

Folio::route(__DIR__.'/resources/views/functional-api-pages');

$this->get('/page-with-fragment')
->assertDontSeeVolt('fragment-component')
->assertOk();
});

test('page with view content', function () {
Folio::route(__DIR__.'/resources/views/functional-api-pages');

Expand Down

0 comments on commit aea9dc6

Please sign in to comment.