Closed dalbo closed 7 months ago
Hey, nice idea.
What about being specific like assertMethodWiredToClick
and assertMethodWiredToChange
?
@nuernbergerA what do you think?
So my concern with making specific assertions like that is that you will end up with dozens of them. I want change
but someone else wants keyup
and someone else wants mouseover
etc. It would certainly work, but may become somewhat overwhelming with so many potential options.
Good point. Do you know how many there are? That might help to decide.
From the documentation it can be any browser event (and possibly any custom event too)
https://livewire.laravel.com/docs/actions#event-listeners
Event listeners
Livewire supports a variety of event listeners, allowing you to respond to various types of user interactions:
wire:click | Triggered when an element is clicked
wire:submit | Triggered when a form is submitted
wire:keydown | Triggered when a key is pressed down
wire:mouseenter | Triggered when the mouse enters an element
wire:* | Whatever text follows wire: will be used as the event name of the listener
Because the event name after wire: can be anything, Livewire supports any browser event you might need to listen for. For example, to listen for transitionend, you can use wire:transitionend.
Ok I see. Then lets keep the dedicated click method and add a generic method like you suggested. Would you want to work an a PR for that?
Sure, will see what I can do.
It would be great to be able to assert methods which are wired to actions other than
click
. I will often attach a method to achange
event on a select dropdown, as follows.Two thoughts on how this could be implemented
assertMethodWired
to look for any string afterwire:
, not justclick
.assertMethodWiredToAction('methodName', 'action')