Angular 2 testing directives with events bound to document
I ran into an issue today where I was writing a test for a directive I created. The directive has a HostListener
which binds to document:mouseup
and the tests were not able to trigger that particular event with the typical triggerEventHandler
function. There is currently a feature request to help with this issue. The workaround stated on that feature request wasn't very descriptive, so I had to figure out another way to call the bound event listener on my directive. Here's some code:
@Component({