Adam Shaw 9 лет назад
Родитель
Сommit
ca7654e2b2
1 измененных файлов с 12 добавлено и 0 удалено
  1. 12 0
      tests/lib/simulate.js

+ 12 - 0
tests/lib/simulate.js

@@ -50,6 +50,18 @@ $.simulate.prototype.simulateTouchEvent = function(elem, type, options) {
 	this.dispatchEvent(elem, type, event, options);
 };
 
+$.simulateMouseClick = function(elem) {
+	var $elem = $(elem);
+	var clientCoords = {
+		clientX: $elem.offset().left + $elem.outerWidth() / 2,
+		clientY: $elem.offset().top + $elem.outerHeight() / 2
+	};
+	$elem.simulate('mousemove', clientCoords);
+	$elem.simulate('mousedown', clientCoords);
+	$elem.simulate('mouseup', clientCoords);
+	$elem.simulate('click', clientCoords);
+};
+
 $.simulateTouchClick = function(elem) {
 	var $elem = $(elem);
 	var clientCoords = {