這是JavaScript的/ jQuery的測試中燼拖n個墨滴: 我不知道爲什麼它沒有運行:如何在灰燼框架使用jQuery編寫測試用例
test('dragdrop', function(assert){
this.render(hbs`{{dragdrop}}`);
(function(export){
var datatransfermock = function(){};
datatransfermock.prototype.setdata = function(format,data){
this[format]= data;
};
datatransfermock.prototype.getdata = function(format){
if(this.hasownproperty(format)){
return this[format];
}else{
return null;
}
};
exports.datatransferMock=Datatransfermock;
})(window);
ember.run(function(){
var sourcedata = this.$('.draggable:eq(0)'),
targetdata = this.$('.draggable:eq(1)'),
datastartevent = $.event('dragstart'),
dropevent - $.event('drop');
dragstartevent.datatransfer = new datatransfermock();
sourcedata.trigger(dragstartevent);
dropevent.datatransfer = dragstartevent.datatransfer;
targetdata.trigger(dropevent);
sourcedata.trigger('dragend');
});
});
你試過了什麼? https://stackoverflow.com/help/how-to-ask – sheriffderek
我曾嘗試使用ember.run(function()){觸發事件(classname,'drag')和triggerevent(classname1,'drop')};在我的單元測試 –