christophrumpel / missing-livewire-assertions

Adding the missing Livewire assertions to your Laravel project
MIT License
136 stars 25 forks source link

assertPropertyWired and assertMethodWired only detect double quotation marks #10

Closed titantwentyone closed 2 years ago

titantwentyone commented 3 years ago

Where we have:

<input type='text' wire:model='property'/>
<button wire:click='method'>Do it!</button>

and test with:

Livewire::test(MyComponent::class)
    ->assertPropertyWired('property')
    ->assertMethodWired('method');

assertPropertyWired and assertMethodWired will both fail as it it is testing against double quotes rather than double quotes and single quotes.

Failed asserting that '<div wire:id="fjmdPc9adH8Od6DRxZl6">\n
          <input type='text' wire:model="property"/>\n    <--- fixed this to pass
          <button wire:click='method'>Do it!</button>\n
  </div>' matches PCRE pattern "/wire:click(\.(prevent))*="method(\s*\(.+\)\s*)?\s*"/".

I'll try and park some time and amend the regex for a PR.

christophrumpel commented 3 years ago

Hey, good point. PR welcome! If you don't find the time let me know and I will add it.