Skip to content

Commit e05c63e

Browse files
committed
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.
1 parent 493b0fd commit e05c63e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/unit/event.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,6 +2843,24 @@ QUnit.test( "originalEvent property for Chrome, Safari, Fx & Edge of simulated e
28432843
jQuery( "#donor-input" ).trigger( "focus" );
28442844
} );
28452845

2846+
QUnit[ jQuery.fn.click ? "test" : "skip" ]( "Event aliases", function( assert ) {
2847+
2848+
// Explicitly skipping focus/blur events due to their flakiness
2849+
var $elem = jQuery( "<div />" ).appendTo( "#qunit-fixture" ),
2850+
aliases = ( "resize scroll click dblclick mousedown mouseup " +
2851+
"mousemove mouseover mouseout mouseenter mouseleave change " +
2852+
"select submit keydown keypress keyup contextmenu" ).split( " " );
2853+
assert.expect( aliases.length );
2854+
2855+
jQuery.each( aliases, function( i, name ) {
2856+
2857+
// e.g. $(elem).click(...).click();
2858+
$elem[ name ]( function( event ) {
2859+
assert.equal( event.type, name, "triggered " + name );
2860+
} )[ name ]().off( name );
2861+
} );
2862+
} );
2863+
28462864
// These tests are unreliable in Firefox
28472865
if ( !( /firefox/i.test( window.navigator.userAgent ) ) ) {
28482866
QUnit.test( "Check order of focusin/focusout events", function( assert ) {

0 commit comments

Comments
 (0)