Skip to content

Commit

Permalink
Fix: Add missing argument 'except' to function 'url' in state propert…
Browse files Browse the repository at this point in the history
…ies (#89)
  • Loading branch information
bekepr authored Jan 30, 2024
1 parent 37dc733 commit f565e39
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Options/StateOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ public function reactive(): static
/**
* Indicate the state should be tracked in the URL.
*/
public function url(?string $as = null, ?bool $history = null, ?bool $keep = null): static
public function url(?string $as = null, ?bool $history = null, ?bool $keep = null, ?string $except = null): static
{
return $this->attribute(Url::class, as: $as, history: $history, keep: $keep);
return $this->attribute(Url::class, as: $as, history: $history, keep: $keep, except: $except);
}
}
7 changes: 6 additions & 1 deletion tests/Feature/Compiler/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
state('searchOne')->url();
state('searchTwo')->url(as: 'search', history: true);
state('searchThree')->url(keep: true);
state('searchFour')->url(keep: true, except: '');

$code = Compiler::contextToString(CompileContext::instance());

expect($code)->toContain(<<<'PHP'
expect($code)->toContain(
<<<'PHP'
#[\Livewire\Attributes\Url()]
public $searchOne;
Expand All @@ -27,6 +29,9 @@
#[\Livewire\Attributes\Url(keep: true)]
public $searchThree;
#[\Livewire\Attributes\Url(keep: true, except: '')]
public $searchFour;
PHP
);
});
9 changes: 8 additions & 1 deletion tests/Feature/CompilerContext/UrlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
state(searchOne: 1)->url();
state(searchTwo: 2)->url(as: 'search', history: true);
state(searchThree: 3)->url(keep: true);
state(searchFour: 4)->url(keep: true, except: '');

expect($context->state)->toHaveKeys(['name', 'searchOne', 'searchTwo', 'searchThree'])
expect($context->state)->toHaveKeys(['name', 'searchOne', 'searchTwo', 'searchThree', 'searchFour'])
->sequence(
fn (Expectation $property) => $property->attributes->toBe([]),
fn (Expectation $property) => $property->attributes->toBe([
Expand All @@ -31,5 +32,11 @@
'keep' => true,
],
]),
fn (Expectation $property) => $property->attributes->toBe([
Url::class => [
'keep' => true,
'except' => '',
],
]),
);
});

0 comments on commit f565e39

Please sign in to comment.