我正在尝试测试我的ember应用程序。在我的路线上定义了快捷方式,一切正常。 但我不知道如何使用qunit测试这些场景?
App.BaseRoute = Ember.Route.extend({
shortcuts: {
'alt+a': 'gotoArticles',
'alt+p': 'gotoPhotos',
'alt+t': 'gotoTests'
},
actions: {
gotoArticles: function() {
console.log('alt + a was pressed, --> articles');
this.get('controller').transitionToRoute('articles');
},
gotoPhotos: function() {
console.log('alt + p was pressed --> photos');
this.get('controller').transitionToRoute('photos');
},
gotoTests: function() {
console.log('alt + t was pressed --> tests');
this.get('controller').transitionToRoute('testability');
}
}
});
问题是如何使用qunit测试已定义的快捷方式?
答案 0 :(得分:0)
您需要进行集成测试,在其中插入由BaseRoute
支持的视图,然后您可以在元素上触发事件。
var e = jQuery.Event("keydown");
e.which = 50; // # Some key code value
$("myelementintheview").trigger(e);