In a component, I have a function I need to write a test for.
toggleDropdown($event: MouseEvent): void {
$event.preventDefault();
$event.stopPropagation();
this.status.isopen = !this.status.isopen;
}
How can I "stub" the $event or more precisely MouseEvent (for click case for example) and test the two methods preventDefault() and stopPropagation() have been called properly?
And how to trigger this method including a proper $event?
I struggle defining a proper test case for this method. I tried to spyOn $event but it doesn't work properly as cannot find name $event