Answer the question
In order to leave comments, you need to log in
How to trigger ctrl+enter key combination in js?
It is necessary to call the combination of keys control + inter for the test in karma.
Tried through
angular.element(document.querySelector('main > div')).trigger({type: 'keydown', which: 13}, {type: 'keydown', which: 17});
Answer the question
In order to leave comments, you need to log in
Why are you testing UI in Karma? Test controllers, their public functions and possibly private ones
var myApp = angular.module('myApp', []);
myApp.controller('Ctrl', function($scope) {
$scope.keyBuffer = [];
function arrays_equal(a,b) { return !(a<b || b<a); }
$scope.down = function(e) {
$scope.keyBuffer.push(e.keyCode);
var upUp = [38, 38, 40, 40, 37, 39, 37, 39, 66, 65];
if (arrays_equal(upUp, $scope.keyBuffer)) {
alert('thats it!');
}
};
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question