fireEvent
Fires a Lynx event at an element, which runs the handlers a device would, such as (bindtap). import { fireEvent, waitForUpdate } from '@blotch/angular-lynx-testing-library';
Usage
fireEvent(element, event)
Fires a Lynx event at element. There's one method per event: the Event reference lists them, and the binding each one runs.
The handler runs before fireEvent returns, so a spy or a signal you read directly already shows the change.
Angular renders the result in a change detection it schedules for after the current task. Await waitForUpdate() before checking the rendered output.
Arguments
For an event without a method, pass an event such as new Event('bindEvent:change'). A CustomEvent's detail arrives as $event.detail.
Bubbling
- Touch, mouse and key events bubble. They go from
elementup to the page, as on a device, so a tap on a row reaches its card's(click). - A
(catch*)handler stops them. So does one that calls$event.stopPropagation(). Either runs, then stops the event there. (capture-*)handlers run first, from the page down.- Other events stay put. Events such as
scrollandinputrun onlyelement's own handler.
eventMap
The events that fireEvent has a method for, keyed by event name. defaultInit.bubbles is true for the events that go up to the page.
