这是一个非常小而简单的问题。在网上看,我什么也找不到,但是我希望能够对我们的剑道图进行单元测试,尤其是seriesClick事件能够按预期工作。问题是我似乎找不到触发事件的方法。我试图通过jQuery定位图表系列并调用.click()。尝试这种方法并没有给我任何帮助,所以在失望之际,我尝试单击所有内容
$('*').each(function(){
$(this).click();
});
没有这种运气。这是chartOptions片段
$scope.chartOptions = {
//...
// On Click add the criteria to the serach bar.
seriesClick: function (series) {
console.log("seriesClick");
//Do stuff here
$scope.$apply();
}
}
};
当我在单元测试中尝试运行上述jQuery代码时,我没有控制台输出。这里是。
xit('should update the searchbar when a series item has been clicked', inject(function ($compile, $rootScope, $timeout) {
var scope = $rootScope.$new();
//Write out the directive
//We have a directive that will replace this tag with the kendo-chart directive
var ele = $compile('<chart></chart>')(scope);
angular.element(document.body).append(ele);
scope.$digest();
$timeout.flush(0);
scope = ele.isolateScope();
console.log('clicking everything');
$('*').each(function () {
$(this).click();
});
我已经向telerik论坛提交了相同的问题,希望能从“专家”那里得到一些建议,但是我得到的回复几乎没有SO的快。
编辑我确实在Telerik论坛上看到过这篇文章,希望我不需要做的是“当前不支持开箱即用”。
element.mousedown().mouseup() //Trigger events for Chrome, Firefox and IE9
.trigger(jQuery.Event("MSPointerDown", { originalEvent: {} })).trigger(jQuery.Event("MSPointerUp", { originalEvent: {} })) //Trigger event for IE10
.trigger(jQuery.Event("pointerdown", { originalEvent: {} })).trigger(jQuery.Event("pointerup", { originalEvent: {} })); //Trigger event for IE11
显然,它侦听mousedown()mouseup()事件。然后在看到它不适用于IE10和11之后,我需要使用另一种触发mousedown()/ mouseup()的方式
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句