mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Tests: further improvements QUnit 2.0 migration
* Remove QUnit jshint globals * Extend QUnit.assert methods * Use assert.async instead of start/stop/done Refb930d14ce6Refc8d15a2f9f
This commit is contained in:
@@ -235,7 +235,7 @@ QUnit.test( "on(), namespace with special add", function( assert ) {
|
||||
QUnit.test( "on(), no data", function( assert ) {
|
||||
assert.expect( 1 );
|
||||
var handler = function( event ) {
|
||||
ok ( !event.data, "Check that no data is added to the event object" );
|
||||
assert.ok( !event.data, "Check that no data is added to the event object" );
|
||||
};
|
||||
jQuery( "#firstp" ).on( "click", handler ).trigger( "click" );
|
||||
} );
|
||||
@@ -1647,17 +1647,23 @@ QUnit.test( ".on()/.off()", function( assert ) {
|
||||
assert.equal( clicked, 2, "off with a context" );
|
||||
|
||||
// Test binding with event data
|
||||
jQuery( "#body" ).on( "click", "#foo", true, function( e ) { equal( e.data, true, "on with event data" ); } );
|
||||
jQuery( "#body" ).on( "click", "#foo", true, function( e ) {
|
||||
assert.equal( e.data, true, "on with event data" );
|
||||
} );
|
||||
jQuery( "#foo" ).trigger( "click" );
|
||||
jQuery( "#body" ).off( "click", "#foo" );
|
||||
|
||||
// Test binding with trigger data
|
||||
jQuery( "#body" ).on( "click", "#foo", function( e, data ) { equal( data, true, "on with trigger data" ); } );
|
||||
jQuery( "#body" ).on( "click", "#foo", function( e, data ) {
|
||||
assert.equal( data, true, "on with trigger data" );
|
||||
} );
|
||||
jQuery( "#foo" ).trigger( "click", true );
|
||||
jQuery( "#body" ).off( "click", "#foo" );
|
||||
|
||||
// Test binding with different this object
|
||||
jQuery( "#body" ).on( "click", "#foo", jQuery.proxy( function() { equal( this[ "foo" ], "bar", "on with event scope" ); }, { "foo": "bar" } ) );
|
||||
jQuery( "#body" ).on( "click", "#foo", jQuery.proxy( function() {
|
||||
assert.equal( this[ "foo" ], "bar", "on with event scope" ); }, { "foo": "bar" }
|
||||
) );
|
||||
jQuery( "#foo" ).trigger( "click" );
|
||||
jQuery( "#body" ).off( "click", "#foo" );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user