Tests: further improvements QUnit 2.0 migration

* Remove QUnit jshint globals
* Extend QUnit.assert methods
* Use assert.async instead of start/stop/done

Ref b930d14ce6
Ref c8d15a2f9f
This commit is contained in:
Oleg Gaidarenko
2015-09-08 03:26:29 +03:00
parent f71e32d4b4
commit 2f0cedc997
16 changed files with 284 additions and 262 deletions

View File

@@ -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" );