1 回答
TA贡献1784条经验 获得超2个赞
.marker-cluster当您尝试单击它时,它不在页面上,我没有看到您的完整 html,但我会假设它与*ngIf="selectedCluster"真实相关。
fit('Should set selectedCluster when clicked', async(() => {
// spy on and calling through doesn't actually call the function
// it makes it so we can determine if the function was called
// and everytime the function was called, call the actual function
// and not a null function
spyOn(component, 'selectCluster').and.callThrough();
// calling the function will should make selectedCluster true
component.selectCluster({ stopPropagation: () => null } as MouseEvent, {}); // send your own inputs
fixture.detectChanges();
fixture.debugElement.query(By.css('.marker-cluster')).nativeElement.click();
fixture.whenStable().then(() => {
expect(component.selectCluster).toHaveBeenCalled();
});
}));
添加回答
举报