Skip to content

Commit

Permalink
Merge pull request #24 from bretterer/property-wired-blur
Browse files Browse the repository at this point in the history
Add Blur to propertyWired assertions
  • Loading branch information
christophrumpel committed Oct 17, 2023
2 parents 547d86e + 4dc1f62 commit a73103e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/CustomLivewireAssertionsMixin.php
Expand Up @@ -15,7 +15,7 @@ public function assertPropertyWired(): Closure
{
return function (string $property) {
PHPUnit::assertMatchesRegularExpression(
'/wire:model(\.(live|(lazy|debounce)(\.\d+?(ms|s)|)))*=(?<q>"|\')'.$property.'(\k\'q\')/',
'/wire:model(\.(live|blur|(lazy|debounce)(\.\d+?(ms|s)|)))*=(?<q>"|\')'.$property.'(\k\'q\')/',
$this->html()
);

Expand All @@ -30,7 +30,7 @@ public function assertPropertyNotWired(): Closure
{
return function (string $property) {
PHPUnit::assertDoesNotMatchRegularExpression(
'/wire:model(\.(live|(lazy|debounce)(\.\d+?(ms|s)|)))*=(?<q>"|\')'.$property.'(\k\'q\')/',
'/wire:model(\.(live|blur|(lazy|debounce)(\.\d+?(ms|s)|)))*=(?<q>"|\')'.$property.'(\k\'q\')/',
$this->html()
);

Expand Down
2 changes: 2 additions & 0 deletions tests/AssertionsTest.php
Expand Up @@ -25,6 +25,7 @@ public function it_checks_if_livewire_property_is_wired_to_a_field(): void
{
Livewire::test(LivewireTestComponentA::class)
->assertPropertyWired('user')
->assertPropertyWired('blur')
->assertPropertyWired('lazy')
->assertPropertyWired('live')
->assertPropertyWired('debounce')
Expand All @@ -39,6 +40,7 @@ public function it_checks_if_livewire_property_is_not_wired_to_a_field(): void
{
Livewire::test(LivewireTestComponentA::class)
->assertPropertyNotWired('user_not_wired')
->assertPropertyNotWired('blur_not_wired')
->assertPropertyNotWired('lazy_not_wired')
->assertPropertyNotWired('live_not_wired')
->assertPropertyNotWired('debounce_not_wired')
Expand Down
1 change: 1 addition & 0 deletions tests/resources/views/livewire-test-component-a.php
@@ -1,5 +1,6 @@
<div>
<input type="text" wire:model="user" />
<input type="text" wire:model.blur="blur" />
<input type="text" wire:model.lazy="lazy" />
<input type="text" wire:model.live="live" />
<input type="text" wire:model.debounce="debounce" />
Expand Down

0 comments on commit a73103e

Please sign in to comment.