diff options
author | Dave Methvin <dave.methvin@gmail.com> | 2015-11-04 13:27:39 -0500 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2015-11-05 14:14:36 -0500 |
commit | e05c63e17a037d550e7dde5d805ee5c4214ee44b (patch) | |
tree | e0f95781eee3d490be6bc0517d18005971ca50b4 | |
parent | 493b0fd7f51054345abe981270bd7839825f79dd (diff) | |
download | jquery-e05c63e17a037d550e7dde5d805ee5c4214ee44b.tar.gz jquery-e05c63e17a037d550e7dde5d805ee5c4214ee44b.zip |
Event: Add basic unit tests for event aliases
Fixes gh-2302
Closes gh-2687
At the moment it's not possible to run the full event unit tests without aliases
so this was just tested with a custom build by running this one test.
-rw-r--r-- | test/unit/event.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/unit/event.js b/test/unit/event.js index 26d972a5b..e82db243f 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2843,6 +2843,24 @@ QUnit.test( "originalEvent property for Chrome, Safari, Fx & Edge of simulated e jQuery( "#donor-input" ).trigger( "focus" ); } ); +QUnit[ jQuery.fn.click ? "test" : "skip" ]( "Event aliases", function( assert ) { + + // Explicitly skipping focus/blur events due to their flakiness + var $elem = jQuery( "<div />" ).appendTo( "#qunit-fixture" ), + aliases = ( "resize scroll click dblclick mousedown mouseup " + + "mousemove mouseover mouseout mouseenter mouseleave change " + + "select submit keydown keypress keyup contextmenu" ).split( " " ); + assert.expect( aliases.length ); + + jQuery.each( aliases, function( i, name ) { + + // e.g. $(elem).click(...).click(); + $elem[ name ]( function( event ) { + assert.equal( event.type, name, "triggered " + name ); + } )[ name ]().off( name ); + } ); +} ); + // These tests are unreliable in Firefox if ( !( /firefox/i.test( window.navigator.userAgent ) ) ) { QUnit.test( "Check order of focusin/focusout events", function( assert ) { |