Skip to content

Method to dispatch events from event creator #529

@DaSchTour

Description

@DaSchTour

Description

Although it seams possible to add an event to dispatchMouseEvent this is only possible by redefinig the type of the event

Consider this code

const mouseEvent = createMouseEvent('click');
const onEventSpy = jest.spyOn(mouseEvent, 'stopPropagation');
spectator.dispatchMouseEvent('button', mouseEvent);
expect(onEventSpy).toHaveBeenCalled();

Currently you would have to add all other parameters to dispatchMouseEvent

Proposed solution

Create a dispatchEvent method to spectator, that allows dispatching an formaly created events.

OR

Change dispatchMouseEvent to allow adding a mouseEvent as second parameter instead of string.

Alternatives considered

None

Do you want to create a pull request?

Yes

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions