我要对该代码进行单元测试
Plotly.newPlot(this.plotViewPort.nativeElement, this.data, this.layout);
this.plotViewPort.nativeElement.on('plotly_relayout', (eventdata) => {
this.onUserZoom(eventdata);
});
如何触发 tests文件
中的plotly_relayout
事件
到目前为止我的尝试
it('should plotly_relayout event to work as expected', () => {
component.droped({ dropData: STORES[0]});
fixture.detectChanges();
const elem = component.plotViewPort
var event = new CustomEvent('plotly_relayout', { test: true });
elem.nativeElement.dispatchEvent(event);
console.log(component.plotViewPort.nativeElement);
expect(component.onUserZoom).toHaveBeenCalled();
});