需要介绍在可点击事件上执行的代码,即onEventPieClicked()
单元测试用例:
it('should call onEventPieClicked function with plotly click event', function() {
spyOn(window, 'onEventPieClicked');
$('#pieChartbyMachibeType').trigger('plotly_click');
expect(window.onEventPieClicked).toHaveBeenCalled();
});
控制器代码:
$('#pieChartbyMachibeType').on('plotly_click', function (data) {
onEventPieClicked(data);
});
它必须调用onEventPieClicked()函数,但从未调用过。