From 2cb8ebadcb77da1c1a12c07bc5274fd456bf3b01 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Fri, 6 Nov 2015 09:59:14 -0500 Subject: [PATCH] Event: Make event aliases optional in unit tests --- test/data/event/focusElem.html | 2 +- test/unit/event.js | 85 ++++++++++++++++------------------ 2 files changed, 42 insertions(+), 45 deletions(-) diff --git a/test/data/event/focusElem.html b/test/data/event/focusElem.html index 10726b4ff..a9a976518 100644 --- a/test/data/event/focusElem.html +++ b/test/data/event/focusElem.html @@ -9,7 +9,7 @@ diff --git a/test/unit/event.js b/test/unit/event.js index e82db243f..619307567 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -900,49 +900,6 @@ QUnit.test( "mouseenter, mouseleave don't catch exceptions", function( assert ) } } ); -if ( jQuery.fn.click ) { - - QUnit.test( "trigger() shortcuts", function( assert ) { - assert.expect( 5 ); - - var counter, clickCounter, - elem = jQuery( "
  • Change location
  • " ).prependTo( "#firstUL" ); - elem.find( "a" ).on( "click", function() { - var close = jQuery( "spanx", this ); // same with jQuery(this).find("span"); - assert.equal( close.length, 0, "Context element does not exist, length must be zero" ); - assert.ok( !close[ 0 ], "Context element does not exist, direct access to element must return undefined" ); - return false; - } ).click(); - - // manually clean up detached elements - elem.remove(); - - jQuery( "#check1" ).click( function() { - assert.ok( true, "click event handler for checkbox gets fired twice, see #815" ); - } ).click(); - - counter = 0; - jQuery( "#firstp" )[ 0 ].onclick = function() { - counter++; - }; - jQuery( "#firstp" ).click(); - assert.equal( counter, 1, "Check that click, triggers onclick event handler also" ); - - clickCounter = 0; - jQuery( "#simon1" )[ 0 ].onclick = function() { - clickCounter++; - }; - jQuery( "#simon1" ).click(); - assert.equal( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" ); - - // test that special handlers do not blow up with VML elements (#7071) - jQuery( "" ).appendTo( "head" ); - jQuery( " " ).appendTo( "#form" ); - jQuery( "#oval" ).click().keydown(); - } ); - -} - QUnit.test( "trigger() bubbling", function( assert ) { assert.expect( 18 ); @@ -2778,7 +2735,7 @@ QUnit.test( "preventDefault() on focusin does not throw exception", function( as "Preventing default on focusin throws no exception" ); done(); - } ).focus(); + } ).trigger( "focus" ); } ); QUnit.test( "Donor event interference", function( assert ) { @@ -2843,6 +2800,46 @@ QUnit.test( "originalEvent property for Chrome, Safari, Fx & Edge of simulated e jQuery( "#donor-input" ).trigger( "focus" ); } ); + +QUnit[ jQuery.fn.click ? "test" : "skip" ]( "trigger() shortcuts", function( assert ) { + assert.expect( 5 ); + + var counter, clickCounter, + elem = jQuery( "
  • Change location
  • " ).prependTo( "#firstUL" ); + elem.find( "a" ).on( "click", function() { + var close = jQuery( "spanx", this ); // same with jQuery(this).find("span"); + assert.equal( close.length, 0, "Context element does not exist, length must be zero" ); + assert.ok( !close[ 0 ], "Context element does not exist, direct access to element must return undefined" ); + return false; + } ).click(); + + // manually clean up detached elements + elem.remove(); + + jQuery( "#check1" ).click( function() { + assert.ok( true, "click event handler for checkbox gets fired twice, see #815" ); + } ).click(); + + counter = 0; + jQuery( "#firstp" )[ 0 ].onclick = function() { + counter++; + }; + jQuery( "#firstp" ).click(); + assert.equal( counter, 1, "Check that click, triggers onclick event handler also" ); + + clickCounter = 0; + jQuery( "#simon1" )[ 0 ].onclick = function() { + clickCounter++; + }; + jQuery( "#simon1" ).click(); + assert.equal( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" ); + + // test that special handlers do not blow up with VML elements (#7071) + jQuery( "" ).appendTo( "head" ); + jQuery( " " ).appendTo( "#form" ); + jQuery( "#oval" ).click().keydown(); +} ); + QUnit[ jQuery.fn.click ? "test" : "skip" ]( "Event aliases", function( assert ) { // Explicitly skipping focus/blur events due to their flakiness -- 2.39.5