We have a drop-down component that has its dropdown collapsed on any outside click. This is implemented as:
@HostListener('document:click', ['$event'])
public documentClick(event) {
if (this.dropdownIsOpen && !event.clickedFromMe) {
this.dropdownIsOpen = false;
}
}
How can this code be tested? When using TestBed.createComponent, only the component seems to be created, and it is not inside any document, so how can I simulate a click outside of that component?
Aucun commentaire:
Enregistrer un commentaire