I encountered an issue with my mapbox popup while using jasmine and attempting to write a unit test for it.
Here is the function in question:
selectCluster(event: MouseEvent, feature: any) {
event.stopPropagation();
this.selectedCluster = {geometry: feature.geometry, properties: feature.properties};
}
Below is the corresponding template code:
<ng-template mglClusterPoint let-feature>
<div class="marker-cluster" (click)="selectCluster($event, feature)">
<fa-icon [icon]="faVideo" [styles]="{'stroke': 'black', 'color': 'black'}" size="lg" class="pr-2"></fa-icon>
<fa-icon [icon]="faWifi" [styles]="{'stroke': 'black', 'color': 'black'}" size="lg" class="pr-2"></fa-icon>
</div>
</ng-template>
My attempted unit test script is as follows:
fit('Should prevent popup from closing after being triggered', () => {
const ev = new Event('MouseEvent');
spyOn(ev, 'stopPropagation');
expect(ev.stopPropagation).toHaveBeenCalled();
});
However, I am encountering the following error message:
Expected spy stopPropagation to have been called.
Can anyone provide guidance on what changes need to be made to resolve this issue?
Thank you