Skip to content

Commit

Permalink
Fixed test to set e.which = 1
Browse files Browse the repository at this point in the history
  • Loading branch information
anovi committed Jun 28, 2014
1 parent f8d00ec commit 621c698
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
11 changes: 8 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
elem = box.find('li:eq(3)'),
secElem = box.find('li:eq(5)'),
e = $.Event( "mousedown" );
e.which = 1;
e.metaKey = true;

elem.triggerClick();
Expand All @@ -153,6 +154,7 @@

elem.triggerClick();
e = $.Event( "mousedown" );
e.which = 1;
e.metaKey = true;
elem.trigger( e );
assert
Expand All @@ -167,6 +169,7 @@
midElem = box.find('li:eq(4)'),
secElem = box.find('li:eq(5)'),
e = $.Event( "mousedown" );
e.which = 1;
e.shiftKey = true;

elem.triggerClick();
Expand Down Expand Up @@ -200,15 +203,15 @@

el(3).triggerClick();
el(5).shiftMousedown();
el(4).trigger('mousedown');
el(4).triggerMousedown();
assert.selectedFocus( el(5) );
assert.selectedCount(3);
});

test( 'Mouseup mouseMode', 6, function() {
var el = elems();
el(3).trigger('mouseup');
el(5).trigger('mousedown');
el(3).triggerMouseup();
el(5).triggerMousedown();
assert.selectedFocus( el(3) );

el(5).triggerMouseup('shift');
Expand Down Expand Up @@ -247,6 +250,7 @@
midElem = box.find('li:eq(4)'),
secElem = box.find('li:eq(5)'),
e = $.Event( "mousedown" );
e.which = 1;
e.shiftKey = true;

elem.triggerClick();
Expand Down Expand Up @@ -712,6 +716,7 @@
}
});
var e = $.Event( "mousedown" );
e.which = 1;
e.shiftKey = true;
sec.trigger( e );

Expand Down
10 changes: 7 additions & 3 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,26 @@

$.fn.triggerMousedown = function(mode) {
var e = $.Event( "mousedown" );
e.which = 1;
if (mode === 'meta' || mode === 'ctrl') { e.metaKey = true; } else if (mode === 'shift') { e.shiftKey = true; }
this.trigger( e );
return this;
};

$.fn.triggerMouseup = function(mode) {
var e = $.Event( "mouseup" );
e.which = 1;
if (mode === 'meta' || mode === 'ctrl') { e.metaKey = true; } else if (mode === 'shift') { e.shiftKey = true; }
this.trigger( e );
return this;
};

jQuery.fn.triggerClick = function() {
this.trigger('mousedown');
this.trigger('mouseup');
this.trigger('click');
this.triggerMousedown();
this.triggerMouseup();
var e = $.Event( "click" );
e.which = 1;
this.trigger( e );
return this;
};

Expand Down

0 comments on commit 621c698

Please sign in to comment.