diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2015-09-03 04:46:31 +0300 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2015-09-07 20:14:59 +0300 |
commit | 4543815eeda0d7299e701311ca4ac38f23dbaf3a (patch) | |
tree | f5a0374836bf1b0c0b748098a14075093ea8de7b | |
parent | c530661629ac713a3ccab9691773cc6de5e84759 (diff) | |
download | jquery-4543815eeda0d7299e701311ca4ac38f23dbaf3a.tar.gz jquery-4543815eeda0d7299e701311ca4ac38f23dbaf3a.zip |
Tests: Partially use new qunit interface
http://qunitjs.com/upgrade-guide-2.x/
For most of the boring work was used
https://github.com/apsdehal/qunit-migrate package
However, it can't update local qunit helpers, plus in some places
old QUnit.asyncTest signature is still used
Ref b930d14ce64937e9478405eee2828d4da091d2cb
Fixes gh-2540
-rw-r--r-- | test/data/testinit.js | 72 | ||||
-rw-r--r-- | test/unit/ajax.js | 2271 | ||||
-rw-r--r-- | test/unit/animation.js | 205 | ||||
-rw-r--r-- | test/unit/attributes.js | 986 | ||||
-rw-r--r-- | test/unit/callbacks.js | 130 | ||||
-rw-r--r-- | test/unit/core.js | 1058 | ||||
-rw-r--r-- | test/unit/css.js | 623 | ||||
-rw-r--r-- | test/unit/data.js | 1038 | ||||
-rw-r--r-- | test/unit/deferred.js | 196 | ||||
-rw-r--r-- | test/unit/deprecated.js | 2 | ||||
-rw-r--r-- | test/unit/dimensions.js | 380 | ||||
-rw-r--r-- | test/unit/effects.js | 904 | ||||
-rw-r--r-- | test/unit/event.js | 1115 | ||||
-rw-r--r-- | test/unit/exports.js | 8 | ||||
-rw-r--r-- | test/unit/manipulation.js | 1358 | ||||
-rw-r--r-- | test/unit/offset.js | 326 | ||||
-rw-r--r-- | test/unit/queue.js | 174 | ||||
-rw-r--r-- | test/unit/ready.js | 30 | ||||
-rw-r--r-- | test/unit/selector.js | 338 | ||||
-rw-r--r-- | test/unit/serialize.js | 78 | ||||
-rw-r--r-- | test/unit/support.js | 72 | ||||
-rw-r--r-- | test/unit/traversing.js | 816 | ||||
-rw-r--r-- | test/unit/tween.js | 293 | ||||
-rw-r--r-- | test/unit/wrap.js | 295 |
24 files changed, 6646 insertions, 6122 deletions
diff --git a/test/data/testinit.js b/test/data/testinit.js index 273436cf9..491440e19 100644 --- a/test/data/testinit.js +++ b/test/data/testinit.js @@ -17,7 +17,7 @@ original$ = this.$ = "replaced"; /** * Returns an array of elements with the given IDs - * @example q("main", "foo", "bar") + * @example q( "main", "foo", "bar" ) * @result [<div id="main">, <span id="foo">, <input id="bar">] */ this.q = function() { @@ -114,12 +114,12 @@ this.createXMLFragment = function() { fireNative = document.createEvent ? function( node, type ) { var event = document.createEvent( "HTMLEvents" ); + event.initEvent( type, true, true ); node.dispatchEvent( event ); } : function( node, type ) { - var event = document.createEventObject(); - node.fireEvent( "on" + type, event ); + node.fireEvent( "on" + type, document.createEventObject() ); }; /** @@ -138,16 +138,20 @@ function url( value ) { // Ajax testing helper this.ajaxTest = function( title, expect, options ) { - var requestOptions; - if ( jQuery.isFunction( options ) ) { - options = options(); - } - options = options || []; - requestOptions = options.requests || options.request || options; - if ( !jQuery.isArray( requestOptions ) ) { - requestOptions = [ requestOptions ]; - } - asyncTest( title, expect, function() { + QUnit.test( title, expect, function( assert ) { + var requestOptions; + + if ( jQuery.isFunction( options ) ) { + options = options( assert ); + } + options = options || []; + requestOptions = options.requests || options.request || options; + if ( !jQuery.isArray( requestOptions ) ) { + requestOptions = [ requestOptions ]; + } + + var done = assert.async(); + if ( options.setup ) { options.setup(); } @@ -161,7 +165,9 @@ this.ajaxTest = function( title, expect, options ) { if ( options.teardown ) { options.teardown(); } - start(); + + // Make sure all events will be called before done() + setTimeout( done ); } }, requests = jQuery.map( requestOptions, function( options ) { @@ -171,7 +177,7 @@ this.ajaxTest = function( title, expect, options ) { return function( _, status ) { if ( !completed ) { if ( !handler ) { - ok( false, "unexpected " + status ); + assert.ok( false, "unexpected " + status ); } else if ( jQuery.isFunction( handler ) ) { handler.apply( this, arguments ); } @@ -180,7 +186,7 @@ this.ajaxTest = function( title, expect, options ) { }; if ( options.afterSend ) { - options.afterSend( request ); + options.afterSend( request, assert ); } return request @@ -203,7 +209,8 @@ this.ajaxTest = function( title, expect, options ) { }; this.testIframe = function( fileName, name, fn ) { - asyncTest( name, function() { + QUnit.test( name, function( assert ) { + var done = assert.async(); // load fixture in iframe var iframe = loadFixture(), @@ -212,10 +219,9 @@ this.testIframe = function( fileName, name, fn ) { if ( win && win.jQuery && win.jQuery.isReady ) { clearInterval( interval ); - start(); - // call actual tests passing the correct jQuery instance to use - fn.call( this, win.jQuery, win, win.document ); + fn.call( this, win.jQuery, win, win.document, assert ); + done(); document.body.removeChild( iframe ); iframe = null; } @@ -234,31 +240,31 @@ this.testIframe = function( fileName, name, fn ) { }; this.testIframeWithCallback = function( title, fileName, func ) { - - test( title, function() { + QUnit.test( title, 1, function( assert ) { var iframe; + var done = assert.async(); - // Expect one assertion, but allow overrides - expect( 1 ); - - stop(); window.iframeCallback = function() { - var self = this, - args = arguments; + var args = Array.prototype.slice.call( arguments ); + + args.push( assert ); + setTimeout( function() { - window.iframeCallback = undefined; + this.iframeCallback = undefined; + iframe.remove(); - func.apply( self, args ); + func.apply( this, args ); func = function() {}; - start(); - }, 0 ); + + done(); + } ); }; iframe = jQuery( "<div/>" ).css( { position: "absolute", width: "500px", left: "-600px" } ) .append( jQuery( "<iframe/>" ).attr( "src", url( "./data/" + fileName ) ) ) .appendTo( "#qunit-fixture" ); } ); }; -window.iframeCallback = undefined; +this.iframeCallback = undefined; // Tests are always loaded async QUnit.config.autostart = false; diff --git a/test/unit/ajax.js b/test/unit/ajax.js index 0dceb0251..541bdff5c 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -1,6 +1,6 @@ var isIE8 = /msie 8\.0/i.test( window.navigator.userAgent ); -module( "ajax", { +QUnit.module( "ajax", { setup: function() { if ( !isIE8 ) { return; @@ -20,117 +20,136 @@ module( "ajax", { } ); ( function() { - test( "Unit Testing Environment", function() { - expect( 2 ); + QUnit.test( "Unit Testing Environment", function( assert ) { + assert.expect( 2 ); - ok( hasPHP, "Running in an environment with PHP support. The AJAX tests only run if the environment supports PHP!" ); - ok( !isLocal, "Unit tests are not ran from file:// (especially in Chrome. If you must test from file:// with Chrome, run it with the --allow-file-access-from-files flag!)" ); + assert.ok( hasPHP, "Running in an environment with PHP support. The AJAX tests only run if the environment supports PHP!" ); + assert.ok( !isLocal, "Unit tests are not ran from file:// (especially in Chrome. If you must test from file:// with Chrome, run it with the --allow-file-access-from-files flag!)" ); } ); if ( !jQuery.ajax || ( isLocal && !hasPHP ) ) { return; } - function addGlobalEvents( expected ) { + function addGlobalEvents( expected, assert ) { return function() { expected = expected || ""; jQuery( document ).on( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError ajaxSuccess", function( e ) { - ok( expected.indexOf( e.type ) !== -1, e.type ); + assert.ok( expected.indexOf( e.type ) !== -1, e.type ); } ); }; } //----------- jQuery.ajax() - ajaxTest( "jQuery.ajax() - success callbacks", 8, { - setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess" ), - url: url( "data/name.html" ), - beforeSend: function() { - ok( true, "beforeSend" ); - }, - success: function() { - ok( true, "success" ); - }, - complete: function() { - ok( true, "complete" ); + testIframeWithCallback( + "XMLHttpRequest - Attempt to block tests because of dangling XHR requests (IE)", + "ajax/unreleasedXHR.html", + function( assert ) { + assert.expect( 1 ); + assert.ok( true, "done" ); } + ); + + ajaxTest( "jQuery.ajax() - success callbacks", 8, function( assert ) { + return { + setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess", assert ), + url: url( "data/name.html" ), + beforeSend: function() { + assert.ok( true, "beforeSend" ); + }, + success: function() { + assert.ok( true, "success" ); + }, + complete: function() { + assert.ok( true, "complete" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - success callbacks - (url, options) syntax", 8, { - setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess" ), - create: function( options ) { - return jQuery.ajax( url( "data/name.html" ), options ); - }, - beforeSend: function() { - ok( true, "beforeSend" ); - }, - success: function() { - ok( true, "success" ); - }, - complete: function() { - ok( true, "complete" ); - } + ajaxTest( "jQuery.ajax() - success callbacks - (url, options) syntax", 8, function( assert ) { + return { + setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess", assert ), + create: function( options ) { + return jQuery.ajax( url( "data/name.html" ), options ); + }, + beforeSend: function() { + assert.ok( true, "beforeSend" ); + }, + success: function() { + assert.ok( true, "success" ); + }, + complete: function() { + assert.ok( true, "complete" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - success callbacks (late binding)", 8, { - setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess" ), - url: url( "data/name.html" ), - beforeSend: function() { - ok( true, "beforeSend" ); - }, - success: true, - afterSend: function( request ) { - request.always( function() { - ok( true, "complete" ); - } ).done( function() { - ok( true, "success" ); - } ).fail( function() { - ok( false, "error" ); - } ); - } + ajaxTest( "jQuery.ajax() - success callbacks (late binding)", 8, function( assert ) { + return { + setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess", assert ), + url: url( "data/name.html" ), + beforeSend: function() { + assert.ok( true, "beforeSend" ); + }, + success: true, + afterSend: function( request ) { + request.always( function() { + assert.ok( true, "complete" ); + } ).done( function() { + assert.ok( true, "success" ); + } ).fail( function() { + assert.ok( false, "error" ); + } ); + } + }; } ); - ajaxTest( "jQuery.ajax() - success callbacks (oncomplete binding)", 8, { - setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess" ), - url: url( "data/name.html" ), - beforeSend: function() { - ok( true, "beforeSend" ); - }, - success: true, - complete: function( xhr ) { - xhr.always( function() { - ok( true, "complete" ); - } ).done( function() { - ok( true, "success" ); - } ).fail( function() { - ok( false, "error" ); - } ); - } + ajaxTest( "jQuery.ajax() - success callbacks (oncomplete binding)", 8, function( assert ) { + return { + setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxSuccess", assert ), + url: url( "data/name.html" ), + beforeSend: function() { + assert.ok( true, "beforeSend" ); + }, + success: true, + complete: function( xhr ) { + xhr.always( function() { + assert.ok( true, "complete" ); + } ).done( function() { + assert.ok( true, "success" ); + } ).fail( function() { + assert.ok( false, "error" ); + } ); + } + }; } ); - ajaxTest( "jQuery.ajax() - error callbacks", 8, { - setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError" ), - url: url( "data/name.php?wait=5" ), - beforeSend: function() { - ok( true, "beforeSend" ); - }, - afterSend: function( request ) { - request.abort(); - }, - error: function() { - ok( true, "error" ); - }, - complete: function() { - ok( true, "complete" ); - } + ajaxTest( "jQuery.ajax() - error callbacks", 8, function( assert ) { + return { + setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError", assert ), + url: url( "data/name.php?wait=5" ), + beforeSend: function() { + assert.ok( true, "beforeSend" ); + }, + afterSend: function( request ) { + request.abort(); + }, + error: function() { + assert.ok( true, "error" ); + }, + complete: function() { + assert.ok( true, "complete" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - textStatus and errorThrown values", 4, [ - { + ajaxTest( "jQuery.ajax() - textStatus and errorThrown values", 4, function( assert ) { + return [ { url: url( "data/name.php?wait=5" ), error: function( _, textStatus, errorThrown ) { - strictEqual( textStatus, "abort", "textStatus is 'abort' for abort" ); - strictEqual( errorThrown, "abort", "errorThrown is 'abort' for abort" ); + assert.strictEqual( textStatus, "abort", "textStatus is 'abort' for abort" ); + assert.strictEqual( errorThrown, "abort", "errorThrown is 'abort' for abort" ); }, afterSend: function( request ) { request.abort(); @@ -139,23 +158,25 @@ module( "ajax", { { url: url( "data/name.php?wait=5" ), error: function( _, textStatus, errorThrown ) { - strictEqual( textStatus, "mystatus", "textStatus is 'mystatus' for abort('mystatus')" ); - strictEqual( errorThrown, "mystatus", "errorThrown is 'mystatus' for abort('mystatus')" ); + assert.strictEqual( textStatus, "mystatus", "textStatus is 'mystatus' for abort('mystatus')" ); + assert.strictEqual( errorThrown, "mystatus", "errorThrown is 'mystatus' for abort('mystatus')" ); }, afterSend: function( request ) { request.abort( "mystatus" ); } - } - ] ); + } ]; + } ); - ajaxTest( "jQuery.ajax() - responseText on error", 1, { - url: url( "data/errorWithText.php" ), - error: function( xhr ) { - strictEqual( xhr.responseText, "plain text message", "Test jqXHR.responseText is filled for HTTP errors" ); - } + ajaxTest( "jQuery.ajax() - responseText on error", 1, function( assert ) { + return { + url: url( "data/errorWithText.php" ), + error: function( xhr ) { + assert.strictEqual( xhr.responseText, "plain text message", "Test jqXHR.responseText is filled for HTTP errors" ); + } + }; } ); - asyncTest( "jQuery.ajax() - retry with jQuery.ajax( this )", 2, function() { + QUnit.asyncTest( "jQuery.ajax() - retry with jQuery.ajax( this )", 2, function( assert ) { var previousUrl, firstTime = true; jQuery.ajax( { @@ -175,8 +196,8 @@ module( "ajax", { if ( !previousUrl ) { previousUrl = this.url; } else { - strictEqual( this.url, previousUrl, "url parameters are not re-appended" ); - start(); + assert.strictEqual( this.url, previousUrl, "url parameters are not re-appended" ); + QUnit.start(); return false; } }, @@ -189,129 +210,139 @@ module( "ajax", { } ); } ); - ajaxTest( "jQuery.ajax() - headers", 5, { - setup: function() { - jQuery( document ).ajaxSend( function( evt, xhr ) { - xhr.setRequestHeader( "ajax-send", "test" ); - } ); - }, - url: url( "data/headers.php?keys=siMPle_SometHing-elsE_OthEr_Nullable_undefined_Empty_ajax-send" ), - headers: { - "siMPle": "value", - "SometHing-elsE": "other value", - "OthEr": "something else", - "Nullable": null, - "undefined": undefined - - // Support: Firefox - // Not all browsers allow empty-string headers - // https://bugzilla.mozilla.org/show_bug.cgi?id=815299 - //"Empty": "" - }, - success: function( data, _, xhr ) { - var i, emptyHeader, - requestHeaders = jQuery.extend( this.headers, { - "ajax-send": "test" - } ), - tmp = []; - for ( i in requestHeaders ) { - tmp.push( i, ": ", requestHeaders[ i ] + "", "\n" ); - } - tmp = tmp.join( "" ); + ajaxTest( "jQuery.ajax() - headers", 5, function( assert ) { + return { + setup: function() { + jQuery( document ).ajaxSend( function( evt, xhr ) { + xhr.setRequestHeader( "ajax-send", "test" ); + } ); + }, + url: url( "data/headers.php?keys=siMPle_SometHing-elsE_OthEr_Nullable_undefined_Empty_ajax-send" ), + headers: { + "siMPle": "value", + "SometHing-elsE": "other value", + "OthEr": "something else", + "Nullable": null, + "undefined": undefined + + // Support: Firefox + // Not all browsers allow empty-string headers + // https://bugzilla.mozilla.org/show_bug.cgi?id=815299 + //"Empty": "" + }, + success: function( data, _, xhr ) { + var i, emptyHeader, + requestHeaders = jQuery.extend( this.headers, { + "ajax-send": "test" + } ), + tmp = []; + for ( i in requestHeaders ) { + tmp.push( i, ": ", requestHeaders[ i ] + "", "\n" ); + } + tmp = tmp.join( "" ); - strictEqual( data, tmp, "Headers were sent" ); - strictEqual( xhr.getResponseHeader( "Sample-Header" ), "Hello World", "Sample header received" ); - ok( data.indexOf( "undefined" ) < 0, "Undefined header value was not sent" ); + assert.strictEqual( data, tmp, "Headers were sent" ); + assert.strictEqual( xhr.getResponseHeader( "Sample-Header" ), "Hello World", "Sample header received" ); + assert.ok( data.indexOf( "undefined" ) < 0, "Undefined header value was not sent" ); - emptyHeader = xhr.getResponseHeader( "Empty-Header" ); - if ( emptyHeader === null ) { - ok( true, "Firefox doesn't support empty headers" ); - } else { - strictEqual( emptyHeader, "", "Empty header received" ); + emptyHeader = xhr.getResponseHeader( "Empty-Header" ); + if ( emptyHeader === null ) { + assert.ok( true, "Firefox doesn't support empty headers" ); + } else { + assert.strictEqual( emptyHeader, "", "Empty header received" ); + } + assert.strictEqual( xhr.getResponseHeader( "Sample-Header2" ), "Hello World 2", "Second sample header received" ); } - strictEqual( xhr.getResponseHeader( "Sample-Header2" ), "Hello World 2", "Second sample header received" ); - } - } ); - - ajaxTest( "jQuery.ajax() - Accept header", 1, { - url: url( "data/headers.php?keys=accept" ), - headers: { - Accept: "very wrong accept value" - }, - beforeSend: function( xhr ) { - xhr.setRequestHeader( "Accept", "*/*" ); - }, - success: function( data ) { - strictEqual( data, "accept: */*\n", "Test Accept header is set to last value provided" ); - } + }; } ); - ajaxTest( "jQuery.ajax() - contentType", 2, [ - { - url: url( "data/headers.php?keys=content-type" ), - contentType: "test", + ajaxTest( "jQuery.ajax() - Accept header", 1, function( assert ) { + return { + url: url( "data/headers.php?keys=accept" ), + headers: { + Accept: "very wrong accept value" + }, + beforeSend: function( xhr ) { + xhr.setRequestHeader( "Accept", "*/*" ); + }, success: function( data ) { - strictEqual( data, "content-type: test\n", "Test content-type is sent when options.contentType is set" ); + assert.strictEqual( data, "accept: */*\n", "Test Accept header is set to last value provided" ); } - }, - { - url: url( "data/headers.php?keys=content-type" ), - contentType: false, - success: function( data ) { + }; + } ); - // Some server/interpreter combinations always supply a Content-Type to scripts - data = data || "content-type: \n"; - strictEqual( data, "content-type: \n", "Test content-type is not set when options.contentType===false" ); - } - } - ] ); + ajaxTest( "jQuery.ajax() - contentType", 2, function( assert ) { + return [ + { + url: url( "data/headers.php?keys=content-type" ), + contentType: "test", + success: function( data ) { + assert.strictEqual( data, "content-type: test\n", "Test content-type is sent when options.contentType is set" ); + } + }, + { + url: url( "data/headers.php?keys=content-type" ), + contentType: false, + success: function( data ) { - ajaxTest( "jQuery.ajax() - protocol-less urls", 1, { - url: "//somedomain.com", - beforeSend: function( xhr, settings ) { - equal( settings.url, location.protocol + "//somedomain.com", "Make sure that the protocol is added." ); - return false; - }, - error: true + // Some server/interpreter combinations always supply a Content-Type to scripts + data = data || "content-type: \n"; + assert.strictEqual( data, "content-type: \n", "Test content-type is not set when options.contentType===false" ); + } + } + ]; } ); - ajaxTest( "jQuery.ajax() - hash", 3, [ - { - url: "data/name.html#foo", - beforeSend: function( xhr, settings ) { - equal( settings.url, "data/name.html", "Make sure that the URL is trimmed." ); - return false; - }, - error: true - }, - { - url: "data/name.html?abc#foo", + ajaxTest( "jQuery.ajax() - protocol-less urls", 1, function( assert ) { + return { + url: "//somedomain.com", beforeSend: function( xhr, settings ) { - equal( settings.url, "data/name.html?abc", "Make sure that the URL is trimmed." ); + assert.equal( settings.url, location.protocol + "//somedomain.com", "Make sure that the protocol is added." ); return false; }, error: true - }, - { - url: "data/name.html?abc#foo", - data: { - "test": 123 + }; + } ); + + ajaxTest( "jQuery.ajax() - hash", 3, function( assert ) { + return [ + { + url: "data/name.html#foo", + beforeSend: function( xhr, settings ) { + assert.equal( settings.url, "data/name.html", "Make sure that the URL is trimmed." ); + return false; + }, + error: true }, - beforeSend: function( xhr, settings ) { - equal( settings.url, "data/name.html?abc&test=123", "Make sure that the URL is trimmed." ); - return false; + { + url: "data/name.html?abc#foo", + beforeSend: function( xhr, settings ) { + assert.equal( settings.url, "data/name.html?abc", "Make sure that the URL is trimmed." ); + return false; + }, + error: true }, - error: true - } - ] ); + { + url: "data/name.html?abc#foo", + data: { + "test": 123 + }, + beforeSend: function( xhr, settings ) { + assert.equal( settings.url, "data/name.html?abc&test=123", "Make sure that the URL is trimmed." ); + return false; + }, + error: true + } + ]; + } ); - ajaxTest( "jQuery.ajax() - cross-domain detection", 8, function() { + ajaxTest( "jQuery.ajax() - cross-domain detection", 8, function( assert ) { function request( url, title, crossDomainOrOptions ) { return jQuery.extend( { dataType: "jsonp", url: url, beforeSend: function( _, s ) { - ok( crossDomainOrOptions === false ? !s.crossDomain : s.crossDomain, title ); + assert.ok( crossDomainOrOptions === false ? !s.crossDomain : s.crossDomain, title ); return false; }, error: true @@ -363,34 +394,35 @@ module( "ajax", { ]; } ); - ajaxTest( "jQuery.ajax() - abort", 9, { - setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxError ajaxComplete" ), - url: url( "data/name.php?wait=5" ), - beforeSend: function() { - ok( true, "beforeSend" ); - }, - afterSend: function( xhr ) { - strictEqual( xhr.readyState, 1, "XHR readyState indicates successful dispatch" ); - xhr.abort(); - strictEqual( xhr.readyState, 0, "XHR readyState indicates successful abortion" ); - }, - error: true, - complete: function() { - ok( true, "complete" ); - } + ajaxTest( "jQuery.ajax() - abort", 9, function( assert ) { + return { + setup: addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxError ajaxComplete", assert ), + url: url( "data/name.php?wait=5" ), + beforeSend: function() { + assert.ok( true, "beforeSend" ); + }, + afterSend: function( xhr ) { + assert.strictEqual( xhr.readyState, 1, "XHR readyState indicates successful dispatch" ); + xhr.abort(); + assert.strictEqual( xhr.readyState, 0, "XHR readyState indicates successful abortion" ); + }, + error: true, + complete: function() { + assert.ok( true, "complete" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - events with context", 12, function() { - + ajaxTest( "jQuery.ajax() - events with context", 12, function( assert ) { var context = document.createElement( "div" ); function event( e ) { - equal( this, context, e.type ); + assert.equal( this, context, e.type ); } function callback( msg ) { return function() { - equal( this, context, "context is preserved on callback " + msg ); + assert.equal( this, context, "context is preserved on callback " + msg ); }; } @@ -418,10 +450,10 @@ module( "ajax", { }; } ); - ajaxTest( "jQuery.ajax() - events without context", 3, function() { + ajaxTest( "jQuery.ajax() - events without context", 3, function( assert ) { function nocallback( msg ) { return function() { - equal( typeof this.url, "string", "context is settings on callback " + msg ); + assert.equal( typeof this.url, "string", "context is settings on callback " + msg ); }; } return { @@ -432,7 +464,7 @@ module( "ajax", { }; } ); - ajaxTest( "#15118 - jQuery.ajax() - function without jQuery.event", 1, function() { + ajaxTest( "#15118 - jQuery.ajax() - function without jQuery.event", 1, function( assert ) { var holder; return { url: url( "data/json.php" ), @@ -441,196 +473,218 @@ module( "ajax", { delete jQuery.event; }, complete: function() { - ok( true, "Call can be made without jQuery.event" ); + assert.ok( true, "Call can be made without jQuery.event" ); jQuery.event = holder; }, success: true }; } ); - ajaxTest( "#15160 - jQuery.ajax() - request manually aborted in ajaxSend", 3, { - setup: function() { - jQuery( document ).on( "ajaxSend", function( e, jqXHR ) { - jqXHR.abort(); - } ); + ajaxTest( "#15160 - jQuery.ajax() - request manually aborted in ajaxSend", 3, function( assert ) { + return { + setup: function() { + jQuery( document ).on( "ajaxSend", function( e, jqXHR ) { + jqXHR.abort(); + } ); - jQuery( document ).on( "ajaxError ajaxComplete", function( e, jqXHR ) { - equal( jqXHR.statusText, "abort", "jqXHR.statusText equals abort on global ajaxComplete and ajaxError events" ); - } ); - }, - url: url( "data/name.html" ), - error: true, - complete: function() { - ok( true, "complete" ); - } + jQuery( document ).on( "ajaxError ajaxComplete", function( e, jqXHR ) { + assert.equal( jqXHR.statusText, "abort", "jqXHR.statusText equals abort on global ajaxComplete and ajaxError events" ); + } ); + }, + url: url( "data/name.html" ), + error: true, + complete: function() { + assert.ok( true, "complete" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - context modification", 1, { - url: url( "data/name.html" ), - context: {}, - beforeSend: function() { - this.test = "foo"; - }, - afterSend: function() { - strictEqual( this.context.test, "foo", "Make sure the original object is maintained." ); - }, - success: true + ajaxTest( "jQuery.ajax() - context modification", 1, function( assert ) { + return { + url: url( "data/name.html" ), + context: {}, + beforeSend: function() { + this.test = "foo"; + }, + afterSend: function() { + assert.strictEqual( this.context.test, "foo", "Make sure the original object is maintained." ); + }, + success: true + }; } ); - ajaxTest( "jQuery.ajax() - context modification through ajaxSetup", 3, function() { + ajaxTest( "jQuery.ajax() - context modification through ajaxSetup", 3, function( assert ) { var obj = {}; return { setup: function() { jQuery.ajaxSetup( { context: obj } ); - strictEqual( jQuery.ajaxSettings.context, obj, "Make sure the context is properly set in ajaxSettings." ); + assert.strictEqual( jQuery.ajaxSettings.context, obj, "Make sure the context is properly set in ajaxSettings." ); }, requests: [ { url: url( "data/name.html" ), success: function() { - strictEqual( this, obj, "Make sure the original object is maintained." ); + assert.strictEqual( this, obj, "Make sure the original object is maintained." ); } }, { url: url( "data/name.html" ), context: {}, success: function() { - ok( this !== obj, "Make sure overriding context is possible." ); + assert.ok( this !== obj, "Make sure overriding context is possible." ); } } ] }; } ); - ajaxTest( "jQuery.ajax() - disabled globals", 3, { - setup: addGlobalEvents( "" ), - global: false, - url: url( "data/name.html" ), - beforeSend: function() { - ok( true, "beforeSend" ); - }, - success: function() { - ok( true, "success" ); - }, - complete: function() { - ok( true, "complete" ); - } + ajaxTest( "jQuery.ajax() - disabled globals", 3, function( assert ) { + return { + setup: addGlobalEvents( "", assert ), + global: false, + url: url( "data/name.html" ), + beforeSend: function() { + assert.ok( true, "beforeSend" ); + }, + success: function() { + assert.ok( true, "success" ); + }, + complete: function() { + assert.ok( true, "complete" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - xml: non-namespace elements inside namespaced elements", 3, { - url: url( "data/with_fries.xml" ), - dataType: "xml", - success: function( resp ) { - equal( jQuery( "properties", resp ).length, 1, "properties in responseXML" ); - equal( jQuery( "jsconf", resp ).length, 1, "jsconf in responseXML" ); - equal( jQuery( "thing", resp ).length, 2, "things in responseXML" ); - } + ajaxTest( "jQuery.ajax() - xml: non-namespace elements inside namespaced elements", 3, function( assert ) { + return { + url: url( "data/with_fries.xml" ), + dataType: "xml", + success: function( resp ) { + assert.equal( jQuery( "properties", resp ).length, 1, "properties in responseXML" ); + assert.equal( jQuery( "jsconf", resp ).length, 1, "jsconf in responseXML" ); + assert.equal( jQuery( "thing", resp ).length, 2, "things in responseXML" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - xml: non-namespace elements inside namespaced elements (over JSONP)", 3, { - url: url( "data/with_fries_over_jsonp.php" ), - dataType: "jsonp xml", - success: function( resp ) { - equal( jQuery( "properties", resp ).length, 1, "properties in responseXML" ); - equal( jQuery( "jsconf", resp ).length, 1, "jsconf in responseXML" ); - equal( jQuery( "thing", resp ).length, 2, "things in responseXML" ); - } + ajaxTest( "jQuery.ajax() - xml: non-namespace elements inside namespaced elements (over JSONP)", 3, function( assert ) { + return { + url: url( "data/with_fries_over_jsonp.php" ), + dataType: "jsonp xml", + success: function( resp ) { + assert.equal( jQuery( "properties", resp ).length, 1, "properties in responseXML" ); + assert.equal( jQuery( "jsconf", resp ).length, 1, "jsconf in responseXML" ); + assert.equal( jQuery( "thing", resp ).length, 2, "things in responseXML" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - HEAD requests", 2, [ - { - url: url( "data/name.html" ), - type: "HEAD", - success: function( data, status, xhr ) { - ok( /Date/i.test( xhr.getAllResponseHeaders() ), "No Date in HEAD response" ); + ajaxTest( "jQuery.ajax() - HEAD requests", 2, function( assert ) { + return [ + { + url: url( "data/name.html" ), + type: "HEAD", + success: function( data, status, xhr ) { + assert.ok( /Date/i.test( xhr.getAllResponseHeaders() ), "No Date in HEAD response" ); + } + }, + { + url: url( "data/name.html" ), + data: { + "whip_it": "good" + }, + type: "HEAD", + success: function( data, status, xhr ) { + assert.ok( /Date/i.test( xhr.getAllResponseHeaders() ), "No Date in HEAD response with data" ); + } } - }, - { + ]; + } ); + + ajaxTest( "jQuery.ajax() - beforeSend", 1, function( assert ) { + return { url: url( "data/name.html" ), - data: { - "whip_it": "good" + beforeSend: function() { + this.check = true; }, - type: "HEAD", - success: function( data, status, xhr ) { - ok( /Date/i.test( xhr.getAllResponseHeaders() ), "No Date in HEAD response with data" ); + success: function() { + assert.ok( this.check, "check beforeSend was executed" ); } - } - ] ); - - ajaxTest( "jQuery.ajax() - beforeSend", 1, { - url: url( "data/name.html" ), - beforeSend: function() { - this.check = true; - }, - success: function() { - ok( this.check, "check beforeSend was executed" ); - } + }; } ); - ajaxTest( "jQuery.ajax() - beforeSend, cancel request manually", 2, { - create: function() { - return jQuery.ajax( { - url: url( "data/name.html" ), - beforeSend: function( xhr ) { - ok( true, "beforeSend got called, canceling" ); - xhr.abort(); - }, - success: function() { - ok( false, "request didn't get canceled" ); - }, - complete: function() { - ok( false, "request didn't get canceled" ); - }, - error: function() { - ok( false, "request didn't get canceled" ); - } - } ); - }, - fail: function( _, reason ) { - strictEqual( reason, "canceled", "canceled request must fail with 'canceled' status text" ); - } + ajaxTest( "jQuery.ajax() - beforeSend, cancel request manually", 2, function( assert ) { + return { + create: function() { + return jQuery.ajax( { + url: url( "data/name.html" ), + beforeSend: function( xhr ) { + assert.ok( true, "beforeSend got called, canceling" ); + xhr.abort(); + }, + success: function() { + assert.ok( false, "request didn't get canceled" ); + }, + complete: function() { + assert.ok( false, "request didn't get canceled" ); + }, + error: function() { + assert.ok( false, "request didn't get canceled" ); + } + } ); + }, + fail: function( _, reason ) { + assert.strictEqual( reason, "canceled", "canceled request must fail with 'canceled' status text" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - dataType html", 5, { - setup: function() { - Globals.register( "testFoo" ); - Globals.register( "testBar" ); - }, - dataType: "html", - url: url( "data/test.html" ), - success: function( data ) { - ok( data.match( /^html text/ ), "Check content for datatype html" ); - jQuery( "#ap" ).html( data ); - strictEqual( window[ "testFoo" ], "foo", "Check if script was evaluated for datatype html" ); - strictEqual( window[ "testBar" ], "bar", "Check if script src was evaluated for datatype html" ); - } + ajaxTest( "jQuery.ajax() - dataType html", 5, function( assert ) { + return { + setup: function() { + Globals.register( "testFoo" ); + Globals.register( "testBar" ); + }, + dataType: "html", + url: url( "data/test.html" ), + success: function( data ) { + assert.ok( data.match( /^html text/ ), "Check content for datatype html" ); + jQuery( "#ap" ).html( data ); + assert.strictEqual( window[ "testFoo" ], "foo", "Check if script was evaluated for datatype html" ); + assert.strictEqual( window[ "testBar" ], "bar", "Check if script src was evaluated for datatype html" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - synchronous request", 1, { - url: url( "data/json_obj.js" ), - dataType: "text", - async: false, - success: true, - afterSend: function( xhr ) { - ok( /^\{ "data"/.test( xhr.responseText ), "check returned text" ); - } + ajaxTest( "jQuery.ajax() - synchronous request", 1, function( assert ) { + return { + url: url( "data/json_obj.js" ), + dataType: "text", + async: false, + success: true, + afterSend: function( xhr ) { + assert.ok( /^\{ "data"/.test( xhr.responseText ), "check returned text" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - synchronous request with callbacks", 2, { - url: url( "data/json_obj.js" ), - async: false, - dataType: "text", - success: true, - afterSend: function( xhr ) { - var result; - xhr.done( function( data ) { - ok( true, "success callback executed" ); - result = data; - } ); - ok( /^\{ "data"/.test( result ), "check returned text" ); - } + ajaxTest( "jQuery.ajax() - synchronous request with callbacks", 2, function( assert ) { + return { + url: url( "data/json_obj.js" ), + async: false, + dataType: "text", + success: true, + afterSend: function( xhr ) { + var result; + xhr.done( function( data ) { + assert.ok( true, "success callback executed" ); + result = data; + } ); + assert.ok( /^\{ "data"/.test( result ), "check returned text" ); + } + }; } ); - asyncTest( "jQuery.ajax(), jQuery.get[Script|JSON](), jQuery.post(), pass-through request object", 8, function() { + QUnit.asyncTest( "jQuery.ajax(), jQuery.get[Script|JSON](), jQuery.post(), pass-through request object", 8, function( assert ) { var target = "data/name.html", successCount = 0, errorCount = 0, @@ -643,25 +697,24 @@ module( "ajax", { errorEx += ": " + xml.status; } ); jQuery( document ).one( "ajaxStop", function() { - equal( successCount, 5, "Check all ajax calls successful" ); - equal( errorCount, 0, "Check no ajax errors (status" + errorEx + ")" ); + assert.equal( successCount, 5, "Check all ajax calls successful" ); + assert.equal( errorCount, 0, "Check no ajax errors (status" + errorEx + ")" ); jQuery( document ).off( "ajaxError.passthru" ); - start(); + QUnit.start(); } ); Globals.register( "testBar" ); - ok( jQuery.get( url( target ), success ), "get" ); - ok( jQuery.post( url( target ), success ), "post" ); - ok( jQuery.getScript( url( "data/testbar.php" ), success ), "script" ); - ok( jQuery.getJSON( url( "data/json_obj.js" ), success ), "json" ); - ok( jQuery.ajax( { + assert.ok( jQuery.get( url( target ), success ), "get" ); + assert.ok( jQuery.post( url( target ), success ), "post" ); + assert.ok( jQuery.getScript( url( "data/testbar.php" ), success ), "script" ); + assert.ok( jQuery.getJSON( url( "data/json_obj.js" ), success ), "json" ); + assert.ok( jQuery.ajax( { url: url( target ), success: success } ), "generic" ); } ); - ajaxTest( "jQuery.ajax() - cache", 12, function() { - + ajaxTest( "jQuery.ajax() - cache", 12, function( assert ) { var re = /_=(.*?)(&|$)/g; function request( url, title ) { @@ -671,9 +724,9 @@ module( "ajax", { beforeSend: function() { var parameter, tmp; while ( ( tmp = re.exec( this.url ) ) ) { - strictEqual( parameter, undefined, title + ": only one 'no-cache' parameter" ); + assert.strictEqual( parameter, undefined, title + ": only one 'no-cache' parameter" ); parameter = tmp[ 1 ]; - notStrictEqual( parameter, "tobereplaced555", title + ": parameter (if it was there) was replaced" ); + assert.notStrictEqual( parameter, "tobereplaced555", title + ": parameter (if it was there) was replaced" ); } return false; }, @@ -710,316 +763,189 @@ module( "ajax", { } ); jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) { - - ajaxTest( "jQuery.ajax() - JSONP - Query String (?n)" + label, 4, [ - { - url: "data/jsonp.php?callback=?", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data.data, "JSON results returned (GET, url callback)" ); - } - }, - { - url: "data/jsonp.php?callback=??", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data.data, "JSON results returned (GET, url context-free callback)" ); - } - }, - { - url: "data/jsonp.php/??", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data.data, "JSON results returned (GET, REST-like)" ); - } - }, - { - url: "data/jsonp.php/???json=1", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - strictEqual( jQuery.type( data ), "array", "JSON results returned (GET, REST-like with param)" ); - } - } - ] ); - - ajaxTest( "jQuery.ajax() - JSONP - Explicit callback param" + label, 10, { - setup: function() { - Globals.register( "functionToCleanUp" ); - Globals.register( "XXX" ); - Globals.register( "jsonpResults" ); - window[ "jsonpResults" ] = function( data ) { - ok( data[ "data" ], "JSON results returned (GET, custom callback function)" ); - }; - }, - requests: [ { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - jsonp: "callback", - success: function( data ) { - ok( data[ "data" ], "JSON results returned (GET, data obj callback)" ); - } - }, { + ajaxTest( "#8205 - jQuery.ajax() - JSONP - re-use callbacks name" + label, 4, function( assert ) { + return { url: "data/jsonp.php", dataType: "jsonp", crossDomain: crossDomain, - jsonpCallback: "jsonpResults", - success: function( data ) { - strictEqual( - typeof window[ "jsonpResults" ], - "function", - "should not rewrite original function" + beforeSend: function( jqXHR, s ) { + s.callback = s.jsonpCallback; + + assert.ok( this.callback in window, "JSONP callback name is in the window" ); + }, + success: function() { + var previous = this; + + assert.strictEqual( + previous.jsonpCallback, + undefined, + "jsonpCallback option is set back to default in callbacks" ); - ok( data.data, "JSON results returned (GET, custom callback name)" ); - } - }, { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - jsonpCallback: "functionToCleanUp", - success: function( data ) { - ok( data[ "data" ], "JSON results returned (GET, custom callback name to be cleaned up)" ); - strictEqual( window[ "functionToCleanUp" ], true, "Callback was removed (GET, custom callback name to be cleaned up)" ); - var xhr; - jQuery.ajax( { + + if ( isIE8 ) { + assert.ok( true, "IE8 can't remove property from the window" ); + + } else { + assert.ok( + !( this.callback in window ), + "JSONP callback name was removed from the window" + ); + } + + jQuery.ajax({ url: "data/jsonp.php", dataType: "jsonp", crossDomain: crossDomain, - jsonpCallback: "functionToCleanUp", - beforeSend: function( jqXHR ) { - xhr = jqXHR; + beforeSend: function() { + assert.strictEqual( this.jsonpCallback, previous.callback, "JSONP callback name is re-used" ); return false; } - } ); - xhr.fail( function() { - ok( true, "Ajax error JSON (GET, custom callback name to be cleaned up)" ); - strictEqual( window[ "functionToCleanUp" ], true, "Callback was removed after early abort (GET, custom callback name to be cleaned up)" ); - } ); + }); } - }, { - url: "data/jsonp.php?callback=XXX", - dataType: "jsonp", - jsonp: false, - jsonpCallback: "XXX", - crossDomain: crossDomain, - beforeSend: function() { - ok( /^data\/jsonp.php\?callback=XXX&_=\d+$/.test( this.url ), "The URL wasn't messed with (GET, custom callback name with no url manipulation)" ); - }, - success: function( data ) { - ok( data[ "data" ], "JSON results returned (GET, custom callback name with no url manipulation)" ); - } - } ] + }; } ); + } ); - ajaxTest( "jQuery.ajax() - JSONP - Callback in data" + label, 2, [ - { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - data: "callback=?", - success: function( data ) { - ok( data.data, "JSON results returned (GET, data callback)" ); - } + ajaxTest( "jQuery.ajax() - script, Remote", 2, function( assert ) { + return { + setup: function() { + Globals.register( "testBar" ); }, - { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - data: "callback=??", - success: function( data ) { - ok( data.data, "JSON results returned (GET, data context-free callback)" ); - } + url: window.location.href.replace( /[^\/]*$/, "" ) + "data/testbar.php", + dataType: "script", + success: function() { + assert.strictEqual( window[ "testBar" ], "bar", "Script results returned (GET, no callback)" ); } - ] ); + }; + } ); - ajaxTest( "jQuery.ajax() - JSONP - POST" + label, 3, [ - { - type: "POST", - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data[ "data" ], "JSON results returned (POST, no callback)" ); - } + ajaxTest( "jQuery.ajax() - script, Remote with POST", 3, function( assert ) { + return { + setup: function() { + Globals.register( "testBar" ); }, - { - type: "POST", - url: "data/jsonp.php", - data: "callback=?", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data[ "data" ], "JSON results returned (POST, data callback)" ); - } + url: window.location.href.replace( /[^\/]*$/, "" ) + "data/testbar.php", + type: "POST", + dataType: "script", + success: function( data, status ) { + assert.strictEqual( window[ "testBar" ], "bar", "Script results returned (POST, no callback)" ); + assert.strictEqual( status, "success", "Script results returned (POST, no callback)" ); + } + }; + } ); + + ajaxTest( "jQuery.ajax() - script, Remote with scheme-less URL", 2, function( assert ) { + return { + setup: function() { + Globals.register( "testBar" ); }, - { - type: "POST", - url: "data/jsonp.php", - jsonp: "callback", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data[ "data" ], "JSON results returned (POST, data obj callback)" ); - } + url: window.location.href.replace( /[^\/]*$/, "" ).replace( /^.*?\/\//, "//" ) + "data/testbar.php", + dataType: "script", + success: function() { + assert.strictEqual( window[ "testBar" ], "bar", "Script results returned (GET, no callback)" ); + } + }; + } ); + + ajaxTest( "jQuery.ajax() - malformed JSON", 2, function( assert ) { + return { + url: "data/badjson.js", + dataType: "json", + error: function( xhr, msg, detailedMsg ) { + assert.strictEqual( msg, "parsererror", "A parse error occurred." ); + assert.ok( /(invalid|error|exception)/i.test( detailedMsg ), "Detailed parsererror message provided" ); } - ] ); + }; + } ); - ajaxTest( "jQuery.ajax() - JSONP" + label, 3, [ + ajaxTest( "jQuery.ajax() - script by content-type", 2, function() { + return [ { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - success: function( data ) { - ok( data.data, "JSON results returned (GET, no callback)" ); - } + url: "data/script.php", + data: { + "header": "script" + }, + success: true }, { - create: function( options ) { - var request = jQuery.ajax( options ), - promise = request.then( function( data ) { - ok( data.data, "first request: JSON results returned (GET, no callback)" ); - request = jQuery.ajax( this ).done( function( data ) { - ok( data.data, "this re-used: JSON results returned (GET, no callback)" ); - } ); - promise.abort = request.abort; - return request; - } ); - promise.abort = request.abort; - return promise; + url: "data/script.php", + data: { + "header": "ecma" }, - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, success: true } - ] ); - - } ); - - ajaxTest( "jQuery.ajax() - script, Remote", 2, { - setup: function() { - Globals.register( "testBar" ); - }, - url: window.location.href.replace( /[^\/]*$/, "" ) + "data/testbar.php", - dataType: "script", - success: function() { - strictEqual( window[ "testBar" ], "bar", "Script results returned (GET, no callback)" ); - } - } ); - - ajaxTest( "jQuery.ajax() - script, Remote with POST", 3, { - setup: function() { - Globals.register( "testBar" ); - }, - url: window.location.href.replace( /[^\/]*$/, "" ) + "data/testbar.php", - type: "POST", - dataType: "script", - success: function( data, status ) { - strictEqual( window[ "testBar" ], "bar", "Script results returned (POST, no callback)" ); - strictEqual( status, "success", "Script results returned (POST, no callback)" ); - } - } ); - - ajaxTest( "jQuery.ajax() - script, Remote with scheme-less URL", 2, { - setup: function() { - Globals.register( "testBar" ); - }, - url: window.location.href.replace( /[^\/]*$/, "" ).replace( /^.*?\/\//, "//" ) + "data/testbar.php", - dataType: "script", - success: function() { - strictEqual( window[ "testBar" ], "bar", "Script results returned (GET, no callback)" ); - } + ]; } ); - ajaxTest( "jQuery.ajax() - malformed JSON", 2, { - url: "data/badjson.js", - dataType: "json", - error: function( xhr, msg, detailedMsg ) { - strictEqual( msg, "parsererror", "A parse error occurred." ); - ok( /(invalid|error|exception)/i.test( detailedMsg ), "Detailed parsererror message provided" ); - } + ajaxTest( "jQuery.ajax() - JSON by content-type", 5, function( assert ) { + return { + url: "data/json.php", + data: { + "header": "json", + "json": "array" + }, + success: function( json ) { + assert.ok( json.length >= 2, "Check length" ); + assert.strictEqual( json[ 0 ][ "name" ], "John", "Check JSON: first, name" ); + assert.strictEqual( json[ 0 ][ "age" ], 21, "Check JSON: first, age" ); + assert.strictEqual( json[ 1 ][ "name" ], "Peter", "Check JSON: second, name" ); + assert.strictEqual( json[ 1 ][ "age" ], 25, "Check JSON: second, age" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - script by content-type", 2, [ - { - url: "data/script.php", + ajaxTest( "jQuery.ajax() - JSON by content-type disabled with options", 6, function( assert ) { + return { + url: url( "data/json.php" ), data: { - "header": "script" + "header": "json", + "json": "array" }, - success: true - }, - { - url: "data/script.php", - data: { - "header": "ecma" + contents: { + "json": false }, - success: true - } - ] ); - - ajaxTest( "jQuery.ajax() - JSON by content-type", 5, { - url: "data/json.php", - data: { - "header": "json", - "json": "array" - }, - success: function( json ) { - ok( json.length >= 2, "Check length" ); - strictEqual( json[ 0 ][ "name" ], "John", "Check JSON: first, name" ); - strictEqual( json[ 0 ][ "age" ], 21, "Check JSON: first, age" ); - strictEqual( json[ 1 ][ "name" ], "Peter", "Check JSON: second, name" ); - strictEqual( json[ 1 ][ "age" ], 25, "Check JSON: second, age" ); - } - } ); - - ajaxTest( "jQuery.ajax() - JSON by content-type disabled with options", 6, { - url: url( "data/json.php" ), - data: { - "header": "json", - "json": "array" - }, - contents: { - "json": false - }, - success: function( text ) { - strictEqual( typeof text, "string", "json wasn't auto-determined" ); - var json = jQuery.parseJSON( text ); - ok( json.length >= 2, "Check length" ); - strictEqual( json[ 0 ][ "name" ], "John", "Check JSON: first, name" ); - strictEqual( json[ 0 ][ "age" ], 21, "Check JSON: first, age" ); - strictEqual( json[ 1 ][ "name" ], "Peter", "Check JSON: second, name" ); - strictEqual( json[ 1 ][ "age" ], 25, "Check JSON: second, age" ); - } + success: function( text ) { + assert.strictEqual( typeof text, "string", "json wasn't auto-determined" ); + var json = jQuery.parseJSON( text ); + assert.ok( json.length >= 2, "Check length" ); + assert.strictEqual( json[ 0 ][ "name" ], "John", "Check JSON: first, name" ); + assert.strictEqual( json[ 0 ][ "age" ], 21, "Check JSON: first, age" ); + assert.strictEqual( json[ 1 ][ "name" ], "Peter", "Check JSON: second, name" ); + assert.strictEqual( json[ 1 ][ "age" ], 25, "Check JSON: second, age" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - simple get", 1, { - type: "GET", - url: url( "data/name.php?name=foo" ), - success: function( msg ) { - strictEqual( msg, "bar", "Check for GET" ); - } + ajaxTest( "jQuery.ajax() - simple get", 1, function( assert ) { + return { + type: "GET", + url: url( "data/name.php?name=foo" ), + success: function( msg ) { + assert.strictEqual( msg, "bar", "Check for GET" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - simple post", 1, { - type: "POST", - url: url( "data/name.php" ), - data: "name=peter", - success: function( msg ) { - strictEqual( msg, "pan", "Check for POST" ); - } + ajaxTest( "jQuery.ajax() - simple post", 1, function( assert ) { + return { + type: "POST", + url: url( "data/name.php" ), + data: "name=peter", + success: function( msg ) { + assert.strictEqual( msg, "pan", "Check for POST" ); + } + }; } ); - ajaxTest( "jQuery.ajax() - data option - empty bodies for non-GET requests", 1, { - url: "data/echoData.php", - data: undefined, - type: "post", - success: function( result ) { - strictEqual( result, "" ); - } + ajaxTest( "jQuery.ajax() - data option - empty bodies for non-GET requests", 1, function( assert ) { + return { + url: "data/echoData.php", + data: undefined, + type: "post", + success: function( result ) { + assert.strictEqual( result, "" ); + } + }; } ); var ifModifiedNow = new Date(); @@ -1031,105 +957,89 @@ module( "ajax", { " (no cache)": false }, function( label, cache ) { - asyncTest( "jQuery.ajax() - If-Modified-Since support" + label, 4, function() { - var url = "data/if_modified_since.php?ts=" + ifModifiedNow++; - - jQuery.ajax( { - url: url, - ifModified: true, - cache: cache, - success: function( data, status ) { - strictEqual( status, "success" ); - - jQuery.ajax( { - url: url, - ifModified: true, - cache: cache, - success: function( data, status, jqXHR ) { - strictEqual( status, "notmodified", "Following status is 'notmodified'" ); - strictEqual( jqXHR.status, 304, "XHR status is 304" ); - equal( data, null, "no response body is given" ); - }, - complete: function() { - start(); - } - } ); - } - } ); - } ); - - asyncTest( "jQuery.ajax() - Etag support" + label, 3, function() { - var url = "data/etag.php?ts=" + ifModifiedNow++; - - jQuery.ajax( { - url: url, - ifModified: true, - cache: cache, - success: function( data, status ) { - strictEqual( status, "success" ); - + jQuery.each( + { + "If-Modified-Since": "if_modified_since.php", + "Etag": "etag.php" + }, + function( type, url ) { + url = "data/" + url + "?ts=" + ifModifiedNow++; + QUnit.asyncTest( "jQuery.ajax() - " + type + " support" + label, 4, function( assert ) { jQuery.ajax( { url: url, ifModified: true, cache: cache, - success: function( data, status ) { - strictEqual( status, "notmodified" ); - ok( data == null, "response body should be empty" ); - }, - complete: function() { - start(); + success: function( _, status ) { + assert.strictEqual( status, "success", "Initial status is 'success'" ); + jQuery.ajax( { + url: url, + ifModified: true, + cache: cache, + success: function( data, status, jqXHR ) { + assert.strictEqual( status, "notmodified", "Following status is 'notmodified'" ); + assert.strictEqual( jqXHR.status, 304, "XHR status is 304" ); + assert.equal( data, null, "no response body is given" ); + }, + complete: function() { + QUnit.start(); + } + } ); } } ); - } - } ); - } ); + } ); + } + ); } /* jQuery.each arguments end */ ); - ajaxTest( "jQuery.ajax() - failing cross-domain (non-existing)", 1, { + ajaxTest( "jQuery.ajax() - failing cross-domain (non-existing)", 1, function( assert ) { + return { - // see RFC 2606 - url: "http://example.invalid", - error: function( xhr, _, e ) { - ok( true, "file not found: " + xhr.status + " => " + e ); - } + // see RFC 2606 + url: "http://example.invalid", + error: function( xhr, _, e ) { + assert.ok( true, "file not found: " + xhr.status + " => " + e ); + } + }; } ); - ajaxTest( "jQuery.ajax() - failing cross-domain", 1, { - url: "http://" + externalHost, - error: function( xhr, _, e ) { - ok( true, "access denied: " + xhr.status + " => " + e ); - } + ajaxTest( "jQuery.ajax() - failing cross-domain", 1, function( assert ) { + return { + url: "http://" + externalHost, + error: function( xhr, _, e ) { + assert.ok( true, "access denied: " + xhr.status + " => " + e ); + } + }; } ); - ajaxTest( "jQuery.ajax() - atom+xml", 1, { - url: url( "data/atom+xml.php" ), - success: function() { - ok( true, "success" ); - } + ajaxTest( "jQuery.ajax() - atom+xml", 1, function( assert ) { + return { + url: url( "data/atom+xml.php" ), + success: function() { + assert.ok( true, "success" ); + } + }; } ); - asyncTest( "jQuery.ajax() - statusText", 3, function() { + QUnit.asyncTest( "jQuery.ajax() - statusText", 3, function( assert ) { jQuery.ajax( url( "data/statusText.php?status=200&text=Hello" ) ).done( function( _, statusText, jqXHR ) { - strictEqual( statusText, "success", "callback status text ok for success" ); - ok( jqXHR.statusText === "Hello" || jqXHR.statusText === "OK", "jqXHR status text ok for success (" + jqXHR.statusText + ")" ); + assert.strictEqual( statusText, "success", "callback status text ok for success" ); + assert.ok( jqXHR.statusText === "Hello" || jqXHR.statusText === "OK", "jqXHR status text ok for success (" + jqXHR.statusText + ")" ); jQuery.ajax( url( "data/statusText.php?status=404&text=World" ) ).fail( function( jqXHR, statusText ) { - strictEqual( statusText, "error", "callback status text ok for error" ); - - // ok( jqXHR.statusText === "World" || jQuery.browser.safari && jqXHR.statusText === "Not Found", "jqXHR status text ok for error (" + jqXHR.statusText + ")" ); - start(); + assert.strictEqual( statusText, "error", "callback status text ok for error" ); + QUnit.start(); } ); } ); } ); - asyncTest( "jQuery.ajax() - statusCode", 20, function() { + QUnit.asyncTest( "jQuery.ajax() - statusCode", 20, function( assert ) { var count = 12; function countComplete() { if ( !--count ) { - start(); + QUnit.start(); } } @@ -1137,10 +1047,10 @@ module( "ajax", { name = "Test " + name + " " + ( isSuccess ? "success" : "error" ); return { 200: function() { - ok( isSuccess, name ); + assert.ok( isSuccess, name ); }, 404: function() { - ok( !isSuccess, name ); + assert.ok( !isSuccess, name ); } }; } @@ -1193,7 +1103,7 @@ module( "ajax", { jQuery.ajax( url( uri ), { success: function( a, b, jqXHR ) { - ok( isSuccess, "success" ); + assert.ok( isSuccess, "success" ); var statusCode = {}; statusCode[ jqXHR.status ] = function() { testString += "B"; @@ -1202,7 +1112,7 @@ module( "ajax", { testString += "A"; }, error: function( jqXHR ) { - ok( !isSuccess, "error" ); + assert.ok( !isSuccess, "error" ); var statusCode = {}; statusCode[ jqXHR.status ] = function() { testString += "B"; @@ -1211,7 +1121,7 @@ module( "ajax", { testString += "A"; }, complete: function() { - strictEqual( + assert.strictEqual( testString, "AB", "Test statusCode callbacks are ordered like " + ( isSuccess ? "success" : "error" ) + " callbacks" @@ -1225,105 +1135,115 @@ module( "ajax", { ); } ); - ajaxTest( "jQuery.ajax() - transitive conversions", 8, [ - { - url: url( "data/json.php" ), - converters: { - "json myJson": function( data ) { - ok( true, "converter called" ); - return data; + ajaxTest( "jQuery.ajax() - transitive conversions", 8, function( assert ) { + return [ + { + url: url( "data/json.php" ), + converters: { + "json myJson": function( data ) { + assert.ok( true, "converter called" ); + return data; + } + }, + dataType: "myJson", + success: function() { + assert.ok( true, "Transitive conversion worked" ); + assert.strictEqual( this.dataTypes[ 0 ], "text", "response was retrieved as text" ); + assert.strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType" ); } }, - dataType: "myJson", - success: function() { - ok( true, "Transitive conversion worked" ); - strictEqual( this.dataTypes[ 0 ], "text", "response was retrieved as text" ); - strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType" ); - } - }, - { - url: url( "data/json.php" ), - converters: { - "json myJson": function( data ) { - ok( true, "converter called (*)" ); - return data; + { + url: url( "data/json.php" ), + converters: { + "json myJson": function( data ) { + assert.ok( true, "converter called (*)" ); + return data; + } + }, + contents: false, /* headers are wrong so we ignore them */ + dataType: "* myJson", + success: function() { + assert.ok( true, "Transitive conversion worked (*)" ); + assert.strictEqual( this.dataTypes[ 0 ], "text", "response was retrieved as text (*)" ); + assert.strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType (*)" ); } - }, - contents: false, /* headers are wrong so we ignore them */ - dataType: "* myJson", - success: function() { - ok( true, "Transitive conversion worked (*)" ); - strictEqual( this.dataTypes[ 0 ], "text", "response was retrieved as text (*)" ); - strictEqual( this.dataTypes[ 1 ], "myjson", "request expected myjson dataType (*)" ); } - } - ] ); + ]; + } ); - ajaxTest( "jQuery.ajax() - overrideMimeType", 2, [ - { - url: url( "data/json.php" ), - beforeSend: function( xhr ) { - xhr.overrideMimeType( "application/json" ); + ajaxTest( "jQuery.ajax() - overrideMimeType", 2, function( assert ) { + return [ + { + url: url( "data/json.php" ), + beforeSend: function( xhr ) { + xhr.overrideMimeType( "application/json" ); + }, + success: function( json ) { + assert.ok( json.data, "Mimetype overridden using beforeSend" ); + } }, - success: function( json ) { - ok( json.data, "Mimetype overridden using beforeSend" ); - } - }, - { - url: url( "data/json.php" ), - mimeType: "application/json", - success: function( json ) { - ok( json.data, "Mimetype overridden using mimeType option" ); + { + url: url( "data/json.php" ), + mimeType: "application/json", + success: function( json ) { + assert.ok( json.data, "Mimetype overridden using mimeType option" ); + } } - } - ] ); + ]; + } ); - ajaxTest( "jQuery.ajax() - empty json gets to error callback instead of success callback.", 1, { - url: url( "data/echoData.php" ), - error: function( _, __, error ) { - equal( typeof error === "object", true, "Didn't get back error object for empty json response" ); - }, - dataType: "json" + ajaxTest( "jQuery.ajax() - empty json gets to error callback instead of success callback.", 1, function( assert ) { + return { + url: url( "data/echoData.php" ), + error: function( _, __, error ) { + assert.equal( typeof error === "object", true, "Didn't get back error object for empty json response" ); + }, + dataType: "json" + }; } ); - ajaxTest( "#2688 - jQuery.ajax() - beforeSend, cancel request", 2, { - create: function() { - return jQuery.ajax( { - url: url( "data/name.html" ), - beforeSend: function() { - ok( true, "beforeSend got called, canceling" ); - return false; - }, - success: function() { - ok( false, "request didn't get canceled" ); - }, - complete: function() { - ok( false, "request didn't get canceled" ); - }, - error: function() { - ok( false, "request didn't get canceled" ); - } - } ); - }, - fail: function( _, reason ) { - strictEqual( reason, "canceled", "canceled request must fail with 'canceled' status text" ); - } + ajaxTest( "#2688 - jQuery.ajax() - beforeSend, cancel request", 2, function( assert ) { + return { + create: function() { + return jQuery.ajax( { + url: url( "data/name.html" ), + beforeSend: function() { + assert.ok( true, "beforeSend got called, canceling" ); + return false; + }, + success: function() { + assert.ok( false, "request didn't get canceled" ); + }, + complete: function() { + assert.ok( false, "request didn't get canceled" ); + }, + error: function() { + assert.ok( false, "request didn't get canceled" ); + } + } ); + }, + fail: function( _, reason ) { + assert.strictEqual( reason, "canceled", "canceled request must fail with 'canceled' status text" ); + } + }; } ); - ajaxTest( "#2806 - jQuery.ajax() - data option - evaluate function values", 1, { - url: "data/echoQuery.php", - data: { - key: function() { - return "value"; + ajaxTest( "#2806 - jQuery.ajax() - data option - evaluate function values", 1, function( assert ) { + return { + url: "data/echoQuery.php", + data: { + key: function() { + return "value"; + } + }, + success: function( result ) { + assert.strictEqual( result, "key=value" ); } - }, - success: function( result ) { - strictEqual( result, "key=value" ); - } + }; } ); - test( "#7531 - jQuery.ajax() - Location object as url", function() { - expect( 1 ); + QUnit.test( "#7531 - jQuery.ajax() - Location object as url", function( assert ) { + assert.expect( 1 ); var xhr, success = false; @@ -1336,102 +1256,64 @@ module( "ajax", { } catch ( e ) { } - ok( success, "document.location did not generate exception" ); + assert.ok( success, "document.location did not generate exception" ); } ); jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) { - ajaxTest( "#7578 - jQuery.ajax() - JSONP - default for cache option" + label, 1, { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - beforeSend: function() { - strictEqual( this.cache, false, "cache must be false on JSON request" ); - return false; - }, - error: true + ajaxTest( "#7578 - jQuery.ajax() - JSONP - default for cache option" + label, 1, function( assert ) { + return { + url: "data/jsonp.php", + dataType: "jsonp", + crossDomain: crossDomain, + beforeSend: function() { + assert.strictEqual( this.cache, false, "cache must be false on JSON request" ); + return false; + }, + error: true + }; } ); } ); - ajaxTest( "#8107 - jQuery.ajax() - multiple method signatures introduced in 1.5", 4, [ - { - create: function() { - return jQuery.ajax(); - }, - done: function() { - ok( true, "With no arguments" ); - } - }, - { - create: function() { - return jQuery.ajax( "data/name.html" ); - }, - done: function() { - ok( true, "With only string URL argument" ); - } - }, - { - create: function() { - return jQuery.ajax( "data/name.html", {} ); + ajaxTest( "#8107 - jQuery.ajax() - multiple method signatures introduced in 1.5", 4, function( assert ) { + return [ + { + create: function() { + return jQuery.ajax(); + }, + done: function() { + assert.ok( true, "With no arguments" ); + } }, - done: function() { - ok( true, "With string URL param and map" ); - } - }, - { - create: function( options ) { - return jQuery.ajax( options ); + { + create: function() { + return jQuery.ajax( "data/name.html" ); + }, + done: function() { + assert.ok( true, "With only string URL argument" ); + } }, - url: "data/name.html", - success: function() { - ok( true, "With only map" ); - } - } - ] ); - - jQuery.each( [ " - Same Domain", " - Cross Domain" ], function( crossDomain, label ) { - ajaxTest( "#8205 - jQuery.ajax() - JSONP - re-use callbacks name" + label, 4, { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - beforeSend: function( jqXHR, s ) { - s.callback = s.jsonpCallback; - - ok( this.callback in window, "JSONP callback name is in the window" ); + { + create: function() { + return jQuery.ajax( "data/name.html", {} ); + }, + done: function() { + assert.ok( true, "With string URL param and map" ); + } }, - success: function() { - var previous = this; - - strictEqual( - previous.jsonpCallback, - undefined, - "jsonpCallback option is set back to default in callbacks" - ); - - if ( isIE8 ) { - ok( true, "IE8 can't remove property from the window" ); - - } else { - ok( - !( this.callback in window ), - "JSONP callback name was removed from the window" - ); + { + create: function( options ) { + return jQuery.ajax( options ); + }, + url: "data/name.html", + success: function() { + assert.ok( true, "With only map" ); } - - jQuery.ajax( { - url: "data/jsonp.php", - dataType: "jsonp", - crossDomain: crossDomain, - beforeSend: function() { - strictEqual( this.jsonpCallback, previous.callback, "JSONP callback name is re-used" ); - return false; - } - } ); } - } ); + ]; } ); - test( "#9887 - jQuery.ajax() - Context with circular references (#9887)", function() { - expect( 2 ); + QUnit.test( "#9887 - jQuery.ajax() - Context with circular references (#9887)", function( assert ) { + assert.expect( 2 ); var success = false, context = {}; @@ -1440,7 +1322,7 @@ module( "ajax", { jQuery.ajax( "non-existing", { context: context, beforeSend: function() { - ok( this === context, "context was not deep extended" ); + assert.ok( this === context, "context was not deep extended" ); return false; } } ); @@ -1448,252 +1330,309 @@ module( "ajax", { } catch ( e ) { console.log( e ); } - ok( success, "context with circular reference did not generate an exception" ); + assert.ok( success, "context with circular reference did not generate an exception" ); } ); jQuery.each( [ "as argument", "in settings object" ], function( inSetting, title ) { - function request( url, test ) { + function request( assert, url, test ) { return { create: function() { return jQuery.ajax( inSetting ? { url: url } : url ); }, done: function() { - ok( true, ( test || url ) + " " + title ); + assert.ok( true, ( test || url ) + " " + title ); } }; } - ajaxTest( "#10093 - jQuery.ajax() - falsy url " + title, 4, [ - request( "", "empty string" ), - request( false ), - request( null ), - request( undefined ) - ] ); - + ajaxTest( "#10093 - jQuery.ajax() - falsy url " + title, 4, function( assert ) { + return [ + request( assert, "", "empty string" ), + request( assert, false ), + request( assert, null ), + request( assert, undefined ) + ]; + } ); } ); - ajaxTest( "#11151 - jQuery.ajax() - parse error body", 2, { - url: url( "data/errorWithJSON.php" ), - dataFilter: function( string ) { - ok( false, "dataFilter called" ); - return string; - }, - error: function( jqXHR ) { - strictEqual( jqXHR.responseText, "{ \"code\": 40, \"message\": \"Bad Request\" }", "Error body properly set" ); - deepEqual( jqXHR.responseJSON, { code: 40, message: "Bad Request" }, "Error body properly parsed" ); - } + ajaxTest( "#11151 - jQuery.ajax() - parse error body", 2, function( assert ) { + return { + url: url( "data/errorWithJSON.php" ), + dataFilter: function( string ) { + assert.ok( false, "dataFilter called" ); + return string; + }, + error: function( jqXHR ) { + assert.strictEqual( jqXHR.responseText, "{ \"code\": 40, \"message\": \"Bad Request\" }", "Error body properly set" ); + assert.deepEqual( jqXHR.responseJSON, { code: 40, message: "Bad Request" }, "Error body properly parsed" ); + } + }; } ); - ajaxTest( "#11426 - jQuery.ajax() - loading binary data shouldn't throw an exception in IE", 1, { - url: url( "data/1x1.jpg" ), - success: function( data ) { - ok( data === undefined || /JFIF/.test( data ), "success callback reached" ); - } + ajaxTest( "#11426 - jQuery.ajax() - loading binary data shouldn't throw an exception in IE", 1, function( assert ) { + return { + url: url( "data/1x1.jpg" ), + success: function( data ) { + assert.ok( data === undefined || /JFIF/.test( data ), "success callback reached" ); + } + }; } ); - asyncTest( "#11743 - jQuery.ajax() - script, throws exception", 1, function() { + QUnit.asyncTest( "#11743 - jQuery.ajax() - script, throws exception", 1, function( assert ) { // Support: Android 2.3 only // Android 2.3 doesn't fire the window.onerror handler, just accept the reality there. if ( /android 2\.3/i.test( navigator.userAgent ) ) { - ok( true, "Test skipped, Android 2.3 doesn't fire window.onerror for " + + assert.ok( true, "Test skipped, Android 2.3 doesn't fire window.onerror for " + "errors in dynamically included scripts" ); - start(); + QUnit.start(); return; } var onerror = window.onerror; window.onerror = function() { - ok( true, "Exception thrown" ); + assert.ok( true, "Exception thrown" ); window.onerror = onerror; - start(); + QUnit.start(); }; jQuery.ajax( { url: "data/badjson.js", dataType: "script", - "throws": true + throws: true } ); } ); jQuery.each( [ "method", "type" ], function( _, globalOption ) { - - function request( option ) { + function request( assert, option ) { var options = { url: url( "data/echoData.php" ), data: "hello", success: function( msg ) { - strictEqual( msg, "hello", "Check for POST (no override)" ); + assert.strictEqual( msg, "hello", "Check for POST (no override)" ); } }; if ( option ) { options[ option ] = "GET"; options.success = function( msg ) { - strictEqual( msg, "", "Check for no POST (overriding with " + option + ")" ); + assert.strictEqual( msg, "", "Check for no POST (overriding with " + option + ")" ); }; } return options; } - ajaxTest( "#12004 - jQuery.ajax() - method is an alias of type - " + globalOption + " set globally", 3, { - setup: function() { - var options = {}; - options[ globalOption ] = "POST"; - jQuery.ajaxSetup( options ); - }, - requests: [ - request( "type" ), - request( "method" ), - request() - ] - } ); - + ajaxTest( + "#12004 - jQuery.ajax() - method is an alias of type - " + + globalOption + " set globally", 3, + function( assert ) { + return { + setup: function() { + var options = {}; + options[ globalOption ] = "POST"; + jQuery.ajaxSetup( options ); + }, + requests: [ + request( assert, "type" ), + request( assert, "method" ), + request( assert ) + ] + }; + } + ); } ); - ajaxTest( "#13276 - jQuery.ajax() - compatibility between XML documents from ajax requests and parsed string", 1, { - url: "data/dashboard.xml", - dataType: "xml", - success: function( ajaxXML ) { - var parsedXML = jQuery( jQuery.parseXML( "<tab title=\"Added\">blibli</tab>" ) ).find( "tab" ); - ajaxXML = jQuery( ajaxXML ); - try { - - // Android 2.3 doesn't automatically adopt nodes from foreign documents. - // (see the comment in test/manipulation.js) - // Support: Android 2.3 - if ( /android 2\.3/i.test( navigator.userAgent ) ) { - parsedXML = jQuery( ajaxXML[ 0 ].adoptNode( parsedXML[ 0 ] ) ); + ajaxTest( "#13276 - jQuery.ajax() - compatibility between XML documents from ajax requests and parsed string", 1, function( assert ) { + return { + url: "data/dashboard.xml", + dataType: "xml", + success: function( ajaxXML ) { + var parsedXML = jQuery( jQuery.parseXML( "<tab title=\"Added\">blibli</tab>" ) ).find( "tab" ); + ajaxXML = jQuery( ajaxXML ); + try { + + // Android 2.3 doesn't automatically adopt nodes from foreign documents. + // (see the comment in test/manipulation.js) + // Support: Android 2.3 + if ( /android 2\.3/i.test( navigator.userAgent ) ) { + parsedXML = jQuery( ajaxXML[ 0 ].adoptNode( parsedXML[ 0 ] ) ); + } + ajaxXML.find( "infowindowtab" ).append( parsedXML ); + } catch ( e ) { + assert.strictEqual( e, undefined, "error" ); + return; } - ajaxXML.find( "infowindowtab" ).append( parsedXML ); - } catch ( e ) { - strictEqual( e, undefined, "error" ); - return; + assert.strictEqual( ajaxXML.find( "tab" ).length, 3, "Parsed node was added properly" ); } - strictEqual( ajaxXML.find( "tab" ).length, 3, "Parsed node was added properly" ); - } + }; } ); - ajaxTest( "#13292 - jQuery.ajax() - converter is bypassed for 204 requests", 3, { - url: "data/nocontent.php", - dataType: "testing", - converters: { - "* testing": function() { - throw "converter was called"; + ajaxTest( "#13292 - jQuery.ajax() - converter is bypassed for 204 requests", 3, function( assert ) { + return { + url: "data/nocontent.php", + dataType: "testing", + converters: { + "* testing": function() { + throw "converter was called"; + } + }, + success: function( data, status, jqXHR ) { + assert.strictEqual( jqXHR.status, 204, "status code is 204" ); + assert.strictEqual( status, "nocontent", "status text is 'nocontent'" ); + assert.strictEqual( data, undefined, "data is undefined" ); + }, + error: function( _, status, error ) { + assert.ok( false, "error" ); + assert.strictEqual( status, "parsererror", "Parser Error" ); + assert.strictEqual( error, "converter was called", "Converter was called" ); } - }, - success: function( data, status, jqXHR ) { - strictEqual( jqXHR.status, 204, "status code is 204" ); - strictEqual( status, "nocontent", "status text is 'nocontent'" ); - strictEqual( data, undefined, "data is undefined" ); - }, - error: function( _, status, error ) { - ok( false, "error" ); - strictEqual( status, "parsererror", "Parser Error" ); - strictEqual( error, "converter was called", "Converter was called" ); - } + }; } ); - ajaxTest( "#13388 - jQuery.ajax() - responseXML", 3, { - url: url( "data/with_fries.xml" ), - dataType: "xml", - success: function( resp, _, jqXHR ) { - notStrictEqual( resp, undefined, "XML document exists" ); - ok( "responseXML" in jqXHR, "jqXHR.responseXML exists" ); - strictEqual( resp, jqXHR.responseXML, "jqXHR.responseXML is set correctly" ); - } + ajaxTest( "#13388 - jQuery.ajax() - responseXML", 3, function( assert ) { + return { + url: url( "data/with_fries.xml" ), + dataType: "xml", + success: function( resp, _, jqXHR ) { + assert.notStrictEqual( resp, undefined, "XML document exists" ); + assert.ok( "responseXML" in jqXHR, "jqXHR.responseXML exists" ); + assert.strictEqual( resp, jqXHR.responseXML, "jqXHR.responseXML is set correctly" ); + } + }; } ); - ajaxTest( "#13922 - jQuery.ajax() - converter is bypassed for HEAD requests", 3, { - url: "data/json.php", - method: "HEAD", - data: { - header: "yes" - }, - converters: { - "text json": function() { - throw "converter was called"; + ajaxTest( "#13922 - jQuery.ajax() - converter is bypassed for HEAD requests", 3, function( assert ) { + return { + url: "data/json.php", + method: "HEAD", + data: { + header: "yes" + }, + converters: { + "text json": function() { + throw "converter was called"; + } + }, + success: function( data, status ) { + assert.ok( true, "success" ); + assert.strictEqual( status, "nocontent", "data is undefined" ); + assert.strictEqual( data, undefined, "data is undefined" ); + }, + error: function( _, status, error ) { + assert.ok( false, "error" ); + assert.strictEqual( status, "parsererror", "Parser Error" ); + assert.strictEqual( error, "converter was called", "Converter was called" ); } - }, - success: function( data, status ) { - ok( true, "success" ); - strictEqual( status, "nocontent", "data is undefined" ); - strictEqual( data, undefined, "data is undefined" ); - }, - error: function( _, status, error ) { - ok( false, "error" ); - strictEqual( status, "parsererror", "Parser Error" ); - strictEqual( error, "converter was called", "Converter was called" ); - } + }; } ); + testIframeWithCallback( + "#14379 - jQuery.ajax() on unload", + "ajax/onunload.html", + function( status, assert ) { + assert.expect( 1 ); + assert.strictEqual( status, "success", "Request completed" ); + } + ); + // BrowserStack PATCH support sometimes breaks so on TestSwarm run the test in IE only. // Unfortunately, all IE versions gets special treatment in request object creation // so we need to test in all supported IE versions to be sure. if ( location.search.indexOf( "swarmURL=" ) === -1 || document.documentMode ) { - ajaxTest( "#13240 - jQuery.ajax() - support non-RFC2616 methods", 1, { - url: "data/echoQuery.php", - method: "PATCH", - success: function() { - ok( true, "success" ); - }, - error: function() { - ok( false, "error" ); - } - } ); + ajaxTest( "#13240 - jQuery.ajax() - support non-RFC2616 methods", 1, function( assert ) { + return { + url: "data/echoQuery.php", + method: "PATCH", + success: function() { + assert.ok( true, "success" ); + }, + error: function() { + assert.ok( false, "error" ); + } + }; + }); } - testIframeWithCallback( "#14379 - jQuery.ajax() on unload", "ajax/onunload.html", function( status ) { - expect( 1 ); - strictEqual( status, "success", "Request completed" ); - } ); + ajaxTest( "#14683 - jQuery.ajax() - Exceptions thrown synchronously by xhr.send should be caught", 4, function( assert ) { + return [ { + url: "data/params_html.php", + method: "POST", + data: { + toString: function() { + throw "Can't parse"; + } + }, + processData: false, + done: function( data ) { + assert.ok( false, "done: " + data ); + }, + fail: function( jqXHR, status, error ) { + assert.ok( true, "exception caught: " + error ); + assert.strictEqual( jqXHR.status, 0, "proper status code" ); + assert.strictEqual( status, "error", "proper status" ); + } + }, { + url: "http://domain.org:80d", + done: function( data ) { + assert.ok( false, "done: " + data ); + }, + fail: function( _, status, error ) { + assert.ok( true, "fail: " + status + " - " + error ); + } + } ]; + } + ); -//----------- jQuery.ajaxPrefilter() - ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, { - dataType: "prefix", - setup: function() { - // Ensure prefix does not throw an error - jQuery.ajaxPrefilter( "+prefix", function( options, _, jqXHR ) { - if ( options.abortInPrefilter ) { - jqXHR.abort(); - } - } ); - }, - abortInPrefilter: true, - error: function() { - ok( false, "error callback called" ); - }, - fail: function( _, reason ) { - strictEqual( reason, "canceled", "Request aborted by the prefilter must fail with 'canceled' status text" ); - } +// //----------- jQuery.ajaxPrefilter() + + ajaxTest( "jQuery.ajaxPrefilter() - abort", 1, function( assert ) { + return { + dataType: "prefix", + setup: function() { + + // Ensure prefix does not throw an error + jQuery.ajaxPrefilter( "+prefix", function( options, _, jqXHR ) { + if ( options.abortInPrefilter ) { + jqXHR.abort(); + } + } ); + }, + abortInPrefilter: true, + error: function() { + assert.ok( false, "error callback called" ); + }, + fail: function( _, reason ) { + assert.strictEqual( reason, "canceled", "Request aborted by the prefilter must fail with 'canceled' status text" ); + } + }; } ); //----------- jQuery.ajaxSetup() - asyncTest( "jQuery.ajaxSetup()", 1, function() { + QUnit.asyncTest( "jQuery.ajaxSetup()", 1, function( assert ) { jQuery.ajaxSetup( { url: url( "data/name.php?name=foo" ), success: function( msg ) { - strictEqual( msg, "bar", "Check for GET" ); - start(); + assert.strictEqual( msg, "bar", "Check for GET" ); + QUnit.start(); } } ); jQuery.ajax(); } ); - asyncTest( "jQuery.ajaxSetup({ timeout: Number }) - with global timeout", 2, function() { + QUnit.asyncTest( "jQuery.ajaxSetup({ timeout: Number }) - with global timeout", 2, function( assert ) { var passed = 0, pass = function() { - ok( passed++ < 2, "Error callback executed" ); + assert.ok( passed++ < 2, "Error callback executed" ); if ( passed === 2 ) { jQuery( document ).off( "ajaxError.setupTest" ); - start(); + QUnit.start(); } }, fail = function( a, b ) { - ok( false, "Check for timeout failed " + a + " " + b ); - start(); + assert.ok( false, "Check for timeout failed " + a + " " + b ); + QUnit.start(); }; jQuery( document ).on( "ajaxError.setupTest", pass ); @@ -1710,7 +1649,7 @@ module( "ajax", { } ); } ); - asyncTest( "jQuery.ajaxSetup({ timeout: Number }) with localtimeout", 1, function() { + QUnit.asyncTest( "jQuery.ajaxSetup({ timeout: Number }) with localtimeout", 1, function( assert ) { jQuery.ajaxSetup( { timeout: 50 } ); @@ -1719,27 +1658,27 @@ module( "ajax", { timeout: 15000, url: url( "data/name.php?wait=1" ), error: function() { - ok( false, "Check for local timeout failed" ); - start(); + assert.ok( false, "Check for local timeout failed" ); + QUnit.start(); }, success: function() { - ok( true, "Check for local timeout" ); - start(); + assert.ok( true, "Check for local timeout" ); + QUnit.start(); } } ); } ); //----------- jQuery.domManip() - test( "#11264 - jQuery.domManip() - no side effect because of ajaxSetup or global events", function() { - expect( 1 ); + QUnit.test( "#11264 - jQuery.domManip() - no side effect because of ajaxSetup or global events", function( assert ) { + assert.expect( 1 ); jQuery.ajaxSetup( { type: "POST" } ); jQuery( document ).on( "ajaxStart ajaxStop", function() { - ok( false, "Global event triggered" ); + assert.ok( false, "Global event triggered" ); } ); jQuery( "#qunit-fixture" ).append( "<script src='data/ajax/evalScript.php'></script>" ); @@ -1747,251 +1686,238 @@ module( "ajax", { jQuery( document ).off( "ajaxStart ajaxStop" ); } ); - asyncTest( "jQuery#load() - always use GET method even if it overrided through ajaxSetup (#11264)", 1, function() { + QUnit.asyncTest( "jQuery#load() - always use GET method even if it overrided through ajaxSetup (#11264)", 1, function( assert ) { jQuery.ajaxSetup( { type: "POST" } ); jQuery( "#qunit-fixture" ).load( "data/ajax/method.php", function( method ) { - equal( method, "GET" ); - start(); + assert.equal( method, "GET" ); + QUnit.start(); } ); } ); - asyncTest( "#11402 - jQuery.domManip() - script in comments are properly evaluated", 2, function() { + QUnit.asyncTest( "#11402 - jQuery.domManip() - script in comments are properly evaluated", 2, function() { jQuery( "#qunit-fixture" ).load( "data/cleanScript.html", start ); } ); //----------- jQuery.get() - asyncTest( "jQuery.get( String, Hash, Function ) - parse xml and use text() on nodes", 2, function() { + QUnit.asyncTest( "jQuery.get( String, Hash, Function ) - parse xml and use text() on nodes", 2, function( assert ) { jQuery.get( url( "data/dashboard.xml" ), function( xml ) { var content = []; jQuery( "tab", xml ).each( function() { content.push( jQuery( this ).text() ); } ); - strictEqual( content[ 0 ], "blabla", "Check first tab" ); - strictEqual( content[ 1 ], "blublu", "Check second tab" ); - start(); + assert.strictEqual( content[ 0 ], "blabla", "Check first tab" ); + assert.strictEqual( content[ 1 ], "blublu", "Check second tab" ); + QUnit.start(); } ); } ); - asyncTest( "#8277 - jQuery.get( String, Function ) - data in ajaxSettings", 1, function() { + QUnit.asyncTest( "#8277 - jQuery.get( String, Function ) - data in ajaxSettings", 1, function( assert ) { jQuery.ajaxSetup( { data: "helloworld" } ); jQuery.get( url( "data/echoQuery.php" ), function( data ) { - ok( /helloworld$/.test( data ), "Data from ajaxSettings was used" ); - start(); + assert.ok( /helloworld$/.test( data ), "Data from ajaxSettings was used" ); + QUnit.start(); } ); } ); //----------- jQuery.getJSON() - asyncTest( "jQuery.getJSON( String, Hash, Function ) - JSON array", 5, function() { + QUnit.asyncTest( "jQuery.getJSON( String, Hash, Function ) - JSON array", 5, function( assert ) { jQuery.getJSON( url( "data/json.php" ), { "json": "array" }, function( json ) { - ok( json.length >= 2, "Check length" ); - strictEqual( json[ 0 ][ "name" ], "John", "Check JSON: first, name" ); - strictEqual( json[ 0 ][ "age" ], 21, "Check JSON: first, age" ); - strictEqual( json[ 1 ][ "name" ], "Peter", "Check JSON: second, name" ); - strictEqual( json[ 1 ][ "age" ], 25, "Check JSON: second, age" ); - start(); + assert.ok( json.length >= 2, "Check length" ); + assert.strictEqual( json[ 0 ][ "name" ], "John", "Check JSON: first, name" ); + assert.strictEqual( json[ 0 ][ "age" ], 21, "Check JSON: first, age" ); + assert.strictEqual( json[ 1 ][ "name" ], "Peter", "Check JSON: second, name" ); + assert.strictEqual( json[ 1 ][ "age" ], 25, "Check JSON: second, age" ); + QUnit.start(); } ); } ); - asyncTest( "jQuery.getJSON( String, Function ) - JSON object", 2, function() { + QUnit.asyncTest( "jQuery.getJSON( String, Function ) - JSON object", 2, function( assert ) { jQuery.getJSON( url( "data/json.php" ), function( json ) { if ( json && json[ "data" ] ) { - strictEqual( json[ "data" ][ "lang" ], "en", "Check JSON: lang" ); - strictEqual( json[ "data" ].length, 25, "Check JSON: length" ); - start(); + assert.strictEqual( json[ "data" ][ "lang" ], "en", "Check JSON: lang" ); + assert.strictEqual( json[ "data" ].length, 25, "Check JSON: length" ); + QUnit.start(); } } ); } ); - asyncTest( "jQuery.getJSON() - Using Native JSON", 2, function() { - var restore = "JSON" in window, - old = window.JSON; - if ( !restore ) { - Globals.register( "JSON" ); - } - window.JSON = { - parse: function() { - ok( true, "Verifying that parse method was run" ); - window.JSON = old; - return true; - } - }; - jQuery.getJSON( url( "data/json.php" ), function( json ) { - strictEqual( json, true, "Verifying return value" ); - start(); - } ); - } ); - - asyncTest( "jQuery.getJSON( String, Function ) - JSON object with absolute url to local content", 2, function() { + QUnit.asyncTest( "jQuery.getJSON( String, Function ) - JSON object with absolute url to local content", 2, function( assert ) { jQuery.getJSON( url( window.location.href.replace( /[^\/]*$/, "" ) + "data/json.php" ), function( json ) { - strictEqual( json.data.lang, "en", "Check JSON: lang" ); - strictEqual( json.data.length, 25, "Check JSON: length" ); - start(); + assert.strictEqual( json.data.lang, "en", "Check JSON: lang" ); + assert.strictEqual( json.data.length, 25, "Check JSON: length" ); + QUnit.start(); } ); } ); //----------- jQuery.getScript() - asyncTest( "jQuery.getScript( String, Function ) - with callback", 2, function() { + QUnit.asyncTest( "jQuery.getScript( String, Function ) - with callback", 2, function( assert ) { Globals.register( "testBar" ); jQuery.getScript( url( "data/testbar.php" ), function() { - strictEqual( window[ "testBar" ], "bar", "Check if script was evaluated" ); - start(); + assert.strictEqual( window[ "testBar" ], "bar", "Check if script was evaluated" ); + QUnit.start(); } ); } ); - asyncTest( "jQuery.getScript( String, Function ) - no callback", 1, function() { + QUnit.asyncTest( "jQuery.getScript( String, Function ) - no callback", 1, function() { Globals.register( "testBar" ); jQuery.getScript( url( "data/testbar.php" ) ).done( start ); } ); - asyncTest( "#8082 - jQuery.getScript( String, Function ) - source as responseText", 2, function() { + QUnit.asyncTest( "#8082 - jQuery.getScript( String, Function ) - source as responseText", 2, function( assert ) { Globals.register( "testBar" ); jQuery.getScript( url( "data/testbar.php" ), function( data, _, jqXHR ) { - strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script" ); - start(); + assert.strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script" ); + QUnit.start(); } ); } ); -//----------- jQuery.fn.load() +// //----------- jQuery.fn.load() // check if load can be called with only url - asyncTest( "jQuery.fn.load( String )", 2, function() { + QUnit.asyncTest( "jQuery.fn.load( String )", 2, function( assert ) { jQuery.ajaxSetup( { beforeSend: function() { - strictEqual( this.type, "GET", "no data means GET request" ); + assert.strictEqual( this.type, "GET", "no data means GET request" ); } } ); jQuery( "#first" ).load( "data/name.html", start ); } ); - asyncTest( "jQuery.fn.load() - 404 error callbacks", 6, function() { - addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError" )(); - jQuery( document ).ajaxStop( start ); + QUnit.test( "jQuery.fn.load() - 404 error callbacks", function( assert ) { + assert.expect( 6 ); + var done = assert.async(); + + addGlobalEvents( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError", assert )(); + jQuery( document ).ajaxStop( done ); jQuery( "<div/>" ).load( "data/404.html", function() { - ok( true, "complete" ); + assert.ok( true, "complete" ); } ); } ); // check if load can be called with url and null data - asyncTest( "jQuery.fn.load( String, null )", 2, function() { + QUnit.asyncTest( "jQuery.fn.load( String, null )", 2, function( assert ) { jQuery.ajaxSetup( { beforeSend: function() { - strictEqual( this.type, "GET", "no data means GET request" ); + assert.strictEqual( this.type, "GET", "no data means GET request" ); } } ); jQuery( "#first" ).load( "data/name.html", null, start ); } ); // check if load can be called with url and undefined data - asyncTest( "jQuery.fn.load( String, undefined )", 2, function() { + QUnit.asyncTest( "jQuery.fn.load( String, undefined )", 2, function( assert ) { jQuery.ajaxSetup( { beforeSend: function() { - strictEqual( this.type, "GET", "no data means GET request" ); + assert.strictEqual( this.type, "GET", "no data means GET request" ); } } ); jQuery( "#first" ).load( "data/name.html", undefined, start ); } ); // check if load can be called with only url - asyncTest( "jQuery.fn.load( URL_SELECTOR )", 1, function() { + QUnit.asyncTest( "jQuery.fn.load( URL_SELECTOR )", 1, function( assert ) { jQuery( "#first" ).load( "data/test3.html div.user", function() { - strictEqual( jQuery( this ).children( "div" ).length, 2, "Verify that specific elements were injected" ); - start(); + assert.strictEqual( jQuery( this ).children( "div" ).length, 2, "Verify that specific elements were injected" ); + QUnit.start(); } ); } ); // Selector should be trimmed to avoid leading spaces (#14773) - asyncTest( "jQuery.fn.load( URL_SELECTOR with spaces )", 1, function() { + QUnit.asyncTest( "jQuery.fn.load( URL_SELECTOR with spaces )", 1, function( assert ) { jQuery( "#first" ).load( "data/test3.html #superuser ", function() { - strictEqual( jQuery( this ).children( "div" ).length, 1, "Verify that specific elements were injected" ); - start(); + assert.strictEqual( jQuery( this ).children( "div" ).length, 1, "Verify that specific elements were injected" ); + QUnit.start(); } ); } ); - asyncTest( "jQuery.fn.load( String, Function ) - simple: inject text into DOM", 2, function() { + QUnit.asyncTest( "jQuery.fn.load( String, Function ) - simple: inject text into DOM", 2, function( assert ) { jQuery( "#first" ).load( url( "data/name.html" ), function() { - ok( /^ERROR/.test( jQuery( "#first" ).text() ), "Check if content was injected into the DOM" ); - start(); + assert.ok( /^ERROR/.test( jQuery( "#first" ).text() ), "Check if content was injected into the DOM" ); + QUnit.start(); } ); } ); - asyncTest( "jQuery.fn.load( String, Function ) - check scripts", 7, function() { + QUnit.asyncTest( "jQuery.fn.load( String, Function ) - check scripts", 7, function( assert ) { var verifyEvaluation = function() { - strictEqual( window[ "testBar" ], "bar", "Check if script src was evaluated after load" ); - strictEqual( jQuery( "#ap" ).html(), "bar", "Check if script evaluation has modified DOM" ); - start(); + assert.strictEqual( window[ "testBar" ], "bar", "Check if script src was evaluated after load" ); + assert.strictEqual( jQuery( "#ap" ).html(), "bar", "Check if script evaluation has modified DOM" ); + QUnit.start(); }; Globals.register( "testFoo" ); Globals.register( "testBar" ); jQuery( "#first" ).load( url( "data/test.html" ), function() { - ok( jQuery( "#first" ).html().match( /^html text/ ), "Check content after loading html" ); - strictEqual( jQuery( "#foo" ).html(), "foo", "Check if script evaluation has modified DOM" ); - strictEqual( window[ "testFoo" ], "foo", "Check if script was evaluated after load" ); + assert.ok( jQuery( "#first" ).html().match( /^html text/ ), "Check content after loading html" ); + assert.strictEqual( jQuery( "#foo" ).html(), "foo", "Check if script evaluation has modified DOM" ); + assert.strictEqual( window[ "testFoo" ], "foo", "Check if script was evaluated after load" ); setTimeout( verifyEvaluation, 600 ); } ); } ); - asyncTest( "jQuery.fn.load( String, Function ) - check file with only a script tag", 3, function() { + QUnit.asyncTest( "jQuery.fn.load( String, Function ) - check file with only a script tag", 3, function( assert ) { Globals.register( "testFoo" ); jQuery( "#first" ).load( url( "data/test2.html" ), function() { - strictEqual( jQuery( "#foo" ).html(), "foo", "Check if script evaluation has modified DOM" ); - strictEqual( window[ "testFoo" ], "foo", "Check if script was evaluated after load" ); - start(); + assert.strictEqual( jQuery( "#foo" ).html(), "foo", "Check if script evaluation has modified DOM" ); + assert.strictEqual( window[ "testFoo" ], "foo", "Check if script was evaluated after load" ); + QUnit.start(); } ); } ); - asyncTest( "jQuery.fn.load( String, Function ) - dataFilter in ajaxSettings", 2, function() { + QUnit.asyncTest( "jQuery.fn.load( String, Function ) - dataFilter in ajaxSettings", 2, function( assert ) { jQuery.ajaxSetup( { dataFilter: function() { return "Hello World"; } } ); jQuery( "<div/>" ).load( url( "data/name.html" ), function( responseText ) { - strictEqual( jQuery( this ).html(), "Hello World", "Test div was filled with filtered data" ); - strictEqual( responseText, "Hello World", "Test callback receives filtered data" ); - start(); + assert.strictEqual( jQuery( this ).html(), "Hello World", "Test div was filled with filtered data" ); + assert.strictEqual( responseText, "Hello World", "Test callback receives filtered data" ); + QUnit.start(); } ); } ); - asyncTest( "jQuery.fn.load( String, Object, Function )", 2, function() { + QUnit.asyncTest( "jQuery.fn.load( String, Object, Function )", 2, function( assert ) { jQuery( "<div />" ).load( url( "data/params_html.php" ), { "foo": 3, "bar": "ok" }, function() { var $post = jQuery( this ).find( "#post" ); - strictEqual( $post.find( "#foo" ).text(), "3", "Check if a hash of data is passed correctly" ); - strictEqual( $post.find( "#bar" ).text(), "ok", "Check if a hash of data is passed correctly" ); - start(); + assert.strictEqual( $post.find( "#foo" ).text(), "3", "Check if a hash of data is passed correctly" ); + assert.strictEqual( $post.find( "#bar" ).text(), "ok", "Check if a hash of data is passed correctly" ); + QUnit.start(); } ); } ); - asyncTest( "jQuery.fn.load( String, String, Function )", 2, function() { + QUnit.test( "jQuery.fn.load( String, String, Function )", 2, function( assert ) { + var done = assert.async(); + jQuery( "<div />" ).load( url( "data/params_html.php" ), "foo=3&bar=ok", function() { var $get = jQuery( this ).find( "#get" ); - strictEqual( $get.find( "#foo" ).text(), "3", "Check if a string of data is passed correctly" ); - strictEqual( $get.find( "#bar" ).text(), "ok", "Check if a of data is passed correctly" ); - start(); + assert.strictEqual( $get.find( "#foo" ).text(), "3", "Check if a string of data is passed correctly" ); + assert.strictEqual( $get.find( "#bar" ).text(), "ok", "Check if a of data is passed correctly" ); + done(); } ); } ); - asyncTest( "jQuery.fn.load() - callbacks get the correct parameters", 8, function() { + QUnit.test( "jQuery.fn.load() - callbacks get the correct parameters", 8, function( assert ) { var completeArgs = {}; + var done = assert.async(); jQuery.ajaxSetup( { success: function( _, status, jqXHR ) { @@ -2018,30 +1944,34 @@ module( "ajax", { return jQuery.Deferred( function( defer ) { jQuery( "#foo" ).load( options.url, function() { var args = arguments; - strictEqual( completeArgs[ options.url ].length, args.length, "same number of arguments (" + options.type + ")" ); + assert.strictEqual( completeArgs[ options.url ].length, args.length, "same number of arguments (" + options.type + ")" ); jQuery.each( completeArgs[ options.url ], function( i, value ) { - strictEqual( args[ i ], value, "argument #" + i + " is the same (" + options.type + ")" ); + assert.strictEqual( args[ i ], value, "argument #" + i + " is the same (" + options.type + ")" ); } ); defer.resolve(); } ); } ); } ) - ).always( start ); + ).always( done ); } ); - asyncTest( "#2046 - jQuery.fn.load( String, Function ) with ajaxSetup on dataType json", 1, function() { + QUnit.test( "#2046 - jQuery.fn.load( String, Function ) with ajaxSetup on dataType json", 1, function( assert ) { + var done = assert.async(); + jQuery.ajaxSetup( { dataType: "json" } ); jQuery( document ).ajaxComplete( function( e, xml, s ) { - strictEqual( s.dataType, "html", "Verify the load() dataType was html" ); + assert.strictEqual( s.dataType, "html", "Verify the load() dataType was html" ); jQuery( document ).off( "ajaxComplete" ); - start(); + done(); } ); jQuery( "#first" ).load( "data/test3.html" ); } ); - asyncTest( "#10524 - jQuery.fn.load() - data specified in ajaxSettings is merged in", 1, function() { + QUnit.test( "#10524 - jQuery.fn.load() - data specified in ajaxSettings is merged in", 1, function( assert ) { + var done = assert.async(); + var data = { "baz": 1 }; @@ -2052,14 +1982,16 @@ module( "ajax", { } ); jQuery( "#foo" ).load( "data/echoQuery.php", data ); jQuery( document ).ajaxComplete( function( event, jqXHR, options ) { - ok( ~options.data.indexOf( "foo=bar" ), "Data from ajaxSettings was used" ); - start(); + assert.ok( ~options.data.indexOf( "foo=bar" ), "Data from ajaxSettings was used" ); + done(); } ); } ); -//----------- jQuery.post() +// //----------- jQuery.post() + + QUnit.test( "jQuery.post() - data", 3, function( assert ) { + var done = assert.async(); - asyncTest( "jQuery.post() - data", 3, function() { jQuery.when( jQuery.post( url( "data/name.php" ), @@ -2069,8 +2001,8 @@ module( "ajax", { }, function( xml ) { jQuery( "math", xml ).each( function() { - strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); - strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" ); + assert.strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); + assert.strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" ); } ); } ), @@ -2084,15 +2016,17 @@ module( "ajax", { } }, success: function( data ) { - strictEqual( data, "test%5Blength%5D=7&test%5Bfoo%5D=bar", "Check if a sub-object with a length param is serialized correctly" ); + assert.strictEqual( data, "test%5Blength%5D=7&test%5Bfoo%5D=bar", "Check if a sub-object with a length param is serialized correctly" ); } } ) ).always( function() { - start(); + done(); } ); } ); - asyncTest( "jQuery.post( String, Hash, Function ) - simple with xml", 4, function() { + QUnit.test( "jQuery.post( String, Hash, Function ) - simple with xml", 4, function( assert ) { + var done = assert.async(); + jQuery.when( jQuery.post( url( "data/name.php" ), @@ -2101,23 +2035,25 @@ module( "ajax", { }, function( xml ) { jQuery( "math", xml ).each( function() { - strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); - strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" ); + assert.strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); + assert.strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" ); } ); } ), jQuery.post( url( "data/name.php?xml=5-2" ), {}, function( xml ) { jQuery( "math", xml ).each( function() { - strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); - strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" ); + assert.strictEqual( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); + assert.strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" ); } ); } ) ).always( function() { - start(); + done(); } ); } ); - asyncTest( "jQuery[get|post]( options ) - simple with xml", 2, function() { + QUnit.test( "jQuery[get|post]( options ) - simple with xml", 2, function( assert ) { + var done = assert.async(); + jQuery.when.apply( jQuery, jQuery.map( [ "get", "post" ], function( method ) { return jQuery[ method ]( { @@ -2127,22 +2063,21 @@ module( "ajax", { }, success: function( xml ) { jQuery( "math", xml ).each( function() { - strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" ); + assert.strictEqual( jQuery( "result", this ).text(), "3", "Check for XML" ); } ); } } ); } ) ).always( function() { - start(); + done(); } ); } ); //----------- jQuery.active - test( "jQuery.active", function() { - expect( 1 ); - - ok( jQuery.active === 0, "ajax active counter should be zero: " + jQuery.active ); + QUnit.test( "jQuery.active", function( assert ) { + assert.expect( 1 ); + assert.ok( jQuery.active === 0, "ajax active counter should be zero: " + jQuery.active ); } ); } )(); diff --git a/test/unit/animation.js b/test/unit/animation.js index 3aae7eab1..78db5f31b 100644 --- a/test/unit/animation.js +++ b/test/unit/animation.js @@ -11,7 +11,7 @@ var oldRaf = window.requestAnimationFrame, startTime = 505877050; // This module tests jQuery.Animation and the corresponding 1.8+ effects APIs -module( "animation", { +QUnit.module( "animation", { setup: function() { window.requestAnimationFrame = null; this.sandbox = sinon.sandbox.create(); @@ -34,77 +34,83 @@ module( "animation", { } } ); -test( "Animation( subject, props, opts ) - shape", function() { - expect( 20 ); +QUnit.test( "Animation( subject, props, opts ) - shape", function( assert ) { + assert.expect( 20 ); var subject = { test: 0 }, props = { test: 1 }, opts = { queue: "fx", duration: 100 }, animation = jQuery.Animation( subject, props, opts ); - equal( animation.elem, subject, ".elem is set to the exact object passed" ); - equal( animation.originalOptions, opts, ".originalOptions is set to options passed" ); - equal( animation.originalProperties, props, ".originalProperties is set to props passed" ); + assert.equal( animation.elem, subject, ".elem is set to the exact object passed" ); + assert.equal( animation.originalOptions, opts, ".originalOptions is set to options passed" ); + assert.equal( + animation.originalProperties, props, ".originalProperties is set to props passed" + ); - notEqual( animation.props, props, ".props is not the original however" ); - deepEqual( animation.props, props, ".props is a copy of the original" ); + assert.notEqual( animation.props, props, ".props is not the original however" ); + assert.deepEqual( animation.props, props, ".props is a copy of the original" ); - deepEqual( animation.opts, { + assert.deepEqual( animation.opts, { duration: 100, queue: "fx", specialEasing: { test: undefined }, easing: jQuery.easing._default }, ".options is filled with default easing and specialEasing" ); - equal( animation.startTime, startTime, "startTime was set" ); - equal( animation.duration, 100, ".duration is set" ); + assert.equal( animation.startTime, startTime, "startTime was set" ); + assert.equal( animation.duration, 100, ".duration is set" ); - equal( animation.tweens.length, 1, ".tweens has one Tween" ); - equal( typeof animation.tweens[ 0 ].run, "function", "which has a .run function" ); + assert.equal( animation.tweens.length, 1, ".tweens has one Tween" ); + assert.equal( typeof animation.tweens[ 0 ].run, "function", "which has a .run function" ); - equal( typeof animation.createTween, "function", ".createTween is a function" ); - equal( typeof animation.stop, "function", ".stop is a function" ); + assert.equal( typeof animation.createTween, "function", ".createTween is a function" ); + assert.equal( typeof animation.stop, "function", ".stop is a function" ); - equal( typeof animation.done, "function", ".done is a function" ); - equal( typeof animation.fail, "function", ".fail is a function" ); - equal( typeof animation.always, "function", ".always is a function" ); - equal( typeof animation.progress, "function", ".progress is a function" ); + assert.equal( typeof animation.done, "function", ".done is a function" ); + assert.equal( typeof animation.fail, "function", ".fail is a function" ); + assert.equal( typeof animation.always, "function", ".always is a function" ); + assert.equal( typeof animation.progress, "function", ".progress is a function" ); - equal( jQuery.timers.length, 1, "Added a timers function" ); - equal( jQuery.timers[ 0 ].elem, subject, "...with .elem as the subject" ); - equal( jQuery.timers[ 0 ].anim, animation, "...with .anim as the animation" ); - equal( jQuery.timers[ 0 ].queue, opts.queue, "...with .queue" ); + assert.equal( jQuery.timers.length, 1, "Added a timers function" ); + assert.equal( jQuery.timers[ 0 ].elem, subject, "...with .elem as the subject" ); + assert.equal( jQuery.timers[ 0 ].anim, animation, "...with .anim as the animation" ); + assert.equal( jQuery.timers[ 0 ].queue, opts.queue, "...with .queue" ); // Cleanup after ourselves by ticking to the end this.clock.tick( 100 ); } ); -test( "Animation.prefilter( fn ) - calls prefilter after defaultPrefilter", function() { - expect( 1 ); +QUnit.test( "Animation.prefilter( fn ) - calls prefilter after defaultPrefilter", + function( assert ) { + assert.expect( 1 ); - var prefilter = this.sandbox.stub(), - defaultSpy = this.sandbox.spy( jQuery.Animation.prefilters, 0 ); + var prefilter = this.sandbox.stub(), + defaultSpy = this.sandbox.spy( jQuery.Animation.prefilters, 0 ); - jQuery.Animation.prefilter( prefilter ); + jQuery.Animation.prefilter( prefilter ); - jQuery.Animation( {}, {}, {} ); - ok( prefilter.calledAfter( defaultSpy ), "our prefilter called after" ); -} ); + jQuery.Animation( {}, {}, {} ); + assert.ok( prefilter.calledAfter( defaultSpy ), "our prefilter called after" ); + } +); -test( "Animation.prefilter( fn, true ) - calls prefilter before defaultPrefilter", function() { - expect( 1 ); +QUnit.test( "Animation.prefilter( fn, true ) - calls prefilter before defaultPrefilter", + function( assert ) { + assert.expect( 1 ); - var prefilter = this.sandbox.stub(), - defaultSpy = this.sandbox.spy( jQuery.Animation.prefilters, 0 ); + var prefilter = this.sandbox.stub(), + defaultSpy = this.sandbox.spy( jQuery.Animation.prefilters, 0 ); - jQuery.Animation.prefilter( prefilter, true ); + jQuery.Animation.prefilter( prefilter, true ); - jQuery.Animation( {}, {}, {} ); - ok( prefilter.calledBefore( defaultSpy ), "our prefilter called before" ); -} ); + jQuery.Animation( {}, {}, {} ); + assert.ok( prefilter.calledBefore( defaultSpy ), "our prefilter called before" ); + } +); -test( "Animation.prefilter - prefilter return hooks", function() { - expect( 34 ); +QUnit.test( "Animation.prefilter - prefilter return hooks", function( assert ) { + assert.expect( 34 ); var animation, realAnimation, element, sandbox = this.sandbox, @@ -116,10 +122,10 @@ test( "Animation.prefilter - prefilter return hooks", function() { realAnimation = this; sandbox.spy( realAnimation, "createTween" ); - deepEqual( realAnimation.originalProperties, props, "originalProperties" ); - equal( arguments[ 0 ], this.elem, "first param elem" ); - equal( arguments[ 1 ], this.props, "second param props" ); - equal( arguments[ 2 ], this.opts, "third param opts" ); + assert.deepEqual( realAnimation.originalProperties, props, "originalProperties" ); + assert.equal( arguments[ 0 ], this.elem, "first param elem" ); + assert.equal( arguments[ 1 ], this.props, "second param props" ); + assert.equal( arguments[ 2 ], this.opts, "third param opts" ); return ourAnimation; } ), defaultSpy = sandbox.spy( jQuery.Animation.prefilters, 0 ), @@ -134,14 +140,18 @@ test( "Animation.prefilter - prefilter return hooks", function() { animation = jQuery.Animation( target, props, opts ); - equal( prefilter.callCount, 1, "Called prefilter" ); + assert.equal( prefilter.callCount, 1, "Called prefilter" ); - equal( defaultSpy.callCount, 0, + assert.equal( defaultSpy.callCount, 0, "Returning something from a prefilter caused remaining prefilters to not run" ); - equal( jQuery.fx.timer.callCount, 0, "Returning something never queues a timer" ); - equal( animation, ourAnimation, "Returning something returned it from jQuery.Animation" ); - equal( realAnimation.createTween.callCount, 0, "Returning something never creates tweens" ); - equal( TweenSpy.callCount, 0, "Returning something never creates tweens" ); + assert.equal( jQuery.fx.timer.callCount, 0, "Returning something never queues a timer" ); + assert.equal( + animation, ourAnimation, "Returning something returned it from jQuery.Animation" + ); + assert.equal( + realAnimation.createTween.callCount, 0, "Returning something never creates tweens" + ); + assert.equal( TweenSpy.callCount, 0, "Returning something never creates tweens" ); // Test overriden usage on queues: prefilter.reset(); @@ -154,78 +164,83 @@ test( "Animation.prefilter - prefilter return hooks", function() { .animate( props, 100 ) .queue( queueSpy ); - equal( prefilter.callCount, 1, "Called prefilter" ); - equal( queueSpy.callCount, 0, "Next function in queue not called" ); + assert.equal( prefilter.callCount, 1, "Called prefilter" ); + assert.equal( queueSpy.callCount, 0, "Next function in queue not called" ); realAnimation.opts.complete.call( realAnimation.elem ); - equal( queueSpy.callCount, 1, "Next function in queue called after complete" ); + assert.equal( queueSpy.callCount, 1, "Next function in queue called after complete" ); - equal( prefilter.callCount, 2, "Called prefilter again - animation #2" ); - equal( ourAnimation.stop.callCount, 0, ".stop() on our animation hasn't been called" ); + assert.equal( prefilter.callCount, 2, "Called prefilter again - animation #2" ); + assert.equal( ourAnimation.stop.callCount, 0, ".stop() on our animation hasn't been called" ); element.stop(); - equal( ourAnimation.stop.callCount, 1, ".stop() called ourAnimation.stop()" ); - ok( !ourAnimation.stop.args[ 0 ][ 0 ], ".stop( falsy ) (undefined or false are both valid)" ); + assert.equal( ourAnimation.stop.callCount, 1, ".stop() called ourAnimation.stop()" ); + assert.ok( + !ourAnimation.stop.args[ 0 ][ 0 ], ".stop( falsy ) (undefined or false are both valid)" + ); - equal( queueSpy.callCount, 2, "Next queue function called" ); - ok( queueSpy.calledAfter( ourAnimation.stop ), "After our animation was told to stop" ); + assert.equal( queueSpy.callCount, 2, "Next queue function called" ); + assert.ok( queueSpy.calledAfter( ourAnimation.stop ), "After our animation was told to stop" ); // ourAnimation.stop.reset(); - equal( prefilter.callCount, 3, "Got the next animation" ); + assert.equal( prefilter.callCount, 3, "Got the next animation" ); ourAnimation.stop.reset(); // do not clear queue, gotoEnd element.stop( false, true ); - ok( ourAnimation.stop.calledWith( true ), ".stop(true) calls .stop(true)" ); - ok( queueSpy.calledAfter( ourAnimation.stop ), + assert.ok( ourAnimation.stop.calledWith( true ), ".stop(true) calls .stop(true)" ); + assert.ok( queueSpy.calledAfter( ourAnimation.stop ), "and the next queue function ran after we were told" ); } ); -test( "Animation.tweener( fn ) - unshifts a * tweener", function() { - expect( 2 ); +QUnit.test( "Animation.tweener( fn ) - unshifts a * tweener", function( assert ) { + assert.expect( 2 ); var starTweeners = jQuery.Animation.tweeners[ "*" ]; jQuery.Animation.tweener( jQuery.noop ); - equal( starTweeners.length, 2 ); - deepEqual( starTweeners, [ jQuery.noop, defaultTweener ] ); + assert.equal( starTweeners.length, 2 ); + assert.deepEqual( starTweeners, [ jQuery.noop, defaultTweener ] ); } ); -test( "Animation.tweener( 'prop', fn ) - unshifts a 'prop' tweener", function() { - expect( 4 ); +QUnit.test( "Animation.tweener( 'prop', fn ) - unshifts a 'prop' tweener", function( assert ) { + assert.expect( 4 ); var tweeners = jQuery.Animation.tweeners, fn = function() {}; jQuery.Animation.tweener( "prop", jQuery.noop ); - equal( tweeners.prop.length, 1 ); - deepEqual( tweeners.prop, [ jQuery.noop ] ); + assert.equal( tweeners.prop.length, 1 ); + assert.deepEqual( tweeners.prop, [ jQuery.noop ] ); jQuery.Animation.tweener( "prop", fn ); - equal( tweeners.prop.length, 2 ); - deepEqual( tweeners.prop, [ fn, jQuery.noop ] ); + assert.equal( tweeners.prop.length, 2 ); + assert.deepEqual( tweeners.prop, [ fn, jQuery.noop ] ); } ); -test( "Animation.tweener( 'list of props', fn ) - unshifts a tweener to each prop", function() { - expect( 2 ); - var tweeners = jQuery.Animation.tweeners, - fn = function() {}; - - jQuery.Animation.tweener( "list of props", jQuery.noop ); - deepEqual( tweeners, { - list: [ jQuery.noop ], - of: [ jQuery.noop ], - props: [ jQuery.noop ], - "*": [ defaultTweener ] - } ); - - // Test with extra whitespaces - jQuery.Animation.tweener( " list\t of \tprops\n*", fn ); - deepEqual( tweeners, { - list: [ fn, jQuery.noop ], - of: [ fn, jQuery.noop ], - props: [ fn, jQuery.noop ], - "*": [ fn, defaultTweener ] - } ); -} ); +QUnit.test( + "Animation.tweener( 'list of props', fn ) - unshifts a tweener to each prop", + function( assert ) { + assert.expect( 2 ); + var tweeners = jQuery.Animation.tweeners, + fn = function() {}; + + jQuery.Animation.tweener( "list of props", jQuery.noop ); + assert.deepEqual( tweeners, { + list: [ jQuery.noop ], + of: [ jQuery.noop ], + props: [ jQuery.noop ], + "*": [ defaultTweener ] + } ); + + // Test with extra whitespaces + jQuery.Animation.tweener( " list\t of \tprops\n*", fn ); + assert.deepEqual( tweeners, { + list: [ fn, jQuery.noop ], + of: [ fn, jQuery.noop ], + props: [ fn, jQuery.noop ], + "*": [ fn, defaultTweener ] + } ); + } +); } )(); diff --git a/test/unit/attributes.js b/test/unit/attributes.js index ec55556d1..59362f397 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -1,4 +1,4 @@ -module( "attributes", { +QUnit.module( "attributes", { teardown: moduleTeardown } ); @@ -24,8 +24,8 @@ function functionReturningObj( value ) { Returns a function that returns the value */ -test( "jQuery.propFix integrity test", function() { - expect( 1 ); +QUnit.test( "jQuery.propFix integrity test", function( assert ) { + assert.expect( 1 ); // This must be maintained and equal jQuery.attrFix when appropriate // Ensure that accidental or erroneous property @@ -46,75 +46,75 @@ test( "jQuery.propFix integrity test", function() { "contenteditable": "contentEditable" }; - deepEqual( props, jQuery.propFix, "jQuery.propFix passes integrity check" ); + assert.deepEqual( props, jQuery.propFix, "jQuery.propFix passes integrity check" ); } ); -test( "attr(String)", function() { - expect( 50 ); +QUnit.test( "attr(String)", function( assert ) { + assert.expect( 50 ); var extras, body, $body, select, optgroup, option, $img, styleElem, $button, $form, $a; - equal( jQuery( "#text1" ).attr( "type" ), "text", "Check for type attribute" ); - equal( jQuery( "#radio1" ).attr( "type" ), "radio", "Check for type attribute" ); - equal( jQuery( "#check1" ).attr( "type" ), "checkbox", "Check for type attribute" ); - equal( jQuery( "#simon1" ).attr( "rel" ), "bookmark", "Check for rel attribute" ); - equal( jQuery( "#google" ).attr( "title" ), "Google!", "Check for title attribute" ); - equal( jQuery( "#mark" ).attr( "hreflang" ), "en", "Check for hreflang attribute" ); - equal( jQuery( "#en" ).attr( "lang" ), "en", "Check for lang attribute" ); - equal( jQuery( "#simon" ).attr( "class" ), "blog link", "Check for class attribute" ); - equal( jQuery( "#name" ).attr( "name" ), "name", "Check for name attribute" ); - equal( jQuery( "#text1" ).attr( "name" ), "action", "Check for name attribute" ); - ok( jQuery( "#form" ).attr( "action" ).indexOf( "formaction" ) >= 0, "Check for action attribute" ); - equal( jQuery( "#text1" ).attr( "value", "t" ).attr( "value" ), "t", "Check setting the value attribute" ); - equal( jQuery( "#text1" ).attr( "value", "" ).attr( "value" ), "", "Check setting the value attribute to empty string" ); - equal( jQuery( "<div value='t'></div>" ).attr( "value" ), "t", "Check setting custom attr named 'value' on a div" ); - equal( jQuery( "#form" ).attr( "blah", "blah" ).attr( "blah" ), "blah", "Set non-existent attribute on a form" ); - equal( jQuery( "#foo" ).attr( "height" ), undefined, "Non existent height attribute should return undefined" ); + assert.equal( jQuery( "#text1" ).attr( "type" ), "text", "Check for type attribute" ); + assert.equal( jQuery( "#radio1" ).attr( "type" ), "radio", "Check for type attribute" ); + assert.equal( jQuery( "#check1" ).attr( "type" ), "checkbox", "Check for type attribute" ); + assert.equal( jQuery( "#simon1" ).attr( "rel" ), "bookmark", "Check for rel attribute" ); + assert.equal( jQuery( "#google" ).attr( "title" ), "Google!", "Check for title attribute" ); + assert.equal( jQuery( "#mark" ).attr( "hreflang" ), "en", "Check for hreflang attribute" ); + assert.equal( jQuery( "#en" ).attr( "lang" ), "en", "Check for lang attribute" ); + assert.equal( jQuery( "#simon" ).attr( "class" ), "blog link", "Check for class attribute" ); + assert.equal( jQuery( "#name" ).attr( "name" ), "name", "Check for name attribute" ); + assert.equal( jQuery( "#text1" ).attr( "name" ), "action", "Check for name attribute" ); + assert.ok( jQuery( "#form" ).attr( "action" ).indexOf( "formaction" ) >= 0, "Check for action attribute" ); + assert.equal( jQuery( "#text1" ).attr( "value", "t" ).attr( "value" ), "t", "Check setting the value attribute" ); + assert.equal( jQuery( "#text1" ).attr( "value", "" ).attr( "value" ), "", "Check setting the value attribute to empty string" ); + assert.equal( jQuery( "<div value='t'></div>" ).attr( "value" ), "t", "Check setting custom attr named 'value' on a div" ); + assert.equal( jQuery( "#form" ).attr( "blah", "blah" ).attr( "blah" ), "blah", "Set non-existent attribute on a form" ); + assert.equal( jQuery( "#foo" ).attr( "height" ), undefined, "Non existent height attribute should return undefined" ); // [7472] & [3113] (form contains an input with name="action" or name="id") extras = jQuery( "<input id='id' name='id' /><input id='name' name='name' /><input id='target' name='target' />" ).appendTo( "#testForm" ); - equal( jQuery( "#form" ).attr( "action", "newformaction" ).attr( "action" ), "newformaction", "Check that action attribute was changed" ); - equal( jQuery( "#testForm" ).attr( "target" ), undefined, "Retrieving target does not equal the input with name=target" ); - equal( jQuery( "#testForm" ).attr( "target", "newTarget" ).attr( "target" ), "newTarget", "Set target successfully on a form" ); - equal( jQuery( "#testForm" ).removeAttr( "id" ).attr( "id" ), undefined, "Retrieving id does not equal the input with name=id after id is removed [#7472]" ); + assert.equal( jQuery( "#form" ).attr( "action", "newformaction" ).attr( "action" ), "newformaction", "Check that action attribute was changed" ); + assert.equal( jQuery( "#testForm" ).attr( "target" ), undefined, "Retrieving target does not equal the input with name=target" ); + assert.equal( jQuery( "#testForm" ).attr( "target", "newTarget" ).attr( "target" ), "newTarget", "Set target successfully on a form" ); + assert.equal( jQuery( "#testForm" ).removeAttr( "id" ).attr( "id" ), undefined, "Retrieving id does not equal the input with name=id after id is removed [#7472]" ); // Bug #3685 (form contains input with name="name") - equal( jQuery( "#testForm" ).attr( "name" ), undefined, "Retrieving name does not retrieve input with name=name" ); + assert.equal( jQuery( "#testForm" ).attr( "name" ), undefined, "Retrieving name does not retrieve input with name=name" ); extras.remove(); - equal( jQuery( "#text1" ).attr( "maxlength" ), "30", "Check for maxlength attribute" ); - equal( jQuery( "#text1" ).attr( "maxLength" ), "30", "Check for maxLength attribute" ); - equal( jQuery( "#area1" ).attr( "maxLength" ), "30", "Check for maxLength attribute" ); + assert.equal( jQuery( "#text1" ).attr( "maxlength" ), "30", "Check for maxlength attribute" ); + assert.equal( jQuery( "#text1" ).attr( "maxLength" ), "30", "Check for maxLength attribute" ); + assert.equal( jQuery( "#area1" ).attr( "maxLength" ), "30", "Check for maxLength attribute" ); // using innerHTML in IE causes href attribute to be serialized to the full path jQuery( "<a/>" ).attr( { "id": "tAnchor5", "href": "#5" } ).appendTo( "#qunit-fixture" ); - equal( jQuery( "#tAnchor5" ).attr( "href" ), "#5", "Check for non-absolute href (an anchor)" ); + assert.equal( jQuery( "#tAnchor5" ).attr( "href" ), "#5", "Check for non-absolute href (an anchor)" ); jQuery( "<a id='tAnchor6' href='#5' />" ).appendTo( "#qunit-fixture" ); - equal( jQuery( "#tAnchor5" ).prop( "href" ), jQuery( "#tAnchor6" ).prop( "href" ), "Check for absolute href prop on an anchor" ); + assert.equal( jQuery( "#tAnchor5" ).prop( "href" ), jQuery( "#tAnchor6" ).prop( "href" ), "Check for absolute href prop on an anchor" ); jQuery( "<script type='jquery/test' src='#5' id='scriptSrc'></script>" ).appendTo( "#qunit-fixture" ); - equal( jQuery( "#tAnchor5" ).prop( "href" ), jQuery( "#scriptSrc" ).prop( "src" ), "Check for absolute src prop on a script" ); + assert.equal( jQuery( "#tAnchor5" ).prop( "href" ), jQuery( "#scriptSrc" ).prop( "src" ), "Check for absolute src prop on a script" ); // list attribute is readonly by default in browsers that support it jQuery( "#list-test" ).attr( "list", "datalist" ); - equal( jQuery( "#list-test" ).attr( "list" ), "datalist", "Check setting list attribute" ); + assert.equal( jQuery( "#list-test" ).attr( "list" ), "datalist", "Check setting list attribute" ); // Related to [5574] and [5683] body = document.body; $body = jQuery( body ); - strictEqual( $body.attr( "foo" ), undefined, "Make sure that a non existent attribute returns undefined" ); + assert.strictEqual( $body.attr( "foo" ), undefined, "Make sure that a non existent attribute returns undefined" ); body.setAttribute( "foo", "baz" ); - equal( $body.attr( "foo" ), "baz", "Make sure the dom attribute is retrieved when no expando is found" ); + assert.equal( $body.attr( "foo" ), "baz", "Make sure the dom attribute is retrieved when no expando is found" ); $body.attr( "foo", "cool" ); - equal( $body.attr( "foo" ), "cool", "Make sure that setting works well when both expando and dom attribute are available" ); + assert.equal( $body.attr( "foo" ), "cool", "Make sure that setting works well when both expando and dom attribute are available" ); body.removeAttribute( "foo" ); // Cleanup @@ -125,82 +125,82 @@ test( "attr(String)", function() { optgroup.appendChild( option ); select.appendChild( optgroup ); - equal( jQuery( option ).prop( "selected" ), true, "Make sure that a single option is selected, even when in an optgroup." ); + assert.equal( jQuery( option ).prop( "selected" ), true, "Make sure that a single option is selected, even when in an optgroup." ); $img = jQuery( "<img style='display:none' width='215' height='53' src='data/1x1.jpg'/>" ).appendTo( "body" ); - equal( $img.attr( "width" ), "215", "Retrieve width attribute an an element with display:none." ); - equal( $img.attr( "height" ), "53", "Retrieve height attribute an an element with display:none." ); + assert.equal( $img.attr( "width" ), "215", "Retrieve width attribute an an element with display:none." ); + assert.equal( $img.attr( "height" ), "53", "Retrieve height attribute an an element with display:none." ); // Check for style support styleElem = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ).css( { background: "url(UPPERlower.gif)" } ); - ok( !!~styleElem.attr( "style" ).indexOf( "UPPERlower.gif" ), "Check style attribute getter" ); - ok( !!~styleElem.attr( "style", "position:absolute;" ).attr( "style" ).indexOf( "absolute" ), "Check style setter" ); + assert.ok( !!~styleElem.attr( "style" ).indexOf( "UPPERlower.gif" ), "Check style attribute getter" ); + assert.ok( !!~styleElem.attr( "style", "position:absolute;" ).attr( "style" ).indexOf( "absolute" ), "Check style setter" ); // Check value on button element (#1954) $button = jQuery( "<button>text</button>" ).insertAfter( "#button" ); - strictEqual( $button.attr( "value" ), undefined, "Absence of value attribute on a button" ); - equal( $button.attr( "value", "foobar" ).attr( "value" ), "foobar", "Value attribute on a button does not return innerHTML" ); - equal( $button.attr( "value", "baz" ).html(), "text", "Setting the value attribute does not change innerHTML" ); + assert.strictEqual( $button.attr( "value" ), undefined, "Absence of value attribute on a button" ); + assert.equal( $button.attr( "value", "foobar" ).attr( "value" ), "foobar", "Value attribute on a button does not return innerHTML" ); + assert.equal( $button.attr( "value", "baz" ).html(), "text", "Setting the value attribute does not change innerHTML" ); // Attributes with a colon on a table element (#1591) - equal( jQuery( "#table" ).attr( "test:attrib" ), undefined, "Retrieving a non-existent attribute on a table with a colon does not throw an error." ); - equal( jQuery( "#table" ).attr( "test:attrib", "foobar" ).attr( "test:attrib" ), "foobar", "Setting an attribute on a table with a colon does not throw an error." ); + assert.equal( jQuery( "#table" ).attr( "test:attrib" ), undefined, "Retrieving a non-existent attribute on a table with a colon does not throw an error." ); + assert.equal( jQuery( "#table" ).attr( "test:attrib", "foobar" ).attr( "test:attrib" ), "foobar", "Setting an attribute on a table with a colon does not throw an error." ); $form = jQuery( "<form class='something'></form>" ).appendTo( "#qunit-fixture" ); - equal( $form.attr( "class" ), "something", "Retrieve the class attribute on a form." ); + assert.equal( $form.attr( "class" ), "something", "Retrieve the class attribute on a form." ); $a = jQuery( "<a href='#' onclick='something()'>Click</a>" ).appendTo( "#qunit-fixture" ); - equal( $a.attr( "onclick" ), "something()", "Retrieve ^on attribute without anonymous function wrapper." ); + assert.equal( $a.attr( "onclick" ), "something()", "Retrieve ^on attribute without anonymous function wrapper." ); - ok( jQuery( "<div/>" ).attr( "doesntexist" ) === undefined, "Make sure undefined is returned when no attribute is found." ); - ok( jQuery( "<div/>" ).attr( "title" ) === undefined, "Make sure undefined is returned when no attribute is found." ); - equal( jQuery( "<div/>" ).attr( "title", "something" ).attr( "title" ), "something", "Set the title attribute." ); - ok( jQuery().attr( "doesntexist" ) === undefined, "Make sure undefined is returned when no element is there." ); - equal( jQuery( "<div/>" ).attr( "value" ), undefined, "An unset value on a div returns undefined." ); - strictEqual( jQuery( "<select><option value='property'></option></select>" ).attr( "value" ), undefined, "An unset value on a select returns undefined." ); + assert.ok( jQuery( "<div/>" ).attr( "doesntexist" ) === undefined, "Make sure undefined is returned when no attribute is found." ); + assert.ok( jQuery( "<div/>" ).attr( "title" ) === undefined, "Make sure undefined is returned when no attribute is found." ); + assert.equal( jQuery( "<div/>" ).attr( "title", "something" ).attr( "title" ), "something", "Set the title attribute." ); + assert.ok( jQuery().attr( "doesntexist" ) === undefined, "Make sure undefined is returned when no element is there." ); + assert.equal( jQuery( "<div/>" ).attr( "value" ), undefined, "An unset value on a div returns undefined." ); + assert.strictEqual( jQuery( "<select><option value='property'></option></select>" ).attr( "value" ), undefined, "An unset value on a select returns undefined." ); $form = jQuery( "#form" ).attr( "enctype", "multipart/form-data" ); - equal( $form.prop( "enctype" ), "multipart/form-data", "Set the enctype of a form (encoding in IE6/7 #6743)" ); + assert.equal( $form.prop( "enctype" ), "multipart/form-data", "Set the enctype of a form (encoding in IE6/7 #6743)" ); } ); -test( "attr(String) on cloned elements, #9646", function() { - expect( 4 ); +QUnit.test( "attr(String) on cloned elements, #9646", function( assert ) { + assert.expect( 4 ); var div, input = jQuery( "<input name='tester' />" ); input.attr( "name" ); - strictEqual( input.clone( true ).attr( "name", "test" )[ 0 ].name, "test", "Name attribute should be changed on cloned element" ); + assert.strictEqual( input.clone( true ).attr( "name", "test" )[ 0 ].name, "test", "Name attribute should be changed on cloned element" ); div = jQuery( "<div id='tester' />" ); div.attr( "id" ); - strictEqual( div.clone( true ).attr( "id", "test" )[ 0 ].id, "test", "Id attribute should be changed on cloned element" ); + assert.strictEqual( div.clone( true ).attr( "id", "test" )[ 0 ].id, "test", "Id attribute should be changed on cloned element" ); input = jQuery( "<input value='tester' />" ); input.attr( "value" ); - strictEqual( input.clone( true ).attr( "value", "test" )[ 0 ].value, "test", "Value attribute should be changed on cloned element" ); + assert.strictEqual( input.clone( true ).attr( "value", "test" )[ 0 ].value, "test", "Value attribute should be changed on cloned element" ); - strictEqual( input.clone( true ).attr( "value", 42 )[ 0 ].value, "42", "Value attribute should be changed on cloned element" ); + assert.strictEqual( input.clone( true ).attr( "value", 42 )[ 0 ].value, "42", "Value attribute should be changed on cloned element" ); } ); -test( "attr(String) in XML Files", function() { - expect( 3 ); +QUnit.test( "attr(String) in XML Files", function( assert ) { + assert.expect( 3 ); var xml = createDashboardXML(); - equal( jQuery( "locations", xml ).attr( "class" ), "foo", "Check class attribute in XML document" ); - equal( jQuery( "location", xml ).attr( "for" ), "bar", "Check for attribute in XML document" ); - equal( jQuery( "location", xml ).attr( "checked" ), "different", "Check that hooks are not attached in XML document" ); + assert.equal( jQuery( "locations", xml ).attr( "class" ), "foo", "Check class attribute in XML document" ); + assert.equal( jQuery( "location", xml ).attr( "for" ), "bar", "Check for attribute in XML document" ); + assert.equal( jQuery( "location", xml ).attr( "checked" ), "different", "Check that hooks are not attached in XML document" ); } ); -test( "attr(String, Function)", function() { - expect( 2 ); +QUnit.test( "attr(String, Function)", function( assert ) { + assert.expect( 2 ); - equal( + assert.equal( jQuery( "#text1" ).attr( "value", function() { return this.id; } ).attr( "value" ), @@ -208,7 +208,7 @@ test( "attr(String, Function)", function() { "Set value from id" ); - equal( + assert.equal( jQuery( "#text1" ).attr( "title", function( i ) { return i; } ).attr( "title" ), @@ -217,8 +217,8 @@ test( "attr(String, Function)", function() { ); } ); -test( "attr(Hash)", function() { - expect( 3 ); +QUnit.test( "attr(Hash)", function( assert ) { + assert.expect( 3 ); var pass = true; jQuery( "div" ).attr( { "foo": "baz", @@ -229,9 +229,9 @@ test( "attr(Hash)", function() { } } ); - ok( pass, "Set Multiple Attributes" ); + assert.ok( pass, "Set Multiple Attributes" ); - equal( + assert.equal( jQuery( "#text1" ).attr( { "value": function() { return this[ "id" ]; @@ -240,7 +240,7 @@ test( "attr(Hash)", function() { "Set attribute to computed value #1" ); - equal( + assert.equal( jQuery( "#text1" ).attr( { "title": function( i ) { return i; @@ -251,8 +251,8 @@ test( "attr(Hash)", function() { ); } ); -test( "attr(String, Object)", function() { - expect( 71 ); +QUnit.test( "attr(String, Object)", function( assert ) { + assert.expect( 71 ); var $input, $text, $details, attributeNode, commentNode, textNode, obj, @@ -269,9 +269,9 @@ test( "attr(String, Object)", function() { } } - equal( fail, false, "Set Attribute, the #" + fail + " element didn't get the attribute 'foo'" ); + assert.equal( fail, false, "Set Attribute, the #" + fail + " element didn't get the attribute 'foo'" ); - ok( + assert.ok( jQuery( "#foo" ).attr( { "width": null } ), @@ -279,90 +279,90 @@ test( "attr(String, Object)", function() { ); jQuery( "#name" ).attr( "name", "something" ); - equal( jQuery( "#name" ).attr( "name" ), "something", "Set name attribute" ); + assert.equal( jQuery( "#name" ).attr( "name" ), "something", "Set name attribute" ); jQuery( "#name" ).attr( "name", null ); - equal( jQuery( "#name" ).attr( "name" ), undefined, "Remove name attribute" ); + assert.equal( jQuery( "#name" ).attr( "name" ), undefined, "Remove name attribute" ); $input = jQuery( "<input>", { name: "something", id: "specified" } ); - equal( $input.attr( "name" ), "something", "Check element creation gets/sets the name attribute." ); - equal( $input.attr( "id" ), "specified", "Check element creation gets/sets the id attribute." ); + assert.equal( $input.attr( "name" ), "something", "Check element creation gets/sets the name attribute." ); + assert.equal( $input.attr( "id" ), "specified", "Check element creation gets/sets the id attribute." ); // As of fixing #11115, we only guarantee boolean property update for checked and selected $input = jQuery( "<input type='checkbox'/>" ).attr( "checked", true ); - equal( $input.prop( "checked" ), true, "Setting checked updates property (verified by .prop)" ); - equal( $input[ 0 ].checked, true, "Setting checked updates property (verified by native property)" ); + assert.equal( $input.prop( "checked" ), true, "Setting checked updates property (verified by .prop)" ); + assert.equal( $input[ 0 ].checked, true, "Setting checked updates property (verified by native property)" ); $input = jQuery( "<option/>" ).attr( "selected", true ); - equal( $input.prop( "selected" ), true, "Setting selected updates property (verified by .prop)" ); - equal( $input[ 0 ].selected, true, "Setting selected updates property (verified by native property)" ); + assert.equal( $input.prop( "selected" ), true, "Setting selected updates property (verified by .prop)" ); + assert.equal( $input[ 0 ].selected, true, "Setting selected updates property (verified by native property)" ); $input = jQuery( "#check2" ); $input.prop( "checked", true ).prop( "checked", false ).attr( "checked", true ); - equal( $input.attr( "checked" ), "checked", "Set checked (verified by .attr)" ); + assert.equal( $input.attr( "checked" ), "checked", "Set checked (verified by .attr)" ); $input.prop( "checked", false ).prop( "checked", true ).attr( "checked", false ); - equal( $input.attr( "checked" ), undefined, "Remove checked (verified by .attr)" ); + assert.equal( $input.attr( "checked" ), undefined, "Remove checked (verified by .attr)" ); $input = jQuery( "#text1" ).prop( "readOnly", true ).prop( "readOnly", false ).attr( "readonly", true ); - equal( $input.attr( "readonly" ), "readonly", "Set readonly (verified by .attr)" ); + assert.equal( $input.attr( "readonly" ), "readonly", "Set readonly (verified by .attr)" ); $input.prop( "readOnly", false ).prop( "readOnly", true ).attr( "readonly", false ); - equal( $input.attr( "readonly" ), undefined, "Remove readonly (verified by .attr)" ); + assert.equal( $input.attr( "readonly" ), undefined, "Remove readonly (verified by .attr)" ); $input = jQuery( "#check2" ).attr( "checked", true ).attr( "checked", false ).prop( "checked", true ); - equal( $input[ 0 ].checked, true, "Set checked property (verified by native property)" ); - equal( $input.prop( "checked" ), true, "Set checked property (verified by .prop)" ); - equal( $input.attr( "checked" ), undefined, "Setting checked property doesn't affect checked attribute" ); + assert.equal( $input[ 0 ].checked, true, "Set checked property (verified by native property)" ); + assert.equal( $input.prop( "checked" ), true, "Set checked property (verified by .prop)" ); + assert.equal( $input.attr( "checked" ), undefined, "Setting checked property doesn't affect checked attribute" ); $input.attr( "checked", false ).attr( "checked", true ).prop( "checked", false ); - equal( $input[ 0 ].checked, false, "Clear checked property (verified by native property)" ); - equal( $input.prop( "checked" ), false, "Clear checked property (verified by .prop)" ); - equal( $input.attr( "checked" ), "checked", "Clearing checked property doesn't affect checked attribute" ); + assert.equal( $input[ 0 ].checked, false, "Clear checked property (verified by native property)" ); + assert.equal( $input.prop( "checked" ), false, "Clear checked property (verified by .prop)" ); + assert.equal( $input.attr( "checked" ), "checked", "Clearing checked property doesn't affect checked attribute" ); $input = jQuery( "#check2" ).attr( "checked", false ).attr( "checked", "checked" ); - equal( $input.attr( "checked" ), "checked", "Set checked to 'checked' (verified by .attr)" ); + assert.equal( $input.attr( "checked" ), "checked", "Set checked to 'checked' (verified by .attr)" ); $radios = jQuery( "#checkedtest" ).find( "input[type='radio']" ); $radios.eq( 1 ).trigger( "click" ); - equal( $radios.eq( 1 ).prop( "checked" ), true, "Second radio was checked when clicked" ); - equal( $radios.eq( 0 ).attr( "checked" ), "checked", "First radio is still [checked]" ); + assert.equal( $radios.eq( 1 ).prop( "checked" ), true, "Second radio was checked when clicked" ); + assert.equal( $radios.eq( 0 ).attr( "checked" ), "checked", "First radio is still [checked]" ); $input = jQuery( "#text1" ).attr( "readonly", false ).prop( "readOnly", true ); - equal( $input[ 0 ].readOnly, true, "Set readonly property (verified by native property)" ); - equal( $input.prop( "readOnly" ), true, "Set readonly property (verified by .prop)" ); + assert.equal( $input[ 0 ].readOnly, true, "Set readonly property (verified by native property)" ); + assert.equal( $input.prop( "readOnly" ), true, "Set readonly property (verified by .prop)" ); $input.attr( "readonly", true ).prop( "readOnly", false ); - equal( $input[ 0 ].readOnly, false, "Clear readonly property (verified by native property)" ); - equal( $input.prop( "readOnly" ), false, "Clear readonly property (verified by .prop)" ); + assert.equal( $input[ 0 ].readOnly, false, "Clear readonly property (verified by native property)" ); + assert.equal( $input.prop( "readOnly" ), false, "Clear readonly property (verified by .prop)" ); $input = jQuery( "#name" ).attr( "maxlength", "5" ); - equal( $input[ 0 ].maxLength, 5, "Set maxlength (verified by native property)" ); + assert.equal( $input[ 0 ].maxLength, 5, "Set maxlength (verified by native property)" ); $input.attr( "maxLength", "10" ); - equal( $input[ 0 ].maxLength, 10, "Set maxlength (verified by native property)" ); + assert.equal( $input[ 0 ].maxLength, 10, "Set maxlength (verified by native property)" ); // HTML5 boolean attributes $text = jQuery( "#text1" ).attr( { "autofocus": true, "required": true } ); - equal( $text.attr( "autofocus" ), "autofocus", "Reading autofocus attribute yields 'autofocus'" ); - equal( $text.attr( "autofocus", false ).attr( "autofocus" ), undefined, "Setting autofocus to false removes it" ); - equal( $text.attr( "required" ), "required", "Reading required attribute yields 'required'" ); - equal( $text.attr( "required", false ).attr( "required" ), undefined, "Setting required attribute to false removes it" ); + assert.equal( $text.attr( "autofocus" ), "autofocus", "Reading autofocus attribute yields 'autofocus'" ); + assert.equal( $text.attr( "autofocus", false ).attr( "autofocus" ), undefined, "Setting autofocus to false removes it" ); + assert.equal( $text.attr( "required" ), "required", "Reading required attribute yields 'required'" ); + assert.equal( $text.attr( "required", false ).attr( "required" ), undefined, "Setting required attribute to false removes it" ); $details = jQuery( "<details open></details>" ).appendTo( "#qunit-fixture" ); - equal( $details.attr( "open" ), "open", "open attribute presence indicates true" ); - equal( $details.attr( "open", false ).attr( "open" ), undefined, "Setting open attribute to false removes it" ); + assert.equal( $details.attr( "open" ), "open", "open attribute presence indicates true" ); + assert.equal( $details.attr( "open", false ).attr( "open" ), undefined, "Setting open attribute to false removes it" ); $text.attr( "data-something", true ); - equal( $text.attr( "data-something" ), "true", "Set data attributes" ); - equal( $text.data( "something" ), true, "Setting data attributes are not affected by boolean settings" ); + assert.equal( $text.attr( "data-something" ), "true", "Set data attributes" ); + assert.equal( $text.data( "something" ), true, "Setting data attributes are not affected by boolean settings" ); $text.attr( "data-another", false ); - equal( $text.attr( "data-another" ), "false", "Set data attributes" ); - equal( $text.data( "another" ), false, "Setting data attributes are not affected by boolean settings" ); - equal( $text.attr( "aria-disabled", false ).attr( "aria-disabled" ), "false", "Setting aria attributes are not affected by boolean settings" ); + assert.equal( $text.attr( "data-another" ), "false", "Set data attributes" ); + assert.equal( $text.data( "another" ), false, "Setting data attributes are not affected by boolean settings" ); + assert.equal( $text.attr( "aria-disabled", false ).attr( "aria-disabled" ), "false", "Setting aria attributes are not affected by boolean settings" ); $text.removeData( "something" ).removeData( "another" ).removeAttr( "aria-disabled" ); jQuery( "#foo" ).attr( "contenteditable", true ); - equal( jQuery( "#foo" ).attr( "contenteditable" ), "true", "Enumerated attributes are set properly" ); + assert.equal( jQuery( "#foo" ).attr( "contenteditable" ), "true", "Enumerated attributes are set properly" ); attributeNode = document.createAttribute( "irrelevant" ); commentNode = document.createComment( "some comment" ); @@ -372,14 +372,14 @@ test( "attr(String, Object)", function() { jQuery.each( [ commentNode, textNode, attributeNode ], function( i, elem ) { var $elem = jQuery( elem ); $elem.attr( "nonexisting", "foo" ); - strictEqual( $elem.attr( "nonexisting" ), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." ); + assert.strictEqual( $elem.attr( "nonexisting" ), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." ); } ); jQuery.each( [ window, document, obj, "#firstp" ], function( i, elem ) { var oldVal = elem.nonexisting, $elem = jQuery( elem ); - strictEqual( $elem.attr( "nonexisting" ), undefined, "attr works correctly for non existing attributes (bug #7500)." ); - equal( $elem.attr( "nonexisting", "foo" ).attr( "nonexisting" ), "foo", "attr falls back to prop on unsupported arguments" ); + assert.strictEqual( $elem.attr( "nonexisting" ), undefined, "attr works correctly for non existing attributes (bug #7500)." ); + assert.equal( $elem.attr( "nonexisting", "foo" ).attr( "nonexisting" ), "foo", "attr falls back to prop on unsupported arguments" ); elem.nonexisting = oldVal; } ); @@ -389,36 +389,36 @@ test( "attr(String, Object)", function() { table = jQuery( "#table" ).append( "<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>" ); td = table.find( "td" ).eq( 0 ); td.attr( "rowspan", "2" ); - equal( td[ 0 ][ "rowSpan" ], 2, "Check rowspan is correctly set" ); + assert.equal( td[ 0 ][ "rowSpan" ], 2, "Check rowspan is correctly set" ); td.attr( "colspan", "2" ); - equal( td[ 0 ][ "colSpan" ], 2, "Check colspan is correctly set" ); + assert.equal( td[ 0 ][ "colSpan" ], 2, "Check colspan is correctly set" ); table.attr( "cellspacing", "2" ); - equal( table[ 0 ][ "cellSpacing" ], "2", "Check cellspacing is correctly set" ); + assert.equal( table[ 0 ][ "cellSpacing" ], "2", "Check cellspacing is correctly set" ); - equal( jQuery( "#area1" ).attr( "value" ), undefined, "Value attribute is distinct from value property." ); + assert.equal( jQuery( "#area1" ).attr( "value" ), undefined, "Value attribute is distinct from value property." ); // for #1070 jQuery( "#name" ).attr( "someAttr", "0" ); - equal( jQuery( "#name" ).attr( "someAttr" ), "0", "Set attribute to a string of '0'" ); + assert.equal( jQuery( "#name" ).attr( "someAttr" ), "0", "Set attribute to a string of '0'" ); jQuery( "#name" ).attr( "someAttr", 0 ); - equal( jQuery( "#name" ).attr( "someAttr" ), "0", "Set attribute to the number 0" ); + assert.equal( jQuery( "#name" ).attr( "someAttr" ), "0", "Set attribute to the number 0" ); jQuery( "#name" ).attr( "someAttr", 1 ); - equal( jQuery( "#name" ).attr( "someAttr" ), "1", "Set attribute to the number 1" ); + assert.equal( jQuery( "#name" ).attr( "someAttr" ), "1", "Set attribute to the number 1" ); // using contents will get comments regular, text, and comment nodes j = jQuery( "#nonnodes" ).contents(); j.attr( "name", "attrvalue" ); - equal( j.attr( "name" ), "attrvalue", "Check node,textnode,comment for attr" ); + assert.equal( j.attr( "name" ), "attrvalue", "Check node,textnode,comment for attr" ); j.removeAttr( "name" ); // Type type = jQuery( "#check2" ).attr( "type" ); try { jQuery( "#check2" ).attr( "type", "hidden" ); - ok( true, "No exception thrown on input type change" ); + assert.ok( true, "No exception thrown on input type change" ); } catch ( e ) { - ok( true, "Exception thrown on input type change: " + e ); + assert.ok( true, "Exception thrown on input type change: " + e ); } check = document.createElement( "input" ); @@ -428,8 +428,8 @@ test( "attr(String, Object)", function() { } catch ( e ) { thrown = false; } - ok( thrown, "Exception thrown when trying to change type property" ); - equal( "checkbox", jQuery( check ).attr( "type" ), "Verify that you can change the type of an input element that isn't in the DOM" ); + assert.ok( thrown, "Exception thrown when trying to change type property" ); + assert.equal( "checkbox", jQuery( check ).attr( "type" ), "Verify that you can change the type of an input element that isn't in the DOM" ); check = jQuery( "<input />" ); thrown = true; @@ -438,22 +438,22 @@ test( "attr(String, Object)", function() { } catch ( e ) { thrown = false; } - ok( thrown, "Exception thrown when trying to change type property" ); - equal( "checkbox", check.attr( "type" ), "Verify that you can change the type of an input element that isn't in the DOM" ); + assert.ok( thrown, "Exception thrown when trying to change type property" ); + assert.equal( "checkbox", check.attr( "type" ), "Verify that you can change the type of an input element that isn't in the DOM" ); button = jQuery( "#button" ); try { button.attr( "type", "submit" ); - ok( true, "No exception thrown on button type change" ); + assert.ok( true, "No exception thrown on button type change" ); } catch ( e ) { - ok( true, "Exception thrown on button type change: " + e ); + assert.ok( true, "Exception thrown on button type change: " + e ); } $radio = jQuery( "<input>", { "value": "sup", "type": "radio" } ).appendTo( "#testForm" ); - equal( $radio.val(), "sup", "Value is not reset when type is set after value on a radio" ); + assert.equal( $radio.val(), "sup", "Value is not reset when type is set after value on a radio" ); // Setting attributes on svg elements (bug #3116) $svg = jQuery( @@ -461,18 +461,18 @@ test( "attr(String, Object)", function() { "<circle cx='200' cy='200' r='150' />" + "</svg>" ).appendTo( "body" ); - equal( $svg.attr( "cx", 100 ).attr( "cx" ), "100", "Set attribute on svg element" ); + assert.equal( $svg.attr( "cx", 100 ).attr( "cx" ), "100", "Set attribute on svg element" ); $svg.remove(); // undefined values are chainable jQuery( "#name" ).attr( "maxlength", "5" ).removeAttr( "nonexisting" ); - equal( typeof jQuery( "#name" ).attr( "maxlength", undefined ), "object", ".attr('attribute', undefined) is chainable (#5571)" ); - equal( jQuery( "#name" ).attr( "maxlength", undefined ).attr( "maxlength" ), "5", ".attr('attribute', undefined) does not change value (#5571)" ); - equal( jQuery( "#name" ).attr( "nonexisting", undefined ).attr( "nonexisting" ), undefined, ".attr('attribute', undefined) does not create attribute (#5571)" ); + assert.equal( typeof jQuery( "#name" ).attr( "maxlength", undefined ), "object", ".attr('attribute', undefined) is chainable (#5571)" ); + assert.equal( jQuery( "#name" ).attr( "maxlength", undefined ).attr( "maxlength" ), "5", ".attr('attribute', undefined) does not change value (#5571)" ); + assert.equal( jQuery( "#name" ).attr( "nonexisting", undefined ).attr( "nonexisting" ), undefined, ".attr('attribute', undefined) does not create attribute (#5571)" ); } ); -test( "attr - extending the boolean attrHandle", function() { - expect( 1 ); +QUnit.test( "attr - extending the boolean attrHandle", function( assert ) { + assert.expect( 1 ); var called = false, _handle = jQuery.expr.attrHandle.checked || $.noop; jQuery.expr.attrHandle.checked = function() { @@ -482,139 +482,139 @@ test( "attr - extending the boolean attrHandle", function() { jQuery( "input" ).attr( "checked" ); called = false; jQuery( "input" ).attr( "checked" ); - ok( called, "The boolean attrHandle does not drop custom attrHandles" ); + assert.ok( called, "The boolean attrHandle does not drop custom attrHandles" ); } ); -test( "attr(String, Object) - Loaded via XML document", function() { - expect( 2 ); +QUnit.test( "attr(String, Object) - Loaded via XML document", function( assert ) { + assert.expect( 2 ); var xml = createDashboardXML(), titles = []; jQuery( "tab", xml ).each( function() { titles.push( jQuery( this ).attr( "title" ) ); } ); - equal( titles[ 0 ], "Location", "attr() in XML context: Check first title" ); - equal( titles[ 1 ], "Users", "attr() in XML context: Check second title" ); + assert.equal( titles[ 0 ], "Location", "attr() in XML context: Check first title" ); + assert.equal( titles[ 1 ], "Users", "attr() in XML context: Check second title" ); } ); -test( "attr(String, Object) - Loaded via XML fragment", function() { - expect( 2 ); +QUnit.test( "attr(String, Object) - Loaded via XML fragment", function( assert ) { + assert.expect( 2 ); var frag = createXMLFragment(), $frag = jQuery( frag ); $frag.attr( "test", "some value" ); - equal( $frag.attr( "test" ), "some value", "set attribute" ); + assert.equal( $frag.attr( "test" ), "some value", "set attribute" ); $frag.attr( "test", null ); - equal( $frag.attr( "test" ), undefined, "remove attribute" ); + assert.equal( $frag.attr( "test" ), undefined, "remove attribute" ); } ); -test( "attr('tabindex')", function() { - expect( 8 ); +QUnit.test( "attr('tabindex')", function( assert ) { + assert.expect( 8 ); // elements not natively tabbable - equal( jQuery( "#listWithTabIndex" ).attr( "tabindex" ), "5", "not natively tabbable, with tabindex set to 0" ); - equal( jQuery( "#divWithNoTabIndex" ).attr( "tabindex" ), undefined, "not natively tabbable, no tabindex set" ); + assert.equal( jQuery( "#listWithTabIndex" ).attr( "tabindex" ), "5", "not natively tabbable, with tabindex set to 0" ); + assert.equal( jQuery( "#divWithNoTabIndex" ).attr( "tabindex" ), undefined, "not natively tabbable, no tabindex set" ); // anchor with href - equal( jQuery( "#linkWithNoTabIndex" ).attr( "tabindex" ), undefined, "anchor with href, no tabindex set" ); - equal( jQuery( "#linkWithTabIndex" ).attr( "tabindex" ), "2", "anchor with href, tabindex set to 2" ); - equal( jQuery( "#linkWithNegativeTabIndex" ).attr( "tabindex" ), "-1", "anchor with href, tabindex set to -1" ); + assert.equal( jQuery( "#linkWithNoTabIndex" ).attr( "tabindex" ), undefined, "anchor with href, no tabindex set" ); + assert.equal( jQuery( "#linkWithTabIndex" ).attr( "tabindex" ), "2", "anchor with href, tabindex set to 2" ); + assert.equal( jQuery( "#linkWithNegativeTabIndex" ).attr( "tabindex" ), "-1", "anchor with href, tabindex set to -1" ); // anchor without href - equal( jQuery( "#linkWithNoHrefWithNoTabIndex" ).attr( "tabindex" ), undefined, "anchor without href, no tabindex set" ); - equal( jQuery( "#linkWithNoHrefWithTabIndex" ).attr( "tabindex" ), "1", "anchor without href, tabindex set to 2" ); - equal( jQuery( "#linkWithNoHrefWithNegativeTabIndex" ).attr( "tabindex" ), "-1", "anchor without href, no tabindex set" ); + assert.equal( jQuery( "#linkWithNoHrefWithNoTabIndex" ).attr( "tabindex" ), undefined, "anchor without href, no tabindex set" ); + assert.equal( jQuery( "#linkWithNoHrefWithTabIndex" ).attr( "tabindex" ), "1", "anchor without href, tabindex set to 2" ); + assert.equal( jQuery( "#linkWithNoHrefWithNegativeTabIndex" ).attr( "tabindex" ), "-1", "anchor without href, no tabindex set" ); } ); -test( "attr('tabindex', value)", function() { - expect( 9 ); +QUnit.test( "attr('tabindex', value)", function( assert ) { + assert.expect( 9 ); var element = jQuery( "#divWithNoTabIndex" ); - equal( element.attr( "tabindex" ), undefined, "start with no tabindex" ); + assert.equal( element.attr( "tabindex" ), undefined, "start with no tabindex" ); // set a positive string element.attr( "tabindex", "1" ); - equal( element.attr( "tabindex" ), "1", "set tabindex to 1 (string)" ); + assert.equal( element.attr( "tabindex" ), "1", "set tabindex to 1 (string)" ); // set a zero string element.attr( "tabindex", "0" ); - equal( element.attr( "tabindex" ), "0", "set tabindex to 0 (string)" ); + assert.equal( element.attr( "tabindex" ), "0", "set tabindex to 0 (string)" ); // set a negative string element.attr( "tabindex", "-1" ); - equal( element.attr( "tabindex" ), "-1", "set tabindex to -1 (string)" ); + assert.equal( element.attr( "tabindex" ), "-1", "set tabindex to -1 (string)" ); // set a positive number element.attr( "tabindex", 1 ); - equal( element.attr( "tabindex" ), "1", "set tabindex to 1 (number)" ); + assert.equal( element.attr( "tabindex" ), "1", "set tabindex to 1 (number)" ); // set a zero number element.attr( "tabindex", 0 ); - equal( element.attr( "tabindex" ), "0", "set tabindex to 0 (number)" ); + assert.equal( element.attr( "tabindex" ), "0", "set tabindex to 0 (number)" ); // set a negative number element.attr( "tabindex", -1 ); - equal( element.attr( "tabindex" ), "-1", "set tabindex to -1 (number)" ); + assert.equal( element.attr( "tabindex" ), "-1", "set tabindex to -1 (number)" ); element = jQuery( "#linkWithTabIndex" ); - equal( element.attr( "tabindex" ), "2", "start with tabindex 2" ); + assert.equal( element.attr( "tabindex" ), "2", "start with tabindex 2" ); element.attr( "tabindex", -1 ); - equal( element.attr( "tabindex" ), "-1", "set negative tabindex" ); + assert.equal( element.attr( "tabindex" ), "-1", "set negative tabindex" ); } ); -test( "removeAttr(String)", function() { - expect( 12 ); +QUnit.test( "removeAttr(String)", function( assert ) { + assert.expect( 12 ); var $first; - equal( jQuery( "#mark" ).removeAttr( "class" ).attr( "class" ), undefined, "remove class" ); - equal( jQuery( "#form" ).removeAttr( "id" ).attr( "id" ), undefined, "Remove id" ); - equal( jQuery( "#foo" ).attr( "style", "position:absolute;" ).removeAttr( "style" ).attr( "style" ), undefined, "Check removing style attribute" ); - equal( jQuery( "#form" ).attr( "style", "position:absolute;" ).removeAttr( "style" ).attr( "style" ), undefined, "Check removing style attribute on a form" ); - equal( jQuery( "<div style='position: absolute'></div>" ).appendTo( "#foo" ).removeAttr( "style" ).prop( "style" ).cssText, "", "Check removing style attribute (#9699 Webkit)" ); - equal( jQuery( "#fx-test-group" ).attr( "height", "3px" ).removeAttr( "height" ).get( 0 ).style.height, "1px", "Removing height attribute has no effect on height set with style attribute" ); + assert.equal( jQuery( "#mark" ).removeAttr( "class" ).attr( "class" ), undefined, "remove class" ); + assert.equal( jQuery( "#form" ).removeAttr( "id" ).attr( "id" ), undefined, "Remove id" ); + assert.equal( jQuery( "#foo" ).attr( "style", "position:absolute;" ).removeAttr( "style" ).attr( "style" ), undefined, "Check removing style attribute" ); + assert.equal( jQuery( "#form" ).attr( "style", "position:absolute;" ).removeAttr( "style" ).attr( "style" ), undefined, "Check removing style attribute on a form" ); + assert.equal( jQuery( "<div style='position: absolute'></div>" ).appendTo( "#foo" ).removeAttr( "style" ).prop( "style" ).cssText, "", "Check removing style attribute (#9699 Webkit)" ); + assert.equal( jQuery( "#fx-test-group" ).attr( "height", "3px" ).removeAttr( "height" ).get( 0 ).style.height, "1px", "Removing height attribute has no effect on height set with style attribute" ); jQuery( "#check1" ).removeAttr( "checked" ).prop( "checked", true ).removeAttr( "checked" ); - equal( document.getElementById( "check1" ).checked, false, "removeAttr sets boolean properties to false" ); + assert.equal( document.getElementById( "check1" ).checked, false, "removeAttr sets boolean properties to false" ); jQuery( "#text1" ).prop( "readOnly", true ).removeAttr( "readonly" ); - equal( document.getElementById( "text1" ).readOnly, false, "removeAttr sets boolean properties to false" ); + assert.equal( document.getElementById( "text1" ).readOnly, false, "removeAttr sets boolean properties to false" ); jQuery( "#option2c" ).removeAttr( "selected" ); - equal( jQuery( "#option2d" ).attr( "selected" ), "selected", "Removing `selected` from an option that is not selected does not remove selected from the currently selected option (#10870)" ); + assert.equal( jQuery( "#option2d" ).attr( "selected" ), "selected", "Removing `selected` from an option that is not selected does not remove selected from the currently selected option (#10870)" ); try { $first = jQuery( "#first" ).attr( "contenteditable", "true" ).removeAttr( "contenteditable" ); - equal( $first.attr( "contenteditable" ), undefined, "Remove the contenteditable attribute" ); + assert.equal( $first.attr( "contenteditable" ), undefined, "Remove the contenteditable attribute" ); } catch ( e ) { - ok( false, "Removing contenteditable threw an error (#10429)" ); + assert.ok( false, "Removing contenteditable threw an error (#10429)" ); } $first = jQuery( "<div Case='mixed'></div>" ); - equal( $first.attr( "Case" ), "mixed", "case of attribute doesn't matter" ); + assert.equal( $first.attr( "Case" ), "mixed", "case of attribute doesn't matter" ); $first.removeAttr( "Case" ); - equal( $first.attr( "Case" ), undefined, "mixed-case attribute was removed" ); + assert.equal( $first.attr( "Case" ), undefined, "mixed-case attribute was removed" ); } ); -test( "removeAttr(String) in XML", function() { - expect( 7 ); +QUnit.test( "removeAttr(String) in XML", function( assert ) { + assert.expect( 7 ); var xml = createDashboardXML(), iwt = jQuery( "infowindowtab", xml ); - equal( iwt.attr( "normal" ), "ab", "Check initial value" ); + assert.equal( iwt.attr( "normal" ), "ab", "Check initial value" ); iwt.removeAttr( "Normal" ); - equal( iwt.attr( "normal" ), "ab", "Should still be there" ); + assert.equal( iwt.attr( "normal" ), "ab", "Should still be there" ); iwt.removeAttr( "normal" ); - equal( iwt.attr( "normal" ), undefined, "Removed" ); + assert.equal( iwt.attr( "normal" ), undefined, "Removed" ); - equal( iwt.attr( "mixedCase" ), "yes", "Check initial value" ); - equal( iwt.attr( "mixedcase" ), undefined, "toLowerCase not work good" ); + assert.equal( iwt.attr( "mixedCase" ), "yes", "Check initial value" ); + assert.equal( iwt.attr( "mixedcase" ), undefined, "toLowerCase not work good" ); iwt.removeAttr( "mixedcase" ); - equal( iwt.attr( "mixedCase" ), "yes", "Should still be there" ); + assert.equal( iwt.attr( "mixedCase" ), "yes", "Should still be there" ); iwt.removeAttr( "mixedCase" ); - equal( iwt.attr( "mixedCase" ), undefined, "Removed" ); + assert.equal( iwt.attr( "mixedCase" ), undefined, "Removed" ); } ); -test( "removeAttr(Multi String, variable space width)", function() { - expect( 8 ); +QUnit.test( "removeAttr(Multi String, variable space width)", function( assert ) { + assert.expect( 8 ); var div = jQuery( "<div id='a' alt='b' title='c' rel='d'></div>" ), tests = { @@ -625,60 +625,60 @@ test( "removeAttr(Multi String, variable space width)", function() { }; jQuery.each( tests, function( key, val ) { - equal( div.attr( key ), val, "Attribute `" + key + "` exists, and has a value of `" + val + "`" ); + assert.equal( div.attr( key ), val, "Attribute `" + key + "` exists, and has a value of `" + val + "`" ); } ); div.removeAttr( "id alt title rel " ); jQuery.each( tests, function( key ) { - equal( div.attr( key ), undefined, "Attribute `" + key + "` was removed" ); + assert.equal( div.attr( key ), undefined, "Attribute `" + key + "` was removed" ); } ); } ); -test( "prop(String, Object)", function() { - expect( 17 ); +QUnit.test( "prop(String, Object)", function( assert ) { + assert.expect( 17 ); - equal( jQuery( "#text1" ).prop( "value" ), "Test", "Check for value attribute" ); - equal( jQuery( "#text1" ).prop( "value", "Test2" ).prop( "defaultValue" ), "Test", "Check for defaultValue attribute" ); - equal( jQuery( "#select2" ).prop( "selectedIndex" ), 3, "Check for selectedIndex attribute" ); - equal( jQuery( "#foo" ).prop( "nodeName" ).toUpperCase(), "DIV", "Check for nodeName attribute" ); - equal( jQuery( "#foo" ).prop( "tagName" ).toUpperCase(), "DIV", "Check for tagName attribute" ); - equal( jQuery( "<option/>" ).prop( "selected" ), false, "Check selected attribute on disconnected element." ); + assert.equal( jQuery( "#text1" ).prop( "value" ), "Test", "Check for value attribute" ); + assert.equal( jQuery( "#text1" ).prop( "value", "Test2" ).prop( "defaultValue" ), "Test", "Check for defaultValue attribute" ); + assert.equal( jQuery( "#select2" ).prop( "selectedIndex" ), 3, "Check for selectedIndex attribute" ); + assert.equal( jQuery( "#foo" ).prop( "nodeName" ).toUpperCase(), "DIV", "Check for nodeName attribute" ); + assert.equal( jQuery( "#foo" ).prop( "tagName" ).toUpperCase(), "DIV", "Check for tagName attribute" ); + assert.equal( jQuery( "<option/>" ).prop( "selected" ), false, "Check selected attribute on disconnected element." ); - equal( jQuery( "#listWithTabIndex" ).prop( "tabindex" ), 5, "Check retrieving tabindex" ); + assert.equal( jQuery( "#listWithTabIndex" ).prop( "tabindex" ), 5, "Check retrieving tabindex" ); jQuery( "#text1" ).prop( "readonly", true ); - equal( document.getElementById( "text1" ).readOnly, true, "Check setting readOnly property with 'readonly'" ); - equal( jQuery( "#label-for" ).prop( "for" ), "action", "Check retrieving htmlFor" ); + assert.equal( document.getElementById( "text1" ).readOnly, true, "Check setting readOnly property with 'readonly'" ); + assert.equal( jQuery( "#label-for" ).prop( "for" ), "action", "Check retrieving htmlFor" ); jQuery( "#text1" ).prop( "class", "test" ); - equal( document.getElementById( "text1" ).className, "test", "Check setting className with 'class'" ); - equal( jQuery( "#text1" ).prop( "maxlength" ), 30, "Check retrieving maxLength" ); + assert.equal( document.getElementById( "text1" ).className, "test", "Check setting className with 'class'" ); + assert.equal( jQuery( "#text1" ).prop( "maxlength" ), 30, "Check retrieving maxLength" ); jQuery( "#table" ).prop( "cellspacing", 1 ); - equal( jQuery( "#table" ).prop( "cellSpacing" ), "1", "Check setting and retrieving cellSpacing" ); + assert.equal( jQuery( "#table" ).prop( "cellSpacing" ), "1", "Check setting and retrieving cellSpacing" ); jQuery( "#table" ).prop( "cellpadding", 1 ); - equal( jQuery( "#table" ).prop( "cellPadding" ), "1", "Check setting and retrieving cellPadding" ); + assert.equal( jQuery( "#table" ).prop( "cellPadding" ), "1", "Check setting and retrieving cellPadding" ); jQuery( "#table" ).prop( "rowspan", 1 ); - equal( jQuery( "#table" ).prop( "rowSpan" ), 1, "Check setting and retrieving rowSpan" ); + assert.equal( jQuery( "#table" ).prop( "rowSpan" ), 1, "Check setting and retrieving rowSpan" ); jQuery( "#table" ).prop( "colspan", 1 ); - equal( jQuery( "#table" ).prop( "colSpan" ), 1, "Check setting and retrieving colSpan" ); + assert.equal( jQuery( "#table" ).prop( "colSpan" ), 1, "Check setting and retrieving colSpan" ); jQuery( "#table" ).prop( "usemap", 1 ); - equal( jQuery( "#table" ).prop( "useMap" ), 1, "Check setting and retrieving useMap" ); + assert.equal( jQuery( "#table" ).prop( "useMap" ), 1, "Check setting and retrieving useMap" ); jQuery( "#table" ).prop( "frameborder", 1 ); - equal( jQuery( "#table" ).prop( "frameBorder" ), 1, "Check setting and retrieving frameBorder" ); + assert.equal( jQuery( "#table" ).prop( "frameBorder" ), 1, "Check setting and retrieving frameBorder" ); } ); -test( "prop(String, Object) on null/undefined", function() { +QUnit.test( "prop(String, Object) on null/undefined", function( assert ) { - expect( 14 ); + assert.expect( 14 ); var select, optgroup, option, attributeNode, commentNode, textNode, obj, $form, body = document.body, $body = jQuery( body ); - ok( $body.prop( "nextSibling" ) === null, "Make sure a null expando returns null" ); + assert.ok( $body.prop( "nextSibling" ) === null, "Make sure a null expando returns null" ); body[ "foo" ] = "bar"; - equal( $body.prop( "foo" ), "bar", "Make sure the expando is preferred over the dom attribute" ); + assert.equal( $body.prop( "foo" ), "bar", "Make sure the expando is preferred over the dom attribute" ); body[ "foo" ] = undefined; - ok( $body.prop( "foo" ) === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" ); + assert.ok( $body.prop( "foo" ) === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" ); select = document.createElement( "select" ); optgroup = document.createElement( "optgroup" ); @@ -687,103 +687,103 @@ test( "prop(String, Object) on null/undefined", function() { optgroup.appendChild( option ); select.appendChild( optgroup ); - equal( jQuery( option ).prop( "selected" ), true, "Make sure that a single option is selected, even when in an optgroup." ); - equal( jQuery( document ).prop( "nodeName" ), "#document", "prop works correctly on document nodes (bug #7451)." ); + assert.equal( jQuery( option ).prop( "selected" ), true, "Make sure that a single option is selected, even when in an optgroup." ); + assert.equal( jQuery( document ).prop( "nodeName" ), "#document", "prop works correctly on document nodes (bug #7451)." ); attributeNode = document.createAttribute( "irrelevant" ); commentNode = document.createComment( "some comment" ); textNode = document.createTextNode( "some text" ); obj = {}; jQuery.each( [ document, attributeNode, commentNode, textNode, obj, "#firstp" ], function( i, ele ) { - strictEqual( jQuery( ele ).prop( "nonexisting" ), undefined, "prop works correctly for non existing attributes (bug #7500)." ); + assert.strictEqual( jQuery( ele ).prop( "nonexisting" ), undefined, "prop works correctly for non existing attributes (bug #7500)." ); } ); obj = {}; jQuery.each( [ document, obj ], function( i, ele ) { var $ele = jQuery( ele ); $ele.prop( "nonexisting", "foo" ); - equal( $ele.prop( "nonexisting" ), "foo", "prop(name, value) works correctly for non existing attributes (bug #7500)." ); + assert.equal( $ele.prop( "nonexisting" ), "foo", "prop(name, value) works correctly for non existing attributes (bug #7500)." ); } ); jQuery( document ).removeProp( "nonexisting" ); $form = jQuery( "#form" ).prop( "enctype", "multipart/form-data" ); - equal( $form.prop( "enctype" ), "multipart/form-data", "Set the enctype of a form (encoding in IE6/7 #6743)" ); + assert.equal( $form.prop( "enctype" ), "multipart/form-data", "Set the enctype of a form (encoding in IE6/7 #6743)" ); } ); -test( "prop('tabindex')", function() { - expect( 11 ); +QUnit.test( "prop('tabindex')", function( assert ) { + assert.expect( 11 ); // inputs without tabIndex attribute - equal( jQuery( "#inputWithoutTabIndex" ).prop( "tabindex" ), 0, "input without tabindex" ); - equal( jQuery( "#buttonWithoutTabIndex" ).prop( "tabindex" ), 0, "button without tabindex" ); - equal( jQuery( "#textareaWithoutTabIndex" ).prop( "tabindex" ), 0, "textarea without tabindex" ); + assert.equal( jQuery( "#inputWithoutTabIndex" ).prop( "tabindex" ), 0, "input without tabindex" ); + assert.equal( jQuery( "#buttonWithoutTabIndex" ).prop( "tabindex" ), 0, "button without tabindex" ); + assert.equal( jQuery( "#textareaWithoutTabIndex" ).prop( "tabindex" ), 0, "textarea without tabindex" ); // elements not natively tabbable - equal( jQuery( "#listWithTabIndex" ).prop( "tabindex" ), 5, "not natively tabbable, with tabindex set to 0" ); - equal( jQuery( "#divWithNoTabIndex" ).prop( "tabindex" ), -1, "not natively tabbable, no tabindex set" ); + assert.equal( jQuery( "#listWithTabIndex" ).prop( "tabindex" ), 5, "not natively tabbable, with tabindex set to 0" ); + assert.equal( jQuery( "#divWithNoTabIndex" ).prop( "tabindex" ), -1, "not natively tabbable, no tabindex set" ); // anchor with href - equal( jQuery( "#linkWithNoTabIndex" ).prop( "tabindex" ), 0, "anchor with href, no tabindex set" ); - equal( jQuery( "#linkWithTabIndex" ).prop( "tabindex" ), 2, "anchor with href, tabindex set to 2" ); - equal( jQuery( "#linkWithNegativeTabIndex" ).prop( "tabindex" ), -1, "anchor with href, tabindex set to -1" ); + assert.equal( jQuery( "#linkWithNoTabIndex" ).prop( "tabindex" ), 0, "anchor with href, no tabindex set" ); + assert.equal( jQuery( "#linkWithTabIndex" ).prop( "tabindex" ), 2, "anchor with href, tabindex set to 2" ); + assert.equal( jQuery( "#linkWithNegativeTabIndex" ).prop( "tabindex" ), -1, "anchor with href, tabindex set to -1" ); // anchor without href - equal( jQuery( "#linkWithNoHrefWithNoTabIndex" ).prop( "tabindex" ), -1, "anchor without href, no tabindex set" ); - equal( jQuery( "#linkWithNoHrefWithTabIndex" ).prop( "tabindex" ), 1, "anchor without href, tabindex set to 2" ); - equal( jQuery( "#linkWithNoHrefWithNegativeTabIndex" ).prop( "tabindex" ), -1, "anchor without href, no tabindex set" ); + assert.equal( jQuery( "#linkWithNoHrefWithNoTabIndex" ).prop( "tabindex" ), -1, "anchor without href, no tabindex set" ); + assert.equal( jQuery( "#linkWithNoHrefWithTabIndex" ).prop( "tabindex" ), 1, "anchor without href, tabindex set to 2" ); + assert.equal( jQuery( "#linkWithNoHrefWithNegativeTabIndex" ).prop( "tabindex" ), -1, "anchor without href, no tabindex set" ); } ); -test( "prop('tabindex', value)", function() { - expect( 10 ); +QUnit.test( "prop('tabindex', value)", function( assert ) { + assert.expect( 10 ); var clone, element = jQuery( "#divWithNoTabIndex" ); - equal( element.prop( "tabindex" ), -1, "start with no tabindex" ); + assert.equal( element.prop( "tabindex" ), -1, "start with no tabindex" ); // set a positive string element.prop( "tabindex", "1" ); - equal( element.prop( "tabindex" ), 1, "set tabindex to 1 (string)" ); + assert.equal( element.prop( "tabindex" ), 1, "set tabindex to 1 (string)" ); // set a zero string element.prop( "tabindex", "0" ); - equal( element.prop( "tabindex" ), 0, "set tabindex to 0 (string)" ); + assert.equal( element.prop( "tabindex" ), 0, "set tabindex to 0 (string)" ); // set a negative string element.prop( "tabindex", "-1" ); - equal( element.prop( "tabindex" ), -1, "set tabindex to -1 (string)" ); + assert.equal( element.prop( "tabindex" ), -1, "set tabindex to -1 (string)" ); // set a positive number element.prop( "tabindex", 1 ); - equal( element.prop( "tabindex" ), 1, "set tabindex to 1 (number)" ); + assert.equal( element.prop( "tabindex" ), 1, "set tabindex to 1 (number)" ); // set a zero number element.prop( "tabindex", 0 ); - equal( element.prop( "tabindex" ), 0, "set tabindex to 0 (number)" ); + assert.equal( element.prop( "tabindex" ), 0, "set tabindex to 0 (number)" ); // set a negative number element.prop( "tabindex", -1 ); - equal( element.prop( "tabindex" ), -1, "set tabindex to -1 (number)" ); + assert.equal( element.prop( "tabindex" ), -1, "set tabindex to -1 (number)" ); element = jQuery( "#linkWithTabIndex" ); - equal( element.prop( "tabindex" ), 2, "start with tabindex 2" ); + assert.equal( element.prop( "tabindex" ), 2, "start with tabindex 2" ); element.prop( "tabindex", -1 ); - equal( element.prop( "tabindex" ), -1, "set negative tabindex" ); + assert.equal( element.prop( "tabindex" ), -1, "set negative tabindex" ); clone = element.clone(); clone.prop( "tabindex", 1 ); - equal( clone[ 0 ].getAttribute( "tabindex" ), "1", "set tabindex on cloned element" ); + assert.equal( clone[ 0 ].getAttribute( "tabindex" ), "1", "set tabindex on cloned element" ); } ); -test( "removeProp(String)", function() { - expect( 6 ); +QUnit.test( "removeProp(String)", function( assert ) { + assert.expect( 6 ); var attributeNode = document.createAttribute( "irrelevant" ), commentNode = document.createComment( "some comment" ), textNode = document.createTextNode( "some text" ), obj = {}; - strictEqual( + assert.strictEqual( jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[ 0 ][ "nonexisting" ], undefined, "removeprop works correctly on DOM element nodes" @@ -792,66 +792,66 @@ test( "removeProp(String)", function() { jQuery.each( [ document, obj ], function( i, ele ) { var $ele = jQuery( ele ); $ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" ); - strictEqual( ele[ "nonexisting" ], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." ); + assert.strictEqual( ele[ "nonexisting" ], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." ); } ); jQuery.each( [ commentNode, textNode, attributeNode ], function( i, ele ) { var $ele = jQuery( ele ); $ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" ); - strictEqual( ele[ "nonexisting" ], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." ); + assert.strictEqual( ele[ "nonexisting" ], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." ); } ); } ); -test( "val() after modification", function() { - expect( 1 ); +QUnit.test( "val() after modification", function( assert ) { + assert.expect( 1 ); document.getElementById( "text1" ).value = "bla"; - equal( jQuery( "#text1" ).val(), "bla", "Check for modified value of input element" ); + assert.equal( jQuery( "#text1" ).val(), "bla", "Check for modified value of input element" ); } ); -test( "val()", function() { +QUnit.test( "val()", function( assert ) { - expect( 20 + ( jQuery.fn.serialize ? 6 : 0 ) ); + assert.expect( 20 + ( jQuery.fn.serialize ? 6 : 0 ) ); var checks, $button; - equal( jQuery( "#text1" ).val(), "Test", "Check for value of input element" ); + assert.equal( jQuery( "#text1" ).val(), "Test", "Check for value of input element" ); // ticket #1714 this caused a JS error in IE - equal( jQuery( "#first" ).val(), "", "Check a paragraph element to see if it has a value" ); - ok( jQuery( [] ).val() === undefined, "Check an empty jQuery object will return undefined from val" ); + assert.equal( jQuery( "#first" ).val(), "", "Check a paragraph element to see if it has a value" ); + assert.ok( jQuery( [] ).val() === undefined, "Check an empty jQuery object will return undefined from val" ); - equal( jQuery( "#select2" ).val(), "3", "Call val() on a single='single' select" ); + assert.equal( jQuery( "#select2" ).val(), "3", "Call val() on a single='single' select" ); - deepEqual( jQuery( "#select3" ).val(), [ "1", "2" ], "Call val() on a multiple='multiple' select" ); + assert.deepEqual( jQuery( "#select3" ).val(), [ "1", "2" ], "Call val() on a multiple='multiple' select" ); - equal( jQuery( "#option3c" ).val(), "2", "Call val() on a option element with value" ); + assert.equal( jQuery( "#option3c" ).val(), "2", "Call val() on a option element with value" ); - equal( jQuery( "#option3a" ).val(), "", "Call val() on a option element with empty value" ); + assert.equal( jQuery( "#option3a" ).val(), "", "Call val() on a option element with empty value" ); - equal( jQuery( "#option3e" ).val(), "no value", "Call val() on a option element with no value attribute" ); + assert.equal( jQuery( "#option3e" ).val(), "no value", "Call val() on a option element with no value attribute" ); - equal( jQuery( "#option3a" ).val(), "", "Call val() on a option element with no value attribute" ); + assert.equal( jQuery( "#option3a" ).val(), "", "Call val() on a option element with no value attribute" ); jQuery( "#select3" ).val( "" ); - deepEqual( jQuery( "#select3" ).val(), [ "" ], "Call val() on a multiple='multiple' select" ); + assert.deepEqual( jQuery( "#select3" ).val(), [ "" ], "Call val() on a multiple='multiple' select" ); - deepEqual( jQuery( "#select4" ).val(), [], "Call val() on multiple='multiple' select with all disabled options" ); + assert.deepEqual( jQuery( "#select4" ).val(), [], "Call val() on multiple='multiple' select with all disabled options" ); jQuery( "#select4 optgroup" ).add( "#select4 > [disabled]" ).attr( "disabled", false ); - deepEqual( jQuery( "#select4" ).val(), [ "2", "3" ], "Call val() on multiple='multiple' select with some disabled options" ); + assert.deepEqual( jQuery( "#select4" ).val(), [ "2", "3" ], "Call val() on multiple='multiple' select with some disabled options" ); jQuery( "#select4" ).attr( "disabled", true ); - deepEqual( jQuery( "#select4" ).val(), [ "2", "3" ], "Call val() on disabled multiple='multiple' select" ); + assert.deepEqual( jQuery( "#select4" ).val(), [ "2", "3" ], "Call val() on disabled multiple='multiple' select" ); - equal( jQuery( "#select5" ).val(), "3", "Check value on ambiguous select." ); + assert.equal( jQuery( "#select5" ).val(), "3", "Check value on ambiguous select." ); jQuery( "#select5" ).val( 1 ); - equal( jQuery( "#select5" ).val(), "1", "Check value on ambiguous select." ); + assert.equal( jQuery( "#select5" ).val(), "1", "Check value on ambiguous select." ); jQuery( "#select5" ).val( 3 ); - equal( jQuery( "#select5" ).val(), "3", "Check value on ambiguous select." ); + assert.equal( jQuery( "#select5" ).val(), "3", "Check value on ambiguous select." ); - strictEqual( + assert.strictEqual( jQuery( "<select name='select12584' id='select12584'><option value='1' disabled='disabled'>1</option></select>" ).val(), null, "Select-one with only option disabled (#12584)" @@ -860,44 +860,44 @@ test( "val()", function() { if ( jQuery.fn.serialize ) { checks = jQuery( "<input type='checkbox' name='test' value='1'/><input type='checkbox' name='test' value='2'/><input type='checkbox' name='test' value=''/><input type='checkbox' name='test'/>" ).appendTo( "#form" ); - deepEqual( checks.serialize(), "", "Get unchecked values." ); + assert.deepEqual( checks.serialize(), "", "Get unchecked values." ); - equal( checks.eq( 3 ).val(), "on", "Make sure a value of 'on' is provided if none is specified." ); + assert.equal( checks.eq( 3 ).val(), "on", "Make sure a value of 'on' is provided if none is specified." ); checks.val( [ "2" ] ); - deepEqual( checks.serialize(), "test=2", "Get a single checked value." ); + assert.deepEqual( checks.serialize(), "test=2", "Get a single checked value." ); checks.val( [ "1", "" ] ); - deepEqual( checks.serialize(), "test=1&test=", "Get multiple checked values." ); + assert.deepEqual( checks.serialize(), "test=1&test=", "Get multiple checked values." ); checks.val( [ "", "2" ] ); - deepEqual( checks.serialize(), "test=2&test=", "Get multiple checked values." ); + assert.deepEqual( checks.serialize(), "test=2&test=", "Get multiple checked values." ); checks.val( [ "1", "on" ] ); - deepEqual( checks.serialize(), "test=1&test=on", "Get multiple checked values." ); + assert.deepEqual( checks.serialize(), "test=1&test=on", "Get multiple checked values." ); checks.remove(); } $button = jQuery( "<button value='foobar'>text</button>" ).insertAfter( "#button" ); - equal( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" ); - equal( $button.val( "baz" ).html(), "text", "Setting the value does not change innerHTML" ); + assert.equal( $button.val(), "foobar", "Value retrieval on a button does not return innerHTML" ); + assert.equal( $button.val( "baz" ).html(), "text", "Setting the value does not change innerHTML" ); - equal( jQuery( "<option/>" ).val( "test" ).attr( "value" ), "test", "Setting value sets the value attribute" ); + assert.equal( jQuery( "<option/>" ).val( "test" ).attr( "value" ), "test", "Setting value sets the value attribute" ); } ); -test( "val() with non-matching values on dropdown list", function() { - expect( 3 ); +QUnit.test( "val() with non-matching values on dropdown list", function( assert ) { + assert.expect( 3 ); jQuery( "#select5" ).val( "" ); - equal( jQuery( "#select5" ).val(), null, "Non-matching set on select-one" ); + assert.equal( jQuery( "#select5" ).val(), null, "Non-matching set on select-one" ); var select6 = jQuery( "<select multiple id=\"select6\"><option value=\"1\">A</option><option value=\"2\">B</option></select>" ).appendTo( "#form" ); jQuery( select6 ).val( "nothing" ); - equal( jQuery( select6 ).val(), null, "Non-matching set (single value) on select-multiple" ); + assert.equal( jQuery( select6 ).val(), null, "Non-matching set (single value) on select-multiple" ); jQuery( select6 ).val( [ "nothing1", "nothing2" ] ); - equal( jQuery( select6 ).val(), null, "Non-matching set (array of values) on select-multiple" ); + assert.equal( jQuery( select6 ).val(), null, "Non-matching set (array of values) on select-multiple" ); select6.remove(); } ); @@ -905,19 +905,19 @@ test( "val() with non-matching values on dropdown list", function() { if ( "value" in document.createElement( "meter" ) && "value" in document.createElement( "progress" ) ) { - test( "val() respects numbers without exception (Bug #9319)", function() { + QUnit.test( "val() respects numbers without exception (Bug #9319)", function( assert ) { - expect( 4 ); + assert.expect( 4 ); var $meter = jQuery( "<meter min='0' max='10' value='5.6'></meter>" ), $progress = jQuery( "<progress max='10' value='1.5'></progress>" ); try { - equal( typeof $meter.val(), "number", "meter, returns a number and does not throw exception" ); - equal( $meter.val(), $meter[ 0 ].value, "meter, api matches host and does not throw exception" ); + assert.equal( typeof $meter.val(), "number", "meter, returns a number and does not throw exception" ); + assert.equal( $meter.val(), $meter[ 0 ].value, "meter, api matches host and does not throw exception" ); - equal( typeof $progress.val(), "number", "progress, returns a number and does not throw exception" ); - equal( $progress.val(), $progress[ 0 ].value, "progress, api matches host and does not throw exception" ); + assert.equal( typeof $progress.val(), "number", "progress, returns a number and does not throw exception" ); + assert.equal( $progress.val(), $progress[ 0 ].value, "progress, api matches host and does not throw exception" ); } catch ( e ) {} @@ -926,119 +926,119 @@ if ( "value" in document.createElement( "meter" ) && } ); } -var testVal = function( valueObj ) { - expect( 9 ); +var testVal = function( valueObj, assert ) { + assert.expect( 9 ); jQuery( "#text1" ).val( valueObj( "test" ) ); - equal( document.getElementById( "text1" ).value, "test", "Check for modified (via val(String)) value of input element" ); + assert.equal( document.getElementById( "text1" ).value, "test", "Check for modified (via val(String)) value of input element" ); jQuery( "#text1" ).val( valueObj( undefined ) ); - equal( document.getElementById( "text1" ).value, "", "Check for modified (via val(undefined)) value of input element" ); + assert.equal( document.getElementById( "text1" ).value, "", "Check for modified (via val(undefined)) value of input element" ); jQuery( "#text1" ).val( valueObj( 67 ) ); - equal( document.getElementById( "text1" ).value, "67", "Check for modified (via val(Number)) value of input element" ); + assert.equal( document.getElementById( "text1" ).value, "67", "Check for modified (via val(Number)) value of input element" ); jQuery( "#text1" ).val( valueObj( null ) ); - equal( document.getElementById( "text1" ).value, "", "Check for modified (via val(null)) value of input element" ); + assert.equal( document.getElementById( "text1" ).value, "", "Check for modified (via val(null)) value of input element" ); var j, $select = jQuery( "<select multiple><option value='1'/><option value='2'/></select>" ), $select1 = jQuery( "#select1" ); $select1.val( valueObj( "3" ) ); - equal( $select1.val(), "3", "Check for modified (via val(String)) value of select element" ); + assert.equal( $select1.val(), "3", "Check for modified (via val(String)) value of select element" ); $select1.val( valueObj( 2 ) ); - equal( $select1.val(), "2", "Check for modified (via val(Number)) value of select element" ); + assert.equal( $select1.val(), "2", "Check for modified (via val(Number)) value of select element" ); $select1.append( "<option value='4'>four</option>" ); $select1.val( valueObj( 4 ) ); - equal( $select1.val(), "4", "Should be possible to set the val() to a newly created option" ); + assert.equal( $select1.val(), "4", "Should be possible to set the val() to a newly created option" ); // using contents will get comments regular, text, and comment nodes j = jQuery( "#nonnodes" ).contents(); j.val( valueObj( "asdf" ) ); - equal( j.val(), "asdf", "Check node,textnode,comment with val()" ); + assert.equal( j.val(), "asdf", "Check node,textnode,comment with val()" ); j.removeAttr( "value" ); $select.val( valueObj( [ "1", "2" ] ) ); - deepEqual( $select.val(), [ "1", "2" ], "Should set array of values" ); + assert.deepEqual( $select.val(), [ "1", "2" ], "Should set array of values" ); }; -test( "val(String/Number)", function() { - testVal( bareObj ); +QUnit.test( "val(String/Number)", function( assert ) { + testVal( bareObj, assert ); } ); -test( "val(Function)", function() { - testVal( functionReturningObj ); +QUnit.test( "val(Function)", function( assert ) { + testVal( functionReturningObj, assert ); } ); -test( "val(Array of Numbers) (Bug #7123)", function() { - expect( 4 ); +QUnit.test( "val(Array of Numbers) (Bug #7123)", function( assert ) { + assert.expect( 4 ); jQuery( "#form" ).append( "<input type='checkbox' name='arrayTest' value='1' /><input type='checkbox' name='arrayTest' value='2' /><input type='checkbox' name='arrayTest' value='3' checked='checked' /><input type='checkbox' name='arrayTest' value='4' />" ); var elements = jQuery( "input[name=arrayTest]" ).val( [ 1, 2 ] ); - ok( elements[ 0 ].checked, "First element was checked" ); - ok( elements[ 1 ].checked, "Second element was checked" ); - ok( !elements[ 2 ].checked, "Third element was unchecked" ); - ok( !elements[ 3 ].checked, "Fourth element remained unchecked" ); + assert.ok( elements[ 0 ].checked, "First element was checked" ); + assert.ok( elements[ 1 ].checked, "Second element was checked" ); + assert.ok( !elements[ 2 ].checked, "Third element was unchecked" ); + assert.ok( !elements[ 3 ].checked, "Fourth element remained unchecked" ); elements.remove(); } ); -test( "val(Function) with incoming value", function() { - expect( 10 ); +QUnit.test( "val(Function) with incoming value", function( assert ) { + assert.expect( 10 ); var oldVal = jQuery( "#text1" ).val(); jQuery( "#text1" ).val( function( i, val ) { - equal( val, oldVal, "Make sure the incoming value is correct." ); + assert.equal( val, oldVal, "Make sure the incoming value is correct." ); return "test"; } ); - equal( document.getElementById( "text1" ).value, "test", "Check for modified (via val(String)) value of input element" ); + assert.equal( document.getElementById( "text1" ).value, "test", "Check for modified (via val(String)) value of input element" ); oldVal = jQuery( "#text1" ).val(); jQuery( "#text1" ).val( function( i, val ) { - equal( val, oldVal, "Make sure the incoming value is correct." ); + assert.equal( val, oldVal, "Make sure the incoming value is correct." ); return 67; } ); - equal( document.getElementById( "text1" ).value, "67", "Check for modified (via val(Number)) value of input element" ); + assert.equal( document.getElementById( "text1" ).value, "67", "Check for modified (via val(Number)) value of input element" ); oldVal = jQuery( "#select1" ).val(); jQuery( "#select1" ).val( function( i, val ) { - equal( val, oldVal, "Make sure the incoming value is correct." ); + assert.equal( val, oldVal, "Make sure the incoming value is correct." ); return "3"; } ); - equal( jQuery( "#select1" ).val(), "3", "Check for modified (via val(String)) value of select element" ); + assert.equal( jQuery( "#select1" ).val(), "3", "Check for modified (via val(String)) value of select element" ); oldVal = jQuery( "#select1" ).val(); jQuery( "#select1" ).val( function( i, val ) { - equal( val, oldVal, "Make sure the incoming value is correct." ); + assert.equal( val, oldVal, "Make sure the incoming value is correct." ); return 2; } ); - equal( jQuery( "#select1" ).val(), "2", "Check for modified (via val(Number)) value of select element" ); + assert.equal( jQuery( "#select1" ).val(), "2", "Check for modified (via val(Number)) value of select element" ); jQuery( "#select1" ).append( "<option value='4'>four</option>" ); oldVal = jQuery( "#select1" ).val(); jQuery( "#select1" ).val( function( i, val ) { - equal( val, oldVal, "Make sure the incoming value is correct." ); + assert.equal( val, oldVal, "Make sure the incoming value is correct." ); return 4; } ); - equal( jQuery( "#select1" ).val(), "4", "Should be possible to set the val() to a newly created option" ); + assert.equal( jQuery( "#select1" ).val(), "4", "Should be possible to set the val() to a newly created option" ); } ); // testing if a form.reset() breaks a subsequent call to a select element's .val() (in IE only) -test( "val(select) after form.reset() (Bug #2551)", function() { - expect( 3 ); +QUnit.test( "val(select) after form.reset() (Bug #2551)", function( assert ) { + assert.expect( 3 ); jQuery( "<form id='kk' name='kk'><select id='kkk'><option value='cf'>cf</option><option value='gf'>gf</option></select></form>" ).appendTo( "#qunit-fixture" ); @@ -1046,17 +1046,17 @@ test( "val(select) after form.reset() (Bug #2551)", function() { document[ "kk" ].reset(); - equal( jQuery( "#kkk" )[ 0 ].value, "cf", "Check value of select after form reset." ); - equal( jQuery( "#kkk" ).val(), "cf", "Check value of select after form reset." ); + assert.equal( jQuery( "#kkk" )[ 0 ].value, "cf", "Check value of select after form reset." ); + assert.equal( jQuery( "#kkk" ).val(), "cf", "Check value of select after form reset." ); // re-verify the multi-select is not broken (after form.reset) by our fix for single-select - deepEqual( jQuery( "#select3" ).val(), [ "1", "2" ], "Call val() on a multiple='multiple' select" ); + assert.deepEqual( jQuery( "#select3" ).val(), [ "1", "2" ], "Call val() on a multiple='multiple' select" ); jQuery( "#kk" ).remove(); } ); -var testAddClass = function( valueObj ) { - expect( 9 ); +var testAddClass = function( valueObj, assert ) { + assert.expect( 9 ); var pass, j, i, div = jQuery( "#qunit-fixture div" ); @@ -1068,50 +1068,50 @@ var testAddClass = function( valueObj ) { pass = false; } } - ok( pass, "Add Class" ); + assert.ok( pass, "Add Class" ); // using contents will get regular, text, and comment nodes j = jQuery( "#nonnodes" ).contents(); j.addClass( valueObj( "asdf" ) ); - ok( j.hasClass( "asdf" ), "Check node,textnode,comment for addClass" ); + assert.ok( j.hasClass( "asdf" ), "Check node,textnode,comment for addClass" ); div = jQuery( "<div/>" ); div.addClass( valueObj( "test" ) ); - equal( div.attr( "class" ), "test", "Make sure there's no extra whitespace." ); + assert.equal( div.attr( "class" ), "test", "Make sure there's no extra whitespace." ); div.attr( "class", " foo" ); div.addClass( valueObj( "test" ) ); - equal( div.attr( "class" ), "foo test", "Make sure there's no extra whitespace." ); + assert.equal( div.attr( "class" ), "foo test", "Make sure there's no extra whitespace." ); div.attr( "class", "foo" ); div.addClass( valueObj( "bar baz" ) ); - equal( div.attr( "class" ), "foo bar baz", "Make sure there isn't too much trimming." ); + assert.equal( div.attr( "class" ), "foo bar baz", "Make sure there isn't too much trimming." ); div.removeClass(); div.addClass( valueObj( "foo" ) ).addClass( valueObj( "foo" ) ); - equal( div.attr( "class" ), "foo", "Do not add the same class twice in separate calls." ); + assert.equal( div.attr( "class" ), "foo", "Do not add the same class twice in separate calls." ); div.addClass( valueObj( "fo" ) ); - equal( div.attr( "class" ), "foo fo", "Adding a similar class does not get interrupted." ); + assert.equal( div.attr( "class" ), "foo fo", "Adding a similar class does not get interrupted." ); div.removeClass().addClass( "wrap2" ); - ok( div.addClass( "wrap" ).hasClass( "wrap" ), "Can add similarly named classes" ); + assert.ok( div.addClass( "wrap" ).hasClass( "wrap" ), "Can add similarly named classes" ); div.removeClass(); div.addClass( valueObj( "bar bar" ) ); - equal( div.attr( "class" ), "bar", "Do not add the same class twice in the same call." ); + assert.equal( div.attr( "class" ), "bar", "Do not add the same class twice in the same call." ); }; -test( "addClass(String)", function() { - testAddClass( bareObj ); +QUnit.test( "addClass(String)", function( assert ) { + testAddClass( bareObj, assert ); } ); -test( "addClass(Function)", function() { - testAddClass( functionReturningObj ); +QUnit.test( "addClass(Function)", function( assert ) { + testAddClass( functionReturningObj, assert ); } ); -test( "addClass(Function) with incoming value", function() { - expect( 52 ); +QUnit.test( "addClass(Function) with incoming value", function( assert ) { + assert.expect( 52 ); var pass, i, div = jQuery( "#qunit-fixture div" ), old = div.map( function() { @@ -1120,7 +1120,7 @@ test( "addClass(Function) with incoming value", function() { div.addClass( function( i, val ) { if ( this.id !== "_firebugConsole" ) { - equal( val, old[ i ], "Make sure the incoming value is correct." ); + assert.equal( val, old[ i ], "Make sure the incoming value is correct." ); return "test"; } } ); @@ -1131,60 +1131,60 @@ test( "addClass(Function) with incoming value", function() { pass = false; } } - ok( pass, "Add Class" ); + assert.ok( pass, "Add Class" ); } ); -var testRemoveClass = function( valueObj ) { - expect( 8 ); +var testRemoveClass = function( valueObj, assert ) { + assert.expect( 8 ); var $set = jQuery( "#qunit-fixture div" ), div = document.createElement( "div" ); $set.addClass( "test" ).removeClass( valueObj( "test" ) ); - ok( !$set.is( ".test" ), "Remove Class" ); + assert.ok( !$set.is( ".test" ), "Remove Class" ); $set.addClass( "test" ).addClass( "foo" ).addClass( "bar" ); $set.removeClass( valueObj( "test" ) ).removeClass( valueObj( "bar" ) ).removeClass( valueObj( "foo" ) ); - ok( !$set.is( ".test,.bar,.foo" ), "Remove multiple classes" ); + assert.ok( !$set.is( ".test,.bar,.foo" ), "Remove multiple classes" ); // Make sure that a null value doesn't cause problems $set.eq( 0 ).addClass( "expected" ).removeClass( valueObj( null ) ); - ok( $set.eq( 0 ).is( ".expected" ), "Null value passed to removeClass" ); + assert.ok( $set.eq( 0 ).is( ".expected" ), "Null value passed to removeClass" ); $set.eq( 0 ).addClass( "expected" ).removeClass( valueObj( "" ) ); - ok( $set.eq( 0 ).is( ".expected" ), "Empty string passed to removeClass" ); + assert.ok( $set.eq( 0 ).is( ".expected" ), "Empty string passed to removeClass" ); // using contents will get regular, text, and comment nodes $set = jQuery( "#nonnodes" ).contents(); $set.removeClass( valueObj( "asdf" ) ); - ok( !$set.hasClass( "asdf" ), "Check node,textnode,comment for removeClass" ); + assert.ok( !$set.hasClass( "asdf" ), "Check node,textnode,comment for removeClass" ); jQuery( div ).removeClass( valueObj( "foo" ) ); - strictEqual( jQuery( div ).attr( "class" ), undefined, "removeClass doesn't create a class attribute" ); + assert.strictEqual( jQuery( div ).attr( "class" ), undefined, "removeClass doesn't create a class attribute" ); div.className = " test foo "; jQuery( div ).removeClass( valueObj( "foo" ) ); - equal( div.className, "test", "Make sure remaining className is trimmed." ); + assert.equal( div.className, "test", "Make sure remaining className is trimmed." ); div.className = " test "; jQuery( div ).removeClass( valueObj( "test" ) ); - equal( div.className, "", "Make sure there is nothing left after everything is removed." ); + assert.equal( div.className, "", "Make sure there is nothing left after everything is removed." ); }; -test( "removeClass(String) - simple", function() { - testRemoveClass( bareObj ); +QUnit.test( "removeClass(String) - simple", function( assert ) { + testRemoveClass( bareObj, assert ); } ); -test( "removeClass(Function) - simple", function() { - testRemoveClass( functionReturningObj ); +QUnit.test( "removeClass(Function) - simple", function( assert ) { + testRemoveClass( functionReturningObj, assert ); } ); -test( "removeClass(Function) with incoming value", function() { - expect( 52 ); +QUnit.test( "removeClass(Function) with incoming value", function( assert ) { + assert.expect( 52 ); var $divs = jQuery( "#qunit-fixture div" ).addClass( "test" ), old = $divs.map( function() { return jQuery( this ).attr( "class" ); @@ -1192,238 +1192,238 @@ test( "removeClass(Function) with incoming value", function() { $divs.removeClass( function( i, val ) { if ( this.id !== "_firebugConsole" ) { - equal( val, old[ i ], "Make sure the incoming value is correct." ); + assert.equal( val, old[ i ], "Make sure the incoming value is correct." ); return "test"; } } ); - ok( !$divs.is( ".test" ), "Remove Class" ); + assert.ok( !$divs.is( ".test" ), "Remove Class" ); } ); -test( "removeClass() removes duplicates", function() { - expect( 1 ); +QUnit.test( "removeClass() removes duplicates", function( assert ) { + assert.expect( 1 ); var $div = jQuery( jQuery.parseHTML( "<div class='x x x'></div>" ) ); $div.removeClass( "x" ); - ok( !$div.hasClass( "x" ), "Element with multiple same classes does not escape the wrath of removeClass()" ); + assert.ok( !$div.hasClass( "x" ), "Element with multiple same classes does not escape the wrath of removeClass()" ); } ); -test( "removeClass(undefined) is a no-op", function() { - expect( 1 ); +QUnit.test( "removeClass(undefined) is a no-op", function( assert ) { + assert.expect( 1 ); var $div = jQuery( "<div class='base second'></div>" ); $div.removeClass( undefined ); - ok( $div.hasClass( "base" ) && $div.hasClass( "second" ), "Element still has classes after removeClass(undefined)" ); + assert.ok( $div.hasClass( "base" ) && $div.hasClass( "second" ), "Element still has classes after removeClass(undefined)" ); } ); -var testToggleClass = function( valueObj ) { - expect( 17 ); +var testToggleClass = function( valueObj, assert ) { + assert.expect( 17 ); var e = jQuery( "#firstp" ); - ok( !e.is( ".test" ), "Assert class not present" ); + assert.ok( !e.is( ".test" ), "Assert class not present" ); e.toggleClass( valueObj( "test" ) ); - ok( e.is( ".test" ), "Assert class present" ); + assert.ok( e.is( ".test" ), "Assert class present" ); e.toggleClass( valueObj( "test" ) ); - ok( !e.is( ".test" ), "Assert class not present" ); + assert.ok( !e.is( ".test" ), "Assert class not present" ); // class name with a boolean e.toggleClass( valueObj( "test" ), false ); - ok( !e.is( ".test" ), "Assert class not present" ); + assert.ok( !e.is( ".test" ), "Assert class not present" ); e.toggleClass( valueObj( "test" ), true ); - ok( e.is( ".test" ), "Assert class present" ); + assert.ok( e.is( ".test" ), "Assert class present" ); e.toggleClass( valueObj( "test" ), false ); - ok( !e.is( ".test" ), "Assert class not present" ); + assert.ok( !e.is( ".test" ), "Assert class not present" ); // multiple class names e.addClass( "testA testB" ); - ok( e.is( ".testA.testB" ), "Assert 2 different classes present" ); + assert.ok( e.is( ".testA.testB" ), "Assert 2 different classes present" ); e.toggleClass( valueObj( "testB testC" ) ); - ok( ( e.is( ".testA.testC" ) && !e.is( ".testB" ) ), "Assert 1 class added, 1 class removed, and 1 class kept" ); + assert.ok( ( e.is( ".testA.testC" ) && !e.is( ".testB" ) ), "Assert 1 class added, 1 class removed, and 1 class kept" ); e.toggleClass( valueObj( "testA testC" ) ); - ok( ( !e.is( ".testA" ) && !e.is( ".testB" ) && !e.is( ".testC" ) ), "Assert no class present" ); + assert.ok( ( !e.is( ".testA" ) && !e.is( ".testB" ) && !e.is( ".testC" ) ), "Assert no class present" ); // toggleClass storage e.toggleClass( true ); - ok( e[ 0 ].className === "", "Assert class is empty (data was empty)" ); + assert.ok( e[ 0 ].className === "", "Assert class is empty (data was empty)" ); e.addClass( "testD testE" ); - ok( e.is( ".testD.testE" ), "Assert class present" ); + assert.ok( e.is( ".testD.testE" ), "Assert class present" ); e.toggleClass(); - ok( !e.is( ".testD.testE" ), "Assert class not present" ); - ok( jQuery._data( e[ 0 ], "__className__" ) === "testD testE", "Assert data was stored" ); + assert.ok( !e.is( ".testD.testE" ), "Assert class not present" ); + assert.ok( jQuery._data( e[ 0 ], "__className__" ) === "testD testE", "Assert data was stored" ); e.toggleClass(); - ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" ); + assert.ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" ); e.toggleClass( false ); - ok( !e.is( ".testD.testE" ), "Assert class not present" ); + assert.ok( !e.is( ".testD.testE" ), "Assert class not present" ); e.toggleClass( true ); - ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" ); + assert.ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" ); e.toggleClass(); e.toggleClass( false ); e.toggleClass(); - ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" ); + assert.ok( e.is( ".testD.testE" ), "Assert class present (restored from data)" ); // Cleanup e.removeClass( "testD" ); QUnit.expectJqData( this, e[ 0 ], "__className__" ); }; -test( "toggleClass(String|boolean|undefined[, boolean])", function() { - testToggleClass( bareObj ); +QUnit.test( "toggleClass(String|boolean|undefined[, boolean])", function( assert ) { + testToggleClass( bareObj, assert ); } ); -test( "toggleClass(Function[, boolean])", function() { - testToggleClass( functionReturningObj ); +QUnit.test( "toggleClass(Function[, boolean])", function( assert ) { + testToggleClass( functionReturningObj, assert ); } ); -test( "toggleClass(Function[, boolean]) with incoming value", function() { - expect( 14 ); +QUnit.test( "toggleClass(Function[, boolean]) with incoming value", function( assert ) { + assert.expect( 14 ); var e = jQuery( "#firstp" ), old = e.attr( "class" ) || ""; - ok( !e.is( ".test" ), "Assert class not present" ); + assert.ok( !e.is( ".test" ), "Assert class not present" ); e.toggleClass( function( i, val ) { - equal( old, val, "Make sure the incoming value is correct." ); + assert.equal( old, val, "Make sure the incoming value is correct." ); return "test"; } ); - ok( e.is( ".test" ), "Assert class present" ); + assert.ok( e.is( ".test" ), "Assert class present" ); old = e.attr( "class" ); e.toggleClass( function( i, val ) { - equal( old, val, "Make sure the incoming value is correct." ); + assert.equal( old, val, "Make sure the incoming value is correct." ); return "test"; } ); - ok( !e.is( ".test" ), "Assert class not present" ); + assert.ok( !e.is( ".test" ), "Assert class not present" ); old = e.attr( "class" ) || ""; // class name with a boolean e.toggleClass( function( i, val, state ) { - equal( old, val, "Make sure the incoming value is correct." ); - equal( state, false, "Make sure that the state is passed in." ); + assert.equal( old, val, "Make sure the incoming value is correct." ); + assert.equal( state, false, "Make sure that the state is passed in." ); return "test"; }, false ); - ok( !e.is( ".test" ), "Assert class not present" ); + assert.ok( !e.is( ".test" ), "Assert class not present" ); old = e.attr( "class" ) || ""; e.toggleClass( function( i, val, state ) { - equal( old, val, "Make sure the incoming value is correct." ); - equal( state, true, "Make sure that the state is passed in." ); + assert.equal( old, val, "Make sure the incoming value is correct." ); + assert.equal( state, true, "Make sure that the state is passed in." ); return "test"; }, true ); - ok( e.is( ".test" ), "Assert class present" ); + assert.ok( e.is( ".test" ), "Assert class present" ); old = e.attr( "class" ); e.toggleClass( function( i, val, state ) { - equal( old, val, "Make sure the incoming value is correct." ); - equal( state, false, "Make sure that the state is passed in." ); + assert.equal( old, val, "Make sure the incoming value is correct." ); + assert.equal( state, false, "Make sure that the state is passed in." ); return "test"; }, false ); - ok( !e.is( ".test" ), "Assert class not present" ); + assert.ok( !e.is( ".test" ), "Assert class not present" ); } ); -test( "addClass, removeClass, hasClass", function() { - expect( 17 ); +QUnit.test( "addClass, removeClass, hasClass", function( assert ) { + assert.expect( 17 ); var jq = jQuery( "<p>Hi</p>" ), x = jq[ 0 ]; jq.addClass( "hi" ); - equal( x.className, "hi", "Check single added class" ); + assert.equal( x.className, "hi", "Check single added class" ); jq.addClass( "foo bar" ); - equal( x.className, "hi foo bar", "Check more added classes" ); + assert.equal( x.className, "hi foo bar", "Check more added classes" ); jq.removeClass(); - equal( x.className, "", "Remove all classes" ); + assert.equal( x.className, "", "Remove all classes" ); jq.addClass( "hi foo bar" ); jq.removeClass( "foo" ); - equal( x.className, "hi bar", "Check removal of one class" ); + assert.equal( x.className, "hi bar", "Check removal of one class" ); - ok( jq.hasClass( "hi" ), "Check has1" ); - ok( jq.hasClass( "bar" ), "Check has2" ); + assert.ok( jq.hasClass( "hi" ), "Check has1" ); + assert.ok( jq.hasClass( "bar" ), "Check has2" ); jq = jQuery( "<p class='class1\nclass2\tcla.ss3\n\rclass4'></p>" ); - ok( jq.hasClass( "class1" ), "Check hasClass with line feed" ); - ok( jq.is( ".class1" ), "Check is with line feed" ); - ok( jq.hasClass( "class2" ), "Check hasClass with tab" ); - ok( jq.is( ".class2" ), "Check is with tab" ); - ok( jq.hasClass( "cla.ss3" ), "Check hasClass with dot" ); - ok( jq.hasClass( "class4" ), "Check hasClass with carriage return" ); - ok( jq.is( ".class4" ), "Check is with carriage return" ); + assert.ok( jq.hasClass( "class1" ), "Check hasClass with line feed" ); + assert.ok( jq.is( ".class1" ), "Check is with line feed" ); + assert.ok( jq.hasClass( "class2" ), "Check hasClass with tab" ); + assert.ok( jq.is( ".class2" ), "Check is with tab" ); + assert.ok( jq.hasClass( "cla.ss3" ), "Check hasClass with dot" ); + assert.ok( jq.hasClass( "class4" ), "Check hasClass with carriage return" ); + assert.ok( jq.is( ".class4" ), "Check is with carriage return" ); jq.removeClass( "class2" ); - ok( jq.hasClass( "class2" ) === false, "Check the class has been properly removed" ); + assert.ok( jq.hasClass( "class2" ) === false, "Check the class has been properly removed" ); jq.removeClass( "cla" ); - ok( jq.hasClass( "cla.ss3" ), "Check the dotted class has not been removed" ); + assert.ok( jq.hasClass( "cla.ss3" ), "Check the dotted class has not been removed" ); jq.removeClass( "cla.ss3" ); - ok( jq.hasClass( "cla.ss3" ) === false, "Check the dotted class has been removed" ); + assert.ok( jq.hasClass( "cla.ss3" ) === false, "Check the dotted class has been removed" ); jq.removeClass( "class4" ); - ok( jq.hasClass( "class4" ) === false, "Check the class has been properly removed" ); + assert.ok( jq.hasClass( "class4" ) === false, "Check the class has been properly removed" ); } ); -test( "addClass, removeClass, hasClass on many elements", function() { - expect( 19 ); +QUnit.test( "addClass, removeClass, hasClass on many elements", function( assert ) { + assert.expect( 19 ); var elem = jQuery( "<p>p0</p><p>p1</p><p>p2</p>" ); elem.addClass( "hi" ); - equal( elem[ 0 ].className, "hi", "Check single added class" ); - equal( elem[ 1 ].className, "hi", "Check single added class" ); - equal( elem[ 2 ].className, "hi", "Check single added class" ); + assert.equal( elem[ 0 ].className, "hi", "Check single added class" ); + assert.equal( elem[ 1 ].className, "hi", "Check single added class" ); + assert.equal( elem[ 2 ].className, "hi", "Check single added class" ); elem.addClass( "foo bar" ); - equal( elem[ 0 ].className, "hi foo bar", "Check more added classes" ); - equal( elem[ 1 ].className, "hi foo bar", "Check more added classes" ); - equal( elem[ 2 ].className, "hi foo bar", "Check more added classes" ); + assert.equal( elem[ 0 ].className, "hi foo bar", "Check more added classes" ); + assert.equal( elem[ 1 ].className, "hi foo bar", "Check more added classes" ); + assert.equal( elem[ 2 ].className, "hi foo bar", "Check more added classes" ); elem.removeClass(); - equal( elem[ 0 ].className, "", "Remove all classes" ); - equal( elem[ 1 ].className, "", "Remove all classes" ); - equal( elem[ 2 ].className, "", "Remove all classes" ); + assert.equal( elem[ 0 ].className, "", "Remove all classes" ); + assert.equal( elem[ 1 ].className, "", "Remove all classes" ); + assert.equal( elem[ 2 ].className, "", "Remove all classes" ); elem.addClass( "hi foo bar" ); elem.removeClass( "foo" ); - equal( elem[ 0 ].className, "hi bar", "Check removal of one class" ); - equal( elem[ 1 ].className, "hi bar", "Check removal of one class" ); - equal( elem[ 2 ].className, "hi bar", "Check removal of one class" ); + assert.equal( elem[ 0 ].className, "hi bar", "Check removal of one class" ); + assert.equal( elem[ 1 ].className, "hi bar", "Check removal of one class" ); + assert.equal( elem[ 2 ].className, "hi bar", "Check removal of one class" ); - ok( elem.hasClass( "hi" ), "Check has1" ); - ok( elem.hasClass( "bar" ), "Check has2" ); + assert.ok( elem.hasClass( "hi" ), "Check has1" ); + assert.ok( elem.hasClass( "bar" ), "Check has2" ); - ok( jQuery( "<p class='hi'>p0</p><p>p1</p><p>p2</p>" ).hasClass( "hi" ), + assert.ok( jQuery( "<p class='hi'>p0</p><p>p1</p><p>p2</p>" ).hasClass( "hi" ), "Did find a class in the first element" ); - ok( jQuery( "<p>p0</p><p class='hi'>p1</p><p>p2</p>" ).hasClass( "hi" ), + assert.ok( jQuery( "<p>p0</p><p class='hi'>p1</p><p>p2</p>" ).hasClass( "hi" ), "Did find a class in the second element" ); - ok( jQuery( "<p>p0</p><p>p1</p><p class='hi'>p2</p>" ).hasClass( "hi" ), + assert.ok( jQuery( "<p>p0</p><p>p1</p><p class='hi'>p2</p>" ).hasClass( "hi" ), "Did find a class in the last element" ); - ok( jQuery( "<p class='hi'>p0</p><p class='hi'>p1</p><p class='hi'>p2</p>" ).hasClass( "hi" ), + assert.ok( jQuery( "<p class='hi'>p0</p><p class='hi'>p1</p><p class='hi'>p2</p>" ).hasClass( "hi" ), "Did find a class when present in all elements" ); - ok( !jQuery( "<p class='hi0'>p0</p><p class='hi1'>p1</p><p class='hi2'>p2</p>" ).hasClass( "hi" ), + assert.ok( !jQuery( "<p class='hi0'>p0</p><p class='hi1'>p1</p><p class='hi2'>p2</p>" ).hasClass( "hi" ), "Did not find a class when not present" ); } ); -test( "contents().hasClass() returns correct values", function() { - expect( 2 ); +QUnit.test( "contents().hasClass() returns correct values", function( assert ) { + assert.expect( 2 ); var $div = jQuery( "<div><span class='foo'></span><!-- comment -->text</div>" ), $contents = $div.contents(); - ok( $contents.hasClass( "foo" ), "Found 'foo' in $contents" ); - ok( !$contents.hasClass( "undefined" ), "Did not find 'undefined' in $contents (correctly)" ); + assert.ok( $contents.hasClass( "foo" ), "Found 'foo' in $contents" ); + assert.ok( !$contents.hasClass( "undefined" ), "Did not find 'undefined' in $contents (correctly)" ); } ); -test( "hasClass correctly interprets non-space separators (#13835)", function() { - expect( 4 ); +QUnit.test( "hasClass correctly interprets non-space separators (#13835)", function( assert ) { + assert.expect( 4 ); var map = { @@ -1438,63 +1438,63 @@ test( "hasClass correctly interprets non-space separators (#13835)", function() $div = jQuery( "<div class='" + classes + "'></div>" ); jQuery.each( map, function( label ) { - ok( $div.hasClass( label ), label.replace( "-", " " ) ); + assert.ok( $div.hasClass( label ), label.replace( "-", " " ) ); } ); } ); -test( "coords returns correct values in IE6/IE7, see #10828", function() { - expect( 1 ); +QUnit.test( "coords returns correct values in IE6/IE7, see #10828", function( assert ) { + assert.expect( 1 ); var area, map = jQuery( "<map />" ); area = map.html( "<area shape='rect' coords='0,0,0,0' href='#' alt='a' />" ).find( "area" ); - equal( area.attr( "coords" ), "0,0,0,0", "did not retrieve coords correctly" ); + assert.equal( area.attr( "coords" ), "0,0,0,0", "did not retrieve coords correctly" ); } ); -test( "should not throw at $(option).val() (#14686)", function() { - expect( 1 ); +QUnit.test( "should not throw at $(option).val() (#14686)", function( assert ) { + assert.expect( 1 ); try { jQuery( "<option/>" ).val(); - ok( true ); + assert.ok( true ); } catch ( _ ) { - ok( false ); + assert.ok( false ); } } ); -test( "option value not trimmed when setting via parent select", function() { - expect( 1 ); - equal( jQuery( "<select><option> 2</option></select>" ).val( "2" ).val(), "2" ); +QUnit.test( "option value not trimmed when setting via parent select", function( assert ) { + assert.expect( 1 ); + assert.equal( jQuery( "<select><option> 2</option></select>" ).val( "2" ).val(), "2" ); } ); -test( "Insignificant white space returned for $(option).val() (#14858)", function() { +QUnit.test( "Insignificant white space returned for $(option).val() (#14858)", function( assert ) { expect ( 3 ); var val = jQuery( "<option></option>" ).val(); - equal( val.length, 0, "Empty option should have no value" ); + assert.equal( val.length, 0, "Empty option should have no value" ); val = jQuery( "<option> </option>" ).val(); - equal( val.length, 0, "insignificant white-space returned for value" ); + assert.equal( val.length, 0, "insignificant white-space returned for value" ); val = jQuery( "<option> test </option>" ).val(); - equal( val.length, 4, "insignificant white-space returned for value" ); + assert.equal( val.length, 4, "insignificant white-space returned for value" ); } ); -test( "SVG class manipulation (gh-2199)", function() { +QUnit.test( "SVG class manipulation (gh-2199)", function( assert ) { // Support: IE8 var svgSupport = !!document.createElementNS && !!document.createElementNS( "http://www.w3.org/2000/svg", "svg" ).createSVGRect; if ( !svgSupport ) { - expect( 1 ); - ok( true, "Environment doesn't support SVG" ); + assert.expect( 1 ); + assert.ok( true, "Environment doesn't support SVG" ); return; } - expect( 12 ); + assert.expect( 12 ); function createSVGElement( nodeName ) { return document.createElementNS( "http://www.w3.org/2000/svg", nodeName ); @@ -1508,15 +1508,15 @@ test( "SVG class manipulation (gh-2199)", function() { var elem = jQuery( createSVGElement( this ) ); elem.addClass( "awesome" ); - ok( elem.hasClass( "awesome" ), "SVG element (" + this + ") has added class" ); + assert.ok( elem.hasClass( "awesome" ), "SVG element (" + this + ") has added class" ); elem.removeClass( "awesome" ); - ok( !elem.hasClass( "awesome" ), "SVG element (" + this + ") removes the class" ); + assert.ok( !elem.hasClass( "awesome" ), "SVG element (" + this + ") removes the class" ); elem.toggleClass( "awesome" ); - ok( elem.hasClass( "awesome" ), "SVG element (" + this + ") toggles the class on" ); + assert.ok( elem.hasClass( "awesome" ), "SVG element (" + this + ") toggles the class on" ); elem.toggleClass( "awesome" ); - ok( !elem.hasClass( "awesome" ), "SVG element (" + this + ") toggles the class off" ); + assert.ok( !elem.hasClass( "awesome" ), "SVG element (" + this + ") toggles the class off" ); } ); } ); diff --git a/test/unit/callbacks.js b/test/unit/callbacks.js index 089047f03..c6c379ded 100644 --- a/test/unit/callbacks.js +++ b/test/unit/callbacks.js @@ -1,4 +1,4 @@ -module( "callbacks", { +QUnit.module( "callbacks", { teardown: moduleTeardown } ); @@ -63,9 +63,9 @@ jQuery.each( tests, function( strFlags, resultString ) { "object": objectFlags }, function( flagsTypes, flags ) { - test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function() { + QUnit.test( "jQuery.Callbacks( " + showFlags( flags ) + " ) - " + filterLabel, function( assert ) { - expect( 29 ); + assert.expect( 29 ); var cblist, results = resultString.split( /\s+/ ); @@ -73,32 +73,32 @@ jQuery.each( tests, function( strFlags, resultString ) { // Basic binding and firing output = "X"; cblist = jQuery.Callbacks( flags ); - strictEqual( cblist.locked(), false, ".locked() initially false" ); - strictEqual( cblist.disabled(), false, ".disabled() initially false" ); - strictEqual( cblist.fired(), false, ".fired() initially false" ); + assert.strictEqual( cblist.locked(), false, ".locked() initially false" ); + assert.strictEqual( cblist.disabled(), false, ".disabled() initially false" ); + assert.strictEqual( cblist.fired(), false, ".fired() initially false" ); cblist.add( function( str ) { output += str; } ); - strictEqual( cblist.fired(), false, ".fired() still false after .add" ); + assert.strictEqual( cblist.fired(), false, ".fired() still false after .add" ); cblist.fire( "A" ); - strictEqual( output, "XA", "Basic binding and firing" ); - strictEqual( cblist.fired(), true, ".fired() detects firing" ); + assert.strictEqual( output, "XA", "Basic binding and firing" ); + assert.strictEqual( cblist.fired(), true, ".fired() detects firing" ); output = "X"; cblist.disable(); cblist.add( function( str ) { output += str; } ); - strictEqual( output, "X", "Adding a callback after disabling" ); + assert.strictEqual( output, "X", "Adding a callback after disabling" ); cblist.fire( "A" ); - strictEqual( output, "X", "Firing after disabling" ); - strictEqual( cblist.disabled(), true, ".disabled() becomes true" ); - strictEqual( cblist.locked(), true, "disabling locks" ); + assert.strictEqual( output, "X", "Firing after disabling" ); + assert.strictEqual( cblist.disabled(), true, ".disabled() becomes true" ); + assert.strictEqual( cblist.locked(), true, "disabling locks" ); // Emptying while firing (#13517) cblist = jQuery.Callbacks( flags ); cblist.add( cblist.empty ); cblist.add( function() { - ok( false, "not emptied" ); + assert.ok( false, "not emptied" ); } ); cblist.fire(); @@ -106,7 +106,7 @@ jQuery.each( tests, function( strFlags, resultString ) { cblist = jQuery.Callbacks( flags ); cblist.add( cblist.disable ); cblist.add( function() { - ok( false, "not disabled" ); + assert.ok( false, "not disabled" ); } ); cblist.fire(); @@ -114,18 +114,18 @@ jQuery.each( tests, function( strFlags, resultString ) { output = "X"; cblist = jQuery.Callbacks( flags ); cblist.add( function() { - equal( this, window, "Basic binding and firing (context)" ); + assert.equal( this, window, "Basic binding and firing (context)" ); output += Array.prototype.join.call( arguments, "" ); } ); cblist.fireWith( window, [ "A", "B" ] ); - strictEqual( output, "XAB", "Basic binding and firing (arguments)" ); + assert.strictEqual( output, "XAB", "Basic binding and firing (arguments)" ); // fireWith with no arguments output = ""; cblist = jQuery.Callbacks( flags ); cblist.add( function() { - equal( this, window, "fireWith with no arguments (context is window)" ); - strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" ); + assert.equal( this, window, "fireWith with no arguments (context is window)" ); + assert.strictEqual( arguments.length, 0, "fireWith with no arguments (no arguments)" ); } ); cblist.fireWith(); @@ -135,7 +135,7 @@ jQuery.each( tests, function( strFlags, resultString ) { cblist.add( outputA, outputB, outputC ); cblist.remove( outputB, outputC ); cblist.fire(); - strictEqual( output, "XA", "Basic binding, removing and firing" ); + assert.strictEqual( output, "XA", "Basic binding, removing and firing" ); // Empty output = "X"; @@ -145,7 +145,7 @@ jQuery.each( tests, function( strFlags, resultString ) { cblist.add( outputC ); cblist.empty(); cblist.fire(); - strictEqual( output, "X", "Empty" ); + assert.strictEqual( output, "X", "Empty" ); // Locking output = "X"; @@ -161,8 +161,8 @@ jQuery.each( tests, function( strFlags, resultString ) { cblist.add( function( str ) { output += str; } ); - strictEqual( output, "X", "Lock early" ); - strictEqual( cblist.locked(), true, "Locking reflected in accessor" ); + assert.strictEqual( output, "X", "Lock early" ); + assert.strictEqual( cblist.locked(), true, "Locking reflected in accessor" ); // Locking while firing (gh-1990) output = "X"; @@ -172,7 +172,7 @@ jQuery.each( tests, function( strFlags, resultString ) { output += str; } ); cblist.fire( "A" ); - strictEqual( output, "XA", "Locking doesn't abort execution (gh-1990)" ); + assert.strictEqual( output, "XA", "Locking doesn't abort execution (gh-1990)" ); // Ordering output = "X"; @@ -182,7 +182,7 @@ jQuery.each( tests, function( strFlags, resultString ) { outputA(); }, outputB ); cblist.fire(); - strictEqual( output, results.shift(), "Proper ordering" ); + assert.strictEqual( output, results.shift(), "Proper ordering" ); // Add and fire again output = "X"; @@ -190,11 +190,11 @@ jQuery.each( tests, function( strFlags, resultString ) { cblist.add( outputC ); outputA(); }, outputB ); - strictEqual( output, results.shift(), "Add after fire" ); + assert.strictEqual( output, results.shift(), "Add after fire" ); output = "X"; cblist.fire(); - strictEqual( output, results.shift(), "Fire again" ); + assert.strictEqual( output, results.shift(), "Fire again" ); // Multiple fire output = "X"; @@ -203,20 +203,20 @@ jQuery.each( tests, function( strFlags, resultString ) { output += str; } ); cblist.fire( "A" ); - strictEqual( output, "XA", "Multiple fire (first fire)" ); + assert.strictEqual( output, "XA", "Multiple fire (first fire)" ); output = "X"; cblist.add( function( str ) { output += str; } ); - strictEqual( output, results.shift(), "Multiple fire (first new callback)" ); + assert.strictEqual( output, results.shift(), "Multiple fire (first new callback)" ); output = "X"; cblist.fire( "B" ); - strictEqual( output, results.shift(), "Multiple fire (second fire)" ); + assert.strictEqual( output, results.shift(), "Multiple fire (second fire)" ); output = "X"; cblist.add( function( str ) { output += str; } ); - strictEqual( output, results.shift(), "Multiple fire (second new callback)" ); + assert.strictEqual( output, results.shift(), "Multiple fire (second new callback)" ); // Return false output = "X"; @@ -224,12 +224,12 @@ jQuery.each( tests, function( strFlags, resultString ) { cblist.add( outputA, function() { return false; }, outputB ); cblist.add( outputA ); cblist.fire(); - strictEqual( output, results.shift(), "Callback returning false" ); + assert.strictEqual( output, results.shift(), "Callback returning false" ); // Add another callback (to control lists with memory do not fire anymore) output = "X"; cblist.add( outputC ); - strictEqual( output, results.shift(), "Adding a callback after one returned false" ); + assert.strictEqual( output, results.shift(), "Adding a callback after one returned false" ); // Callbacks are not iterated output = ""; @@ -243,7 +243,7 @@ jQuery.each( tests, function( strFlags, resultString ) { cblist.add( handler ); cblist.add( handler ); cblist.fire(); - strictEqual( output, results.shift(), "No callback iteration" ); + assert.strictEqual( output, results.shift(), "No callback iteration" ); } ); } ); } ); @@ -251,9 +251,9 @@ jQuery.each( tests, function( strFlags, resultString ) { } )(); -test( "jQuery.Callbacks( options ) - options are copied", function() { +QUnit.test( "jQuery.Callbacks( options ) - options are copied", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var options = { "unique": true @@ -261,16 +261,16 @@ test( "jQuery.Callbacks( options ) - options are copied", function() { cb = jQuery.Callbacks( options ), count = 0, fn = function() { - ok( !( count++ ), "called once" ); + assert.ok( !( count++ ), "called once" ); }; options[ "unique" ] = false; cb.add( fn, fn ); cb.fire(); } ); -test( "jQuery.Callbacks.fireWith - arguments are copied", function() { +QUnit.test( "jQuery.Callbacks.fireWith - arguments are copied", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var cb = jQuery.Callbacks( "memory" ), args = [ "hello" ]; @@ -279,28 +279,28 @@ test( "jQuery.Callbacks.fireWith - arguments are copied", function() { args[ 0 ] = "world"; cb.add( function( hello ) { - strictEqual( hello, "hello", "arguments are copied internally" ); + assert.strictEqual( hello, "hello", "arguments are copied internally" ); } ); } ); -test( "jQuery.Callbacks.remove - should remove all instances", function() { +QUnit.test( "jQuery.Callbacks.remove - should remove all instances", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var cb = jQuery.Callbacks(); function fn() { - ok( false, "function wasn't removed" ); + assert.ok( false, "function wasn't removed" ); } cb.add( fn, fn, function() { - ok( true, "end of test" ); + assert.ok( true, "end of test" ); } ).remove( fn ).fire(); } ); -test( "jQuery.Callbacks.has", function() { +QUnit.test( "jQuery.Callbacks.has", function( assert ) { - expect( 13 ); + assert.expect( 13 ); var cb = jQuery.Callbacks(); function getA() { @@ -313,48 +313,48 @@ test( "jQuery.Callbacks.has", function() { return "C"; } cb.add( getA, getB, getC ); - strictEqual( cb.has(), true, "No arguments to .has() returns whether callback function(s) are attached or not" ); - strictEqual( cb.has( getA ), true, "Check if a specific callback function is in the Callbacks list" ); + assert.strictEqual( cb.has(), true, "No arguments to .has() returns whether callback function(s) are attached or not" ); + assert.strictEqual( cb.has( getA ), true, "Check if a specific callback function is in the Callbacks list" ); cb.remove( getB ); - strictEqual( cb.has( getB ), false, "Remove a specific callback function and make sure its no longer there" ); - strictEqual( cb.has( getA ), true, "Remove a specific callback function and make sure other callback function is still there" ); + assert.strictEqual( cb.has( getB ), false, "Remove a specific callback function and make sure its no longer there" ); + assert.strictEqual( cb.has( getA ), true, "Remove a specific callback function and make sure other callback function is still there" ); cb.empty(); - strictEqual( cb.has(), false, "Empty list and make sure there are no callback function(s)" ); - strictEqual( cb.has( getA ), false, "Check for a specific function in an empty() list" ); + assert.strictEqual( cb.has(), false, "Empty list and make sure there are no callback function(s)" ); + assert.strictEqual( cb.has( getA ), false, "Check for a specific function in an empty() list" ); cb.add( getA, getB, function() { - strictEqual( cb.has(), true, "Check if list has callback function(s) from within a callback function" ); - strictEqual( cb.has( getA ), true, "Check if list has a specific callback from within a callback function" ); + assert.strictEqual( cb.has(), true, "Check if list has callback function(s) from within a callback function" ); + assert.strictEqual( cb.has( getA ), true, "Check if list has a specific callback from within a callback function" ); } ).fire(); - strictEqual( cb.has(), true, "Callbacks list has callback function(s) after firing" ); + assert.strictEqual( cb.has(), true, "Callbacks list has callback function(s) after firing" ); cb.disable(); - strictEqual( cb.has(), false, "disabled() list has no callback functions (returns false)" ); - strictEqual( cb.has( getA ), false, "Check for a specific function in a disabled() list" ); + assert.strictEqual( cb.has(), false, "disabled() list has no callback functions (returns false)" ); + assert.strictEqual( cb.has( getA ), false, "Check for a specific function in a disabled() list" ); cb = jQuery.Callbacks( "unique" ); cb.add( getA ); cb.add( getA ); - strictEqual( cb.has(), true, "Check if unique list has callback function(s) attached" ); + assert.strictEqual( cb.has(), true, "Check if unique list has callback function(s) attached" ); cb.lock(); - strictEqual( cb.has(), false, "locked() list is empty and returns false" ); + assert.strictEqual( cb.has(), false, "locked() list is empty and returns false" ); } ); -test( "jQuery.Callbacks() - adding a string doesn't cause a stack overflow", function() { +QUnit.test( "jQuery.Callbacks() - adding a string doesn't cause a stack overflow", function( assert ) { - expect( 1 ); + assert.expect( 1 ); jQuery.Callbacks().add( "hello world" ); - ok( true, "no stack overflow" ); + assert.ok( true, "no stack overflow" ); } ); -test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", function() { +QUnit.test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var cb = jQuery.Callbacks(), fired = false, @@ -364,5 +364,5 @@ test( "jQuery.Callbacks() - disabled callback doesn't fire (gh-1790)", function( cb.empty(); cb.add( shot ); cb.fire(); - ok( !fired, "Disabled callback function didn't fire" ); + assert.ok( !fired, "Disabled callback function didn't fire" ); } ); diff --git a/test/unit/core.js b/test/unit/core.js index bf95ff04b..805ae4eaa 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -1,17 +1,17 @@ -module( "core", { teardown: moduleTeardown } ); - -test( "Basic requirements", function() { - expect( 7 ); - ok( Array.prototype.push, "Array.push()" ); - ok( Function.prototype.apply, "Function.apply()" ); - ok( document.getElementById, "getElementById" ); - ok( document.getElementsByTagName, "getElementsByTagName" ); - ok( RegExp, "RegExp" ); - ok( jQuery, "jQuery" ); - ok( $, "$" ); +QUnit.module( "core", { teardown: moduleTeardown } ); + +QUnit.test( "Basic requirements", function( assert ) { + assert.expect( 7 ); + assert.ok( Array.prototype.push, "Array.push()" ); + assert.ok( Function.prototype.apply, "Function.apply()" ); + assert.ok( document.getElementById, "getElementById" ); + assert.ok( document.getElementsByTagName, "getElementsByTagName" ); + assert.ok( RegExp, "RegExp" ); + assert.ok( jQuery, "jQuery" ); + assert.ok( $, "$" ); } ); -test( "jQuery()", function() { +QUnit.test( "jQuery()", function( assert ) { var elem, i, obj = jQuery( "div" ), @@ -49,24 +49,24 @@ test( "jQuery()", function() { attrObj.attr = { "desired": "very" }; } - expect( expected ); + assert.expect( expected ); // Basic constructor's behavior - equal( jQuery().length, 0, "jQuery() === jQuery([])" ); - equal( jQuery( undefined ).length, 0, "jQuery(undefined) === jQuery([])" ); - equal( jQuery( null ).length, 0, "jQuery(null) === jQuery([])" ); - equal( jQuery( "" ).length, 0, "jQuery('') === jQuery([])" ); - deepEqual( jQuery( obj ).get(), obj.get(), "jQuery(jQueryObj) == jQueryObj" ); + assert.equal( jQuery().length, 0, "jQuery() === jQuery([])" ); + assert.equal( jQuery( undefined ).length, 0, "jQuery(undefined) === jQuery([])" ); + assert.equal( jQuery( null ).length, 0, "jQuery(null) === jQuery([])" ); + assert.equal( jQuery( "" ).length, 0, "jQuery('') === jQuery([])" ); + assert.deepEqual( jQuery( obj ).get(), obj.get(), "jQuery(jQueryObj) == jQueryObj" ); // Invalid #id goes to Sizzle which will throw an error (gh-1682) try { jQuery( "#" ); } catch ( e ) { - ok( true, "Threw an error on #id with no id" ); + assert.ok( true, "Threw an error on #id with no id" ); } // can actually yield more than one, when iframes are included, the window is an array as well - equal( jQuery( window ).length, 1, "Correct number of elements generated for jQuery(window)" ); + assert.equal( jQuery( window ).length, 1, "Correct number of elements generated for jQuery(window)" ); /* // disabled since this test was doing nothing. i tried to fix it but i'm not sure @@ -74,7 +74,7 @@ test( "jQuery()", function() { // make sure this is handled var crlfContainer = jQuery('<p>\r\n</p>'); var x = crlfContainer.contents().get(0).nodeValue; - equal( x, what???, "Check for \\r and \\n in jQuery()" ); + assert.equal( x, what???, "Check for \\r and \\n in jQuery()" ); */ /* // Disabled until we add this functionality in @@ -84,50 +84,50 @@ test( "jQuery()", function() { } catch(e){ pass = false; } - ok( pass, "jQuery('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/ + assert.ok( pass, "jQuery('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/ - equal( code.length, 1, "Correct number of elements generated for code" ); - equal( code.parent().length, 0, "Make sure that the generated HTML has no parent." ); + assert.equal( code.length, 1, "Correct number of elements generated for code" ); + assert.equal( code.parent().length, 0, "Make sure that the generated HTML has no parent." ); - equal( img.length, 1, "Correct number of elements generated for img" ); - equal( img.parent().length, 0, "Make sure that the generated HTML has no parent." ); + assert.equal( img.length, 1, "Correct number of elements generated for img" ); + assert.equal( img.parent().length, 0, "Make sure that the generated HTML has no parent." ); - equal( div.length, 4, "Correct number of elements generated for div hr code b" ); - equal( div.parent().length, 0, "Make sure that the generated HTML has no parent." ); + assert.equal( div.length, 4, "Correct number of elements generated for div hr code b" ); + assert.equal( div.parent().length, 0, "Make sure that the generated HTML has no parent." ); - equal( jQuery( [ 1,2,3 ] ).get( 1 ), 2, "Test passing an array to the factory" ); + assert.equal( jQuery( [ 1,2,3 ] ).get( 1 ), 2, "Test passing an array to the factory" ); - equal( jQuery( document.body ).get( 0 ), jQuery( "body" ).get( 0 ), "Test passing an html node to the factory" ); + assert.equal( jQuery( document.body ).get( 0 ), jQuery( "body" ).get( 0 ), "Test passing an html node to the factory" ); elem = jQuery( " <em>hello</em>" )[ 0 ]; - equal( elem.nodeName.toLowerCase(), "em", "leading space" ); + assert.equal( elem.nodeName.toLowerCase(), "em", "leading space" ); elem = jQuery( "\n\n<em>world</em>" )[ 0 ]; - equal( elem.nodeName.toLowerCase(), "em", "leading newlines" ); + assert.equal( elem.nodeName.toLowerCase(), "em", "leading newlines" ); elem = jQuery( "<div/>", attrObj ); if ( jQuery.fn.width ) { - equal( elem[ 0 ].style.width, "10px", "jQuery() quick setter width" ); + assert.equal( elem[ 0 ].style.width, "10px", "jQuery() quick setter width" ); } if ( jQuery.fn.offset ) { - equal( elem[ 0 ].style.top, "1px", "jQuery() quick setter offset" ); + assert.equal( elem[ 0 ].style.top, "1px", "jQuery() quick setter offset" ); } if ( jQuery.fn.css ) { - equal( elem[ 0 ].style.paddingLeft, "1px", "jQuery quick setter css" ); - equal( elem[ 0 ].style.paddingRight, "1px", "jQuery quick setter css" ); + assert.equal( elem[ 0 ].style.paddingLeft, "1px", "jQuery quick setter css" ); + assert.equal( elem[ 0 ].style.paddingRight, "1px", "jQuery quick setter css" ); } if ( jQuery.fn.attr ) { - equal( elem[ 0 ].getAttribute( "desired" ), "very", "jQuery quick setter attr" ); + assert.equal( elem[ 0 ].getAttribute( "desired" ), "very", "jQuery quick setter attr" ); } - equal( elem[ 0 ].childNodes.length, 1, "jQuery quick setter text" ); - equal( elem[ 0 ].firstChild.nodeValue, "test", "jQuery quick setter text" ); - equal( elem[ 0 ].className, "test2", "jQuery() quick setter class" ); - equal( elem[ 0 ].id, "test3", "jQuery() quick setter id" ); + assert.equal( elem[ 0 ].childNodes.length, 1, "jQuery quick setter text" ); + assert.equal( elem[ 0 ].firstChild.nodeValue, "test", "jQuery quick setter text" ); + assert.equal( elem[ 0 ].className, "test2", "jQuery() quick setter class" ); + assert.equal( elem[ 0 ].id, "test3", "jQuery() quick setter id" ); exec = true; elem.trigger( "click" ); @@ -138,36 +138,36 @@ test( "jQuery()", function() { for ( i = 0; i < 3; ++i ) { elem = jQuery( "<input type='text' value='TEST' />" ); } - equal( elem[ 0 ].defaultValue, "TEST", "Ensure cached nodes are cloned properly (Bug #6655)" ); + assert.equal( elem[ 0 ].defaultValue, "TEST", "Ensure cached nodes are cloned properly (Bug #6655)" ); elem = jQuery( "<input type='hidden'>", {} ); - strictEqual( elem[ 0 ].ownerDocument, document, + assert.strictEqual( elem[ 0 ].ownerDocument, document, "Empty attributes object is not interpreted as a document (trac-8950)" ); } ); -test( "jQuery(selector, context)", function() { - expect( 3 ); - deepEqual( jQuery( "div p", "#qunit-fixture" ).get(), q( "sndp", "en", "sap" ), "Basic selector with string as context" ); - deepEqual( jQuery( "div p", q( "qunit-fixture" )[ 0 ] ).get(), q( "sndp", "en", "sap" ), "Basic selector with element as context" ); - deepEqual( jQuery( "div p", jQuery( "#qunit-fixture" ) ).get(), q( "sndp", "en", "sap" ), "Basic selector with jQuery object as context" ); +QUnit.test( "jQuery(selector, context)", function( assert ) { + assert.expect( 3 ); + assert.deepEqual( jQuery( "div p", "#qunit-fixture" ).get(), q( "sndp", "en", "sap" ), "Basic selector with string as context" ); + assert.deepEqual( jQuery( "div p", q( "qunit-fixture" )[ 0 ] ).get(), q( "sndp", "en", "sap" ), "Basic selector with element as context" ); + assert.deepEqual( jQuery( "div p", jQuery( "#qunit-fixture" ) ).get(), q( "sndp", "en", "sap" ), "Basic selector with jQuery object as context" ); } ); -test( "globalEval", function() { - expect( 3 ); +QUnit.test( "globalEval", function( assert ) { + assert.expect( 3 ); Globals.register( "globalEvalTest" ); jQuery.globalEval( "globalEvalTest = 1;" ); - equal( window.globalEvalTest, 1, "Test variable assignments are global" ); + assert.equal( window.globalEvalTest, 1, "Test variable assignments are global" ); jQuery.globalEval( "var globalEvalTest = 2;" ); - equal( window.globalEvalTest, 2, "Test variable declarations are global" ); + assert.equal( window.globalEvalTest, 2, "Test variable declarations are global" ); jQuery.globalEval( "this.globalEvalTest = 3;" ); - equal( window.globalEvalTest, 3, "Test context (this) is the window object" ); + assert.equal( window.globalEvalTest, 3, "Test context (this) is the window object" ); } ); -test( "globalEval execution after script injection (#7862)", function() { - expect( 1 ); +QUnit.test( "globalEval execution after script injection (#7862)", function( assert ) { + assert.expect( 1 ); var now, script = document.createElement( "script" ); @@ -178,126 +178,126 @@ test( "globalEval execution after script injection (#7862)", function() { document.body.appendChild( script ); jQuery.globalEval( "var strictEvalTest = " + jQuery.now() + ";" ); - ok( window.strictEvalTest - now < 500, "Code executed synchronously" ); + assert.ok( window.strictEvalTest - now < 500, "Code executed synchronously" ); } ); // This is not run in AMD mode if ( jQuery.noConflict ) { - test( "noConflict", function() { - expect( 7 ); + QUnit.test( "noConflict", function( assert ) { + assert.expect( 7 ); var $$ = jQuery; - strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" ); - strictEqual( window[ "jQuery" ], $$, "Make sure jQuery wasn't touched." ); - strictEqual( window[ "$" ], original$, "Make sure $ was reverted." ); + assert.strictEqual( jQuery, jQuery.noConflict(), "noConflict returned the jQuery object" ); + assert.strictEqual( window[ "jQuery" ], $$, "Make sure jQuery wasn't touched." ); + assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." ); jQuery = $ = $$; - strictEqual( jQuery.noConflict( true ), $$, "noConflict returned the jQuery object" ); - strictEqual( window[ "jQuery" ], originaljQuery, "Make sure jQuery was reverted." ); - strictEqual( window[ "$" ], original$, "Make sure $ was reverted." ); - ok( $$().pushStack( [] ), "Make sure that jQuery still works." ); + assert.strictEqual( jQuery.noConflict( true ), $$, "noConflict returned the jQuery object" ); + assert.strictEqual( window[ "jQuery" ], originaljQuery, "Make sure jQuery was reverted." ); + assert.strictEqual( window[ "$" ], original$, "Make sure $ was reverted." ); + assert.ok( $$().pushStack( [] ), "Make sure that jQuery still works." ); window[ "jQuery" ] = jQuery = $$; } ); } -test( "trim", function() { - expect( 13 ); +QUnit.test( "trim", function( assert ) { + assert.expect( 13 ); var nbsp = String.fromCharCode( 160 ); - equal( jQuery.trim( "hello " ), "hello", "trailing space" ); - equal( jQuery.trim( " hello" ), "hello", "leading space" ); - equal( jQuery.trim( " hello " ), "hello", "space on both sides" ); - equal( jQuery.trim( " " + nbsp + "hello " + nbsp + " " ), "hello", " " ); - - equal( jQuery.trim(), "", "Nothing in." ); - equal( jQuery.trim( undefined ), "", "Undefined" ); - equal( jQuery.trim( null ), "", "Null" ); - equal( jQuery.trim( 5 ), "5", "Number" ); - equal( jQuery.trim( false ), "false", "Boolean" ); - - equal( jQuery.trim( " " ), "", "space should be trimmed" ); - equal( jQuery.trim( "ipad\xA0" ), "ipad", "nbsp should be trimmed" ); - equal( jQuery.trim( "\uFEFF" ), "", "zwsp should be trimmed" ); - equal( jQuery.trim( "\uFEFF \xA0! | \uFEFF" ), "! |", "leading/trailing should be trimmed" ); + assert.equal( jQuery.trim( "hello " ), "hello", "trailing space" ); + assert.equal( jQuery.trim( " hello" ), "hello", "leading space" ); + assert.equal( jQuery.trim( " hello " ), "hello", "space on both sides" ); + assert.equal( jQuery.trim( " " + nbsp + "hello " + nbsp + " " ), "hello", " " ); + + assert.equal( jQuery.trim(), "", "Nothing in." ); + assert.equal( jQuery.trim( undefined ), "", "Undefined" ); + assert.equal( jQuery.trim( null ), "", "Null" ); + assert.equal( jQuery.trim( 5 ), "5", "Number" ); + assert.equal( jQuery.trim( false ), "false", "Boolean" ); + + assert.equal( jQuery.trim( " " ), "", "space should be trimmed" ); + assert.equal( jQuery.trim( "ipad\xA0" ), "ipad", "nbsp should be trimmed" ); + assert.equal( jQuery.trim( "\uFEFF" ), "", "zwsp should be trimmed" ); + assert.equal( jQuery.trim( "\uFEFF \xA0! | \uFEFF" ), "! |", "leading/trailing should be trimmed" ); } ); -test( "type", function() { - expect( 28 ); - - equal( jQuery.type( null ), "null", "null" ); - equal( jQuery.type( undefined ), "undefined", "undefined" ); - equal( jQuery.type( true ), "boolean", "Boolean" ); - equal( jQuery.type( false ), "boolean", "Boolean" ); - equal( jQuery.type( Boolean( true ) ), "boolean", "Boolean" ); - equal( jQuery.type( 0 ), "number", "Number" ); - equal( jQuery.type( 1 ), "number", "Number" ); - equal( jQuery.type( Number( 1 ) ), "number", "Number" ); - equal( jQuery.type( "" ), "string", "String" ); - equal( jQuery.type( "a" ), "string", "String" ); - equal( jQuery.type( String( "a" ) ), "string", "String" ); - equal( jQuery.type( {} ), "object", "Object" ); - equal( jQuery.type( /foo/ ), "regexp", "RegExp" ); - equal( jQuery.type( new RegExp( "asdf" ) ), "regexp", "RegExp" ); - equal( jQuery.type( [ 1 ] ), "array", "Array" ); - equal( jQuery.type( new Date() ), "date", "Date" ); - equal( jQuery.type( new Function( "return;" ) ), "function", "Function" ); - equal( jQuery.type( function() {} ), "function", "Function" ); - equal( jQuery.type( new Error() ), "error", "Error" ); - equal( jQuery.type( window ), "object", "Window" ); - equal( jQuery.type( document ), "object", "Document" ); - equal( jQuery.type( document.body ), "object", "Element" ); - equal( jQuery.type( document.createTextNode( "foo" ) ), "object", "TextNode" ); - equal( jQuery.type( document.getElementsByTagName( "*" ) ), "object", "NodeList" ); +QUnit.test( "type", function( assert ) { + assert.expect( 28 ); + + assert.equal( jQuery.type( null ), "null", "null" ); + assert.equal( jQuery.type( undefined ), "undefined", "undefined" ); + assert.equal( jQuery.type( true ), "boolean", "Boolean" ); + assert.equal( jQuery.type( false ), "boolean", "Boolean" ); + assert.equal( jQuery.type( Boolean( true ) ), "boolean", "Boolean" ); + assert.equal( jQuery.type( 0 ), "number", "Number" ); + assert.equal( jQuery.type( 1 ), "number", "Number" ); + assert.equal( jQuery.type( Number( 1 ) ), "number", "Number" ); + assert.equal( jQuery.type( "" ), "string", "String" ); + assert.equal( jQuery.type( "a" ), "string", "String" ); + assert.equal( jQuery.type( String( "a" ) ), "string", "String" ); + assert.equal( jQuery.type( {} ), "object", "Object" ); + assert.equal( jQuery.type( /foo/ ), "regexp", "RegExp" ); + assert.equal( jQuery.type( new RegExp( "asdf" ) ), "regexp", "RegExp" ); + assert.equal( jQuery.type( [ 1 ] ), "array", "Array" ); + assert.equal( jQuery.type( new Date() ), "date", "Date" ); + assert.equal( jQuery.type( new Function( "return;" ) ), "function", "Function" ); + assert.equal( jQuery.type( function() {} ), "function", "Function" ); + assert.equal( jQuery.type( new Error() ), "error", "Error" ); + assert.equal( jQuery.type( window ), "object", "Window" ); + assert.equal( jQuery.type( document ), "object", "Document" ); + assert.equal( jQuery.type( document.body ), "object", "Element" ); + assert.equal( jQuery.type( document.createTextNode( "foo" ) ), "object", "TextNode" ); + assert.equal( jQuery.type( document.getElementsByTagName( "*" ) ), "object", "NodeList" ); // Avoid Lint complaints var MyString = String, MyNumber = Number, MyBoolean = Boolean, MyObject = Object; - equal( jQuery.type( new MyBoolean( true ) ), "boolean", "Boolean" ); - equal( jQuery.type( new MyNumber( 1 ) ), "number", "Number" ); - equal( jQuery.type( new MyString( "a" ) ), "string", "String" ); - equal( jQuery.type( new MyObject() ), "object", "Object" ); + assert.equal( jQuery.type( new MyBoolean( true ) ), "boolean", "Boolean" ); + assert.equal( jQuery.type( new MyNumber( 1 ) ), "number", "Number" ); + assert.equal( jQuery.type( new MyString( "a" ) ), "string", "String" ); + assert.equal( jQuery.type( new MyObject() ), "object", "Object" ); } ); -asyncTest( "isPlainObject", function() { - expect( 16 ); +QUnit.asyncTest( "isPlainObject", function( assert ) { + assert.expect( 16 ); var pass, iframe, doc, fn = function() {}; // The use case that we want to match - ok( jQuery.isPlainObject( {} ), "{}" ); + assert.ok( jQuery.isPlainObject( {} ), "{}" ); // Not objects shouldn't be matched - ok( !jQuery.isPlainObject( "" ), "string" ); - ok( !jQuery.isPlainObject( 0 ) && !jQuery.isPlainObject( 1 ), "number" ); - ok( !jQuery.isPlainObject( true ) && !jQuery.isPlainObject( false ), "boolean" ); - ok( !jQuery.isPlainObject( null ), "null" ); - ok( !jQuery.isPlainObject( undefined ), "undefined" ); + assert.ok( !jQuery.isPlainObject( "" ), "string" ); + assert.ok( !jQuery.isPlainObject( 0 ) && !jQuery.isPlainObject( 1 ), "number" ); + assert.ok( !jQuery.isPlainObject( true ) && !jQuery.isPlainObject( false ), "boolean" ); + assert.ok( !jQuery.isPlainObject( null ), "null" ); + assert.ok( !jQuery.isPlainObject( undefined ), "undefined" ); // Arrays shouldn't be matched - ok( !jQuery.isPlainObject( [] ), "array" ); + assert.ok( !jQuery.isPlainObject( [] ), "array" ); // Instantiated objects shouldn't be matched - ok( !jQuery.isPlainObject( new Date() ), "new Date" ); + assert.ok( !jQuery.isPlainObject( new Date() ), "new Date" ); // Functions shouldn't be matched - ok( !jQuery.isPlainObject( fn ), "fn" ); + assert.ok( !jQuery.isPlainObject( fn ), "fn" ); // Again, instantiated objects shouldn't be matched - ok( !jQuery.isPlainObject( new fn() ), "new fn (no methods)" ); + assert.ok( !jQuery.isPlainObject( new fn() ), "new fn (no methods)" ); // Makes the function a little more realistic // (and harder to detect, incidentally) fn.prototype[ "someMethod" ] = function() {}; // Again, instantiated objects shouldn't be matched - ok( !jQuery.isPlainObject( new fn() ), "new fn" ); + assert.ok( !jQuery.isPlainObject( new fn() ), "new fn" ); // Make it even harder to detect in IE < 9 fn = function() { @@ -307,28 +307,28 @@ asyncTest( "isPlainObject", function() { b: "b" }; - ok( !jQuery.isPlainObject( new fn() ), "fn (inherited and own properties)" ); + assert.ok( !jQuery.isPlainObject( new fn() ), "fn (inherited and own properties)" ); // DOM Element - ok( !jQuery.isPlainObject( document.createElement( "div" ) ), "DOM Element" ); + assert.ok( !jQuery.isPlainObject( document.createElement( "div" ) ), "DOM Element" ); // Window - ok( !jQuery.isPlainObject( window ), "window" ); + assert.ok( !jQuery.isPlainObject( window ), "window" ); pass = false; try { jQuery.isPlainObject( window.location ); pass = true; } catch ( e ) {} - ok( pass, "Does not throw exceptions on host objects" ); + assert.ok( pass, "Does not throw exceptions on host objects" ); // Objects from other windows should be matched Globals.register( "iframeDone" ); window.iframeDone = function( otherObject, detail ) { window.iframeDone = undefined; iframe.parentNode.removeChild( iframe ); - ok( jQuery.isPlainObject( new otherObject() ), "new otherObject" + ( detail ? " - " + detail : "" ) ); - start(); + assert.ok( jQuery.isPlainObject( new otherObject() ), "new otherObject" + ( detail ? " - " + detail : "" ) ); + QUnit.start(); }; try { @@ -342,45 +342,45 @@ asyncTest( "isPlainObject", function() { } } ); -test( "isFunction", function() { - expect( 19 ); +QUnit.test( "isFunction", function( assert ) { + assert.expect( 19 ); var mystr, myarr, myfunction, fn, obj, nodes, first, input, a; // Make sure that false values return false - ok( !jQuery.isFunction(), "No Value" ); - ok( !jQuery.isFunction( null ), "null Value" ); - ok( !jQuery.isFunction( undefined ), "undefined Value" ); - ok( !jQuery.isFunction( "" ), "Empty String Value" ); - ok( !jQuery.isFunction( 0 ), "0 Value" ); + assert.ok( !jQuery.isFunction(), "No Value" ); + assert.ok( !jQuery.isFunction( null ), "null Value" ); + assert.ok( !jQuery.isFunction( undefined ), "undefined Value" ); + assert.ok( !jQuery.isFunction( "" ), "Empty String Value" ); + assert.ok( !jQuery.isFunction( 0 ), "0 Value" ); // Check built-ins // Safari uses "(Internal Function)" - ok( jQuery.isFunction( String ), "String Function(" + String + ")" ); - ok( jQuery.isFunction( Array ), "Array Function(" + Array + ")" ); - ok( jQuery.isFunction( Object ), "Object Function(" + Object + ")" ); - ok( jQuery.isFunction( Function ), "Function Function(" + Function + ")" ); + assert.ok( jQuery.isFunction( String ), "String Function(" + String + ")" ); + assert.ok( jQuery.isFunction( Array ), "Array Function(" + Array + ")" ); + assert.ok( jQuery.isFunction( Object ), "Object Function(" + Object + ")" ); + assert.ok( jQuery.isFunction( Function ), "Function Function(" + Function + ")" ); // When stringified, this could be misinterpreted mystr = "function"; - ok( !jQuery.isFunction( mystr ), "Function String" ); + assert.ok( !jQuery.isFunction( mystr ), "Function String" ); // When stringified, this could be misinterpreted myarr = [ "function" ]; - ok( !jQuery.isFunction( myarr ), "Function Array" ); + assert.ok( !jQuery.isFunction( myarr ), "Function Array" ); // When stringified, this could be misinterpreted myfunction = { "function": "test" }; - ok( !jQuery.isFunction( myfunction ), "Function Object" ); + assert.ok( !jQuery.isFunction( myfunction ), "Function Object" ); // Make sure normal functions still work fn = function() {}; - ok( jQuery.isFunction( fn ), "Normal Function" ); + assert.ok( jQuery.isFunction( fn ), "Normal Function" ); obj = document.createElement( "object" ); // Firefox says this is a function - ok( !jQuery.isFunction( obj ), "Object Element" ); + assert.ok( !jQuery.isFunction( obj ), "Object Element" ); // IE says this is an object // Since 1.3, this isn't supported (#2968) @@ -389,12 +389,12 @@ test( "isFunction", function() { nodes = document.body.childNodes; // Safari says this is a function - ok( !jQuery.isFunction( nodes ), "childNodes Property" ); + assert.ok( !jQuery.isFunction( nodes ), "childNodes Property" ); first = document.body.firstChild; // Normal elements are reported ok everywhere - ok( !jQuery.isFunction( first ), "A normal DOM Element" ); + assert.ok( !jQuery.isFunction( first ), "A normal DOM Element" ); input = document.createElement( "input" ); input.type = "text"; @@ -411,7 +411,7 @@ test( "isFunction", function() { document.body.appendChild( a ); // This serializes with the word 'function' in it - ok( !jQuery.isFunction( a ), "Anchor Element" ); + assert.ok( !jQuery.isFunction( a ), "Anchor Element" ); document.body.removeChild( a ); @@ -421,7 +421,7 @@ test( "isFunction", function() { callback( response ); } - ok( jQuery.isFunction( fn ), "Recursive Function Call" ); + assert.ok( jQuery.isFunction( fn ), "Recursive Function Call" ); fn( { some: "data" } ); } @@ -431,8 +431,8 @@ test( "isFunction", function() { } ); } ); -test( "isNumeric", function() { - expect( 38 ); +QUnit.test( "isNumeric", function( assert ) { + assert.expect( 38 ); var t = jQuery.isNumeric, ToString = function( value ) { @@ -441,53 +441,53 @@ test( "isNumeric", function() { }; }; - ok( t( "-10" ), "Negative integer string" ); - ok( t( "0" ), "Zero string" ); - ok( t( "5" ), "Positive integer string" ); - ok( t( -16 ), "Negative integer number" ); - ok( t( 0 ), "Zero integer number" ); - ok( t( 32 ), "Positive integer number" ); - ok( t( "040" ), "Octal integer literal string" ); - ok( t( "0xFF" ), "Hexadecimal integer literal string" ); - ok( t( 0xFFF ), "Hexadecimal integer literal" ); - ok( t( "-1.6" ), "Negative floating point string" ); - ok( t( "4.536" ), "Positive floating point string" ); - ok( t( -2.6 ), "Negative floating point number" ); - ok( t( 3.1415 ), "Positive floating point number" ); - ok( t( 1.5999999999999999 ), "Very precise floating point number" ); - ok( t( 8e5 ), "Exponential notation" ); - ok( t( "123e-2" ), "Exponential notation string" ); - ok( t( new ToString( "42" ) ), "Custom .toString returning number" ); - - equal( t( "" ), false, "Empty string" ); - equal( t( " " ), false, "Whitespace characters string" ); - equal( t( "\t\t" ), false, "Tab characters string" ); - equal( t( "abcdefghijklm1234567890" ), false, "Alphanumeric character string" ); - equal( t( "xabcdefx" ), false, "Non-numeric character string" ); - equal( t( true ), false, "Boolean true literal" ); - equal( t( false ), false, "Boolean false literal" ); - equal( t( "bcfed5.2" ), false, "Number with preceding non-numeric characters" ); - equal( t( "7.2acdgs" ), false, "Number with trailling non-numeric characters" ); - equal( t( undefined ), false, "Undefined value" ); - equal( t( null ), false, "Null value" ); - equal( t( NaN ), false, "NaN value" ); - equal( t( Infinity ), false, "Infinity primitive" ); - equal( t( Number.POSITIVE_INFINITY ), false, "Positive Infinity" ); - equal( t( Number.NEGATIVE_INFINITY ), false, "Negative Infinity" ); - equal( t( new ToString( "Devo" ) ), false, "Custom .toString returning non-number" ); - equal( t( {} ), false, "Empty object" ); - equal( t( [] ), false, "Empty array" ); - equal( t( [ 42 ] ), false, "Array with one number" ); - equal( t( function() {} ), false, "Instance of a function" ); - equal( t( new Date() ), false, "Instance of a Date" ); + assert.ok( t( "-10" ), "Negative integer string" ); + assert.ok( t( "0" ), "Zero string" ); + assert.ok( t( "5" ), "Positive integer string" ); + assert.ok( t( -16 ), "Negative integer number" ); + assert.ok( t( 0 ), "Zero integer number" ); + assert.ok( t( 32 ), "Positive integer number" ); + assert.ok( t( "040" ), "Octal integer literal string" ); + assert.ok( t( "0xFF" ), "Hexadecimal integer literal string" ); + assert.ok( t( 0xFFF ), "Hexadecimal integer literal" ); + assert.ok( t( "-1.6" ), "Negative floating point string" ); + assert.ok( t( "4.536" ), "Positive floating point string" ); + assert.ok( t( -2.6 ), "Negative floating point number" ); + assert.ok( t( 3.1415 ), "Positive floating point number" ); + assert.ok( t( 1.5999999999999999 ), "Very precise floating point number" ); + assert.ok( t( 8e5 ), "Exponential notation" ); + assert.ok( t( "123e-2" ), "Exponential notation string" ); + assert.ok( t( new ToString( "42" ) ), "Custom .toString returning number" ); + + assert.equal( t( "" ), false, "Empty string" ); + assert.equal( t( " " ), false, "Whitespace characters string" ); + assert.equal( t( "\t\t" ), false, "Tab characters string" ); + assert.equal( t( "abcdefghijklm1234567890" ), false, "Alphanumeric character string" ); + assert.equal( t( "xabcdefx" ), false, "Non-numeric character string" ); + assert.equal( t( true ), false, "Boolean true literal" ); + assert.equal( t( false ), false, "Boolean false literal" ); + assert.equal( t( "bcfed5.2" ), false, "Number with preceding non-numeric characters" ); + assert.equal( t( "7.2acdgs" ), false, "Number with trailling non-numeric characters" ); + assert.equal( t( undefined ), false, "Undefined value" ); + assert.equal( t( null ), false, "Null value" ); + assert.equal( t( NaN ), false, "NaN value" ); + assert.equal( t( Infinity ), false, "Infinity primitive" ); + assert.equal( t( Number.POSITIVE_INFINITY ), false, "Positive Infinity" ); + assert.equal( t( Number.NEGATIVE_INFINITY ), false, "Negative Infinity" ); + assert.equal( t( new ToString( "Devo" ) ), false, "Custom .toString returning non-number" ); + assert.equal( t( {} ), false, "Empty object" ); + assert.equal( t( [] ), false, "Empty array" ); + assert.equal( t( [ 42 ] ), false, "Array with one number" ); + assert.equal( t( function() {} ), false, "Instance of a function" ); + assert.equal( t( new Date() ), false, "Instance of a Date" ); } ); -test( "isXMLDoc - HTML", function() { - expect( 4 ); +QUnit.test( "isXMLDoc - HTML", function( assert ) { + assert.expect( 4 ); - ok( !jQuery.isXMLDoc( document ), "HTML document" ); - ok( !jQuery.isXMLDoc( document.documentElement ), "HTML documentElement" ); - ok( !jQuery.isXMLDoc( document.body ), "HTML Body Element" ); + assert.ok( !jQuery.isXMLDoc( document ), "HTML document" ); + assert.ok( !jQuery.isXMLDoc( document.documentElement ), "HTML documentElement" ); + assert.ok( !jQuery.isXMLDoc( document.body ), "HTML Body Element" ); var body, iframe = document.createElement( "iframe" ); @@ -497,27 +497,27 @@ test( "isXMLDoc - HTML", function() { body = jQuery( iframe ).contents()[ 0 ]; try { - ok( !jQuery.isXMLDoc( body ), "Iframe body element" ); + assert.ok( !jQuery.isXMLDoc( body ), "Iframe body element" ); } catch ( e ) { - ok( false, "Iframe body element exception" ); + assert.ok( false, "Iframe body element exception" ); } } catch ( e ) { - ok( true, "Iframe body element - iframe not working correctly" ); + assert.ok( true, "Iframe body element - iframe not working correctly" ); } document.body.removeChild( iframe ); } ); -test( "XSS via location.hash", function() { - expect( 1 ); +QUnit.test( "XSS via location.hash", function( assert ) { + assert.expect( 1 ); - stop(); + QUnit.stop(); jQuery[ "_check9521" ] = function( x ) { - ok( x, "script called from #id-like selector with inline handler" ); + assert.ok( x, "script called from #id-like selector with inline handler" ); jQuery( "#check9521" ).remove(); delete jQuery[ "_check9521" ]; - start(); + QUnit.start(); }; try { @@ -528,92 +528,92 @@ test( "XSS via location.hash", function() { } } ); -test( "isXMLDoc - XML", function() { - expect( 3 ); +QUnit.test( "isXMLDoc - XML", function( assert ) { + assert.expect( 3 ); var xml = createDashboardXML(); - ok( jQuery.isXMLDoc( xml ), "XML document" ); - ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" ); - ok( jQuery.isXMLDoc( jQuery( "tab", xml )[ 0 ] ), "XML Tab Element" ); + assert.ok( jQuery.isXMLDoc( xml ), "XML document" ); + assert.ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" ); + assert.ok( jQuery.isXMLDoc( jQuery( "tab", xml )[ 0 ] ), "XML Tab Element" ); } ); -test( "isWindow", function() { - expect( 14 ); - - ok( jQuery.isWindow( window ), "window" ); - ok( jQuery.isWindow( document.getElementsByTagName( "iframe" )[ 0 ].contentWindow ), "iframe.contentWindow" ); - ok( !jQuery.isWindow(), "empty" ); - ok( !jQuery.isWindow( null ), "null" ); - ok( !jQuery.isWindow( undefined ), "undefined" ); - ok( !jQuery.isWindow( document ), "document" ); - ok( !jQuery.isWindow( document.documentElement ), "documentElement" ); - ok( !jQuery.isWindow( "" ), "string" ); - ok( !jQuery.isWindow( 1 ), "number" ); - ok( !jQuery.isWindow( true ), "boolean" ); - ok( !jQuery.isWindow( {} ), "object" ); - ok( !jQuery.isWindow( { setInterval: function() {} } ), "fake window" ); - ok( !jQuery.isWindow( /window/ ), "regexp" ); - ok( !jQuery.isWindow( function() {} ), "function" ); +QUnit.test( "isWindow", function( assert ) { + assert.expect( 14 ); + + assert.ok( jQuery.isWindow( window ), "window" ); + assert.ok( jQuery.isWindow( document.getElementsByTagName( "iframe" )[ 0 ].contentWindow ), "iframe.contentWindow" ); + assert.ok( !jQuery.isWindow(), "empty" ); + assert.ok( !jQuery.isWindow( null ), "null" ); + assert.ok( !jQuery.isWindow( undefined ), "undefined" ); + assert.ok( !jQuery.isWindow( document ), "document" ); + assert.ok( !jQuery.isWindow( document.documentElement ), "documentElement" ); + assert.ok( !jQuery.isWindow( "" ), "string" ); + assert.ok( !jQuery.isWindow( 1 ), "number" ); + assert.ok( !jQuery.isWindow( true ), "boolean" ); + assert.ok( !jQuery.isWindow( {} ), "object" ); + assert.ok( !jQuery.isWindow( { setInterval: function() {} } ), "fake window" ); + assert.ok( !jQuery.isWindow( /window/ ), "regexp" ); + assert.ok( !jQuery.isWindow( function() {} ), "function" ); } ); -test( "jQuery('html')", function() { - expect( 18 ); +QUnit.test( "jQuery('html')", function( assert ) { + assert.expect( 18 ); var s, div, j; jQuery[ "foo" ] = false; s = jQuery( "<script>jQuery.foo='test';</script>" )[ 0 ]; - ok( s, "Creating a script" ); - ok( !jQuery[ "foo" ], "Make sure the script wasn't executed prematurely" ); + assert.ok( s, "Creating a script" ); + assert.ok( !jQuery[ "foo" ], "Make sure the script wasn't executed prematurely" ); jQuery( "body" ).append( "<script>jQuery.foo='test';</script>" ); - ok( jQuery[ "foo" ], "Executing a scripts contents in the right context" ); + assert.ok( jQuery[ "foo" ], "Executing a scripts contents in the right context" ); // Test multi-line HTML div = jQuery( "<div>\r\nsome text\n<p>some p</p>\nmore text\r\n</div>" )[ 0 ]; - equal( div.nodeName.toUpperCase(), "DIV", "Make sure we're getting a div." ); - equal( div.firstChild.nodeType, 3, "Text node." ); - equal( div.lastChild.nodeType, 3, "Text node." ); - equal( div.childNodes[ 1 ].nodeType, 1, "Paragraph." ); - equal( div.childNodes[ 1 ].firstChild.nodeType, 3, "Paragraph text." ); + assert.equal( div.nodeName.toUpperCase(), "DIV", "Make sure we're getting a div." ); + assert.equal( div.firstChild.nodeType, 3, "Text node." ); + assert.equal( div.lastChild.nodeType, 3, "Text node." ); + assert.equal( div.childNodes[ 1 ].nodeType, 1, "Paragraph." ); + assert.equal( div.childNodes[ 1 ].firstChild.nodeType, 3, "Paragraph text." ); - ok( jQuery( "<link rel='stylesheet'/>" )[ 0 ], "Creating a link" ); + assert.ok( jQuery( "<link rel='stylesheet'/>" )[ 0 ], "Creating a link" ); - ok( !jQuery( "<script/>" )[ 0 ].parentNode, "Create a script" ); + assert.ok( !jQuery( "<script/>" )[ 0 ].parentNode, "Create a script" ); - ok( jQuery( "<input/>" ).attr( "type", "hidden" ), "Create an input and set the type." ); + assert.ok( jQuery( "<input/>" ).attr( "type", "hidden" ), "Create an input and set the type." ); j = jQuery( "<span>hi</span> there <!-- mon ami -->" ); - ok( j.length >= 2, "Check node,textnode,comment creation (some browsers delete comments)" ); + assert.ok( j.length >= 2, "Check node,textnode,comment creation (some browsers delete comments)" ); - ok( !jQuery( "<option>test</option>" )[ 0 ].selected, "Make sure that options are auto-selected #2050" ); + assert.ok( !jQuery( "<option>test</option>" )[ 0 ].selected, "Make sure that options are auto-selected #2050" ); - ok( jQuery( "<div></div>" )[ 0 ], "Create a div with closing tag." ); - ok( jQuery( "<table></table>" )[ 0 ], "Create a table with closing tag." ); + assert.ok( jQuery( "<div></div>" )[ 0 ], "Create a div with closing tag." ); + assert.ok( jQuery( "<table></table>" )[ 0 ], "Create a table with closing tag." ); - equal( jQuery( "element[attribute='<div></div>']" ).length, 0, + assert.equal( jQuery( "element[attribute='<div></div>']" ).length, 0, "When html is within brackets, do not recognize as html." ); //equal( jQuery( "element[attribute=<div></div>]" ).length, 0, // "When html is within brackets, do not recognize as html." ); - equal( jQuery( "element:not(<div></div>)" ).length, 0, + assert.equal( jQuery( "element:not(<div></div>)" ).length, 0, "When html is within parens, do not recognize as html." ); - equal( jQuery( "\\<div\\>" ).length, 0, "Ignore escaped html characters" ); + assert.equal( jQuery( "\\<div\\>" ).length, 0, "Ignore escaped html characters" ); } ); -test( "jQuery(tag-hyphenated elements) gh-1987", function() { - expect( 17 ); +QUnit.test( "jQuery(tag-hyphenated elements) gh-1987", function( assert ) { + assert.expect( 17 ); jQuery.each( "thead tbody tfoot colgroup caption tr th td".split( " " ), function( i, name ) { var j = jQuery( "<" + name + "-d></" + name + "-d>" ); - ok( j[ 0 ], "Create a tag-hyphenated elements" ); - ok( jQuery.nodeName( j[ 0 ], name.toUpperCase() + "-D" ), "Tag-hyphenated element has expected node name" ); + assert.ok( j[ 0 ], "Create a tag-hyphenated elements" ); + assert.ok( jQuery.nodeName( j[ 0 ], name.toUpperCase() + "-D" ), "Tag-hyphenated element has expected node name" ); } ); var j = jQuery( "<tr-multiple-hyphens></tr-multiple-hyphens>" ); - ok( jQuery.nodeName( j[ 0 ], "TR-MULTIPLE-HYPHENS" ), "Element with multiple hyphens in its tag has expected node name" ); + assert.ok( jQuery.nodeName( j[ 0 ], "TR-MULTIPLE-HYPHENS" ), "Element with multiple hyphens in its tag has expected node name" ); } ); -test( "jQuery('massive html #7990')", function() { - expect( 3 ); +QUnit.test( "jQuery('massive html #7990')", function( assert ) { + assert.expect( 3 ); var i, li = "<li>very very very very large html string</li>", @@ -624,60 +624,60 @@ test( "jQuery('massive html #7990')", function() { } html[ html.length ] = "</ul>"; html = jQuery( html.join( "" ) )[ 0 ]; - equal( html.nodeName.toLowerCase(), "ul" ); - equal( html.firstChild.nodeName.toLowerCase(), "li" ); - equal( html.childNodes.length, 30000 ); + assert.equal( html.nodeName.toLowerCase(), "ul" ); + assert.equal( html.firstChild.nodeName.toLowerCase(), "li" ); + assert.equal( html.childNodes.length, 30000 ); } ); -test( "jQuery('html', context)", function() { - expect( 1 ); +QUnit.test( "jQuery('html', context)", function( assert ) { + assert.expect( 1 ); var $div = jQuery( "<div/>" )[ 0 ], $span = jQuery( "<span/>", $div ); - equal( $span.length, 1, "verify a span created with a div context works, #1763" ); + assert.equal( $span.length, 1, "verify a span created with a div context works, #1763" ); } ); -test( "jQuery(selector, xml).text(str) - loaded via xml document", function() { - expect( 2 ); +QUnit.test( "jQuery(selector, xml).text(str) - loaded via xml document", function( assert ) { + assert.expect( 2 ); var xml = createDashboardXML(), // tests for #1419 where ie was a problem tab = jQuery( "tab", xml ).eq( 0 ); - equal( tab.text(), "blabla", "verify initial text correct" ); + assert.equal( tab.text(), "blabla", "verify initial text correct" ); tab.text( "newtext" ); - equal( tab.text(), "newtext", "verify new text correct" ); + assert.equal( tab.text(), "newtext", "verify new text correct" ); } ); -test( "end()", function() { - expect( 3 ); - equal( "Yahoo", jQuery( "#yahoo" ).parent().end().text(), "check for end" ); - ok( jQuery( "#yahoo" ).end(), "check for end with nothing to end" ); +QUnit.test( "end()", function( assert ) { + assert.expect( 3 ); + assert.equal( "Yahoo", jQuery( "#yahoo" ).parent().end().text(), "check for end" ); + assert.ok( jQuery( "#yahoo" ).end(), "check for end with nothing to end" ); var x = jQuery( "#yahoo" ); x.parent(); - equal( "Yahoo", jQuery( "#yahoo" ).text(), "check for non-destructive behaviour" ); + assert.equal( "Yahoo", jQuery( "#yahoo" ).text(), "check for non-destructive behaviour" ); } ); -test( "length", function() { - expect( 1 ); - equal( jQuery( "#qunit-fixture p" ).length, 6, "Get Number of Elements Found" ); +QUnit.test( "length", function( assert ) { + assert.expect( 1 ); + assert.equal( jQuery( "#qunit-fixture p" ).length, 6, "Get Number of Elements Found" ); } ); -test( "get()", function() { - expect( 1 ); - deepEqual( jQuery( "#qunit-fixture p" ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Get All Elements" ); +QUnit.test( "get()", function( assert ) { + assert.expect( 1 ); + assert.deepEqual( jQuery( "#qunit-fixture p" ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Get All Elements" ); } ); -test( "toArray()", function() { - expect( 1 ); - deepEqual( jQuery( "#qunit-fixture p" ).toArray(), +QUnit.test( "toArray()", function( assert ) { + assert.expect( 1 ); + assert.deepEqual( jQuery( "#qunit-fixture p" ).toArray(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Convert jQuery object to an Array" ); } ); -test( "inArray()", function() { - expect( 19 ); +QUnit.test( "inArray()", function( assert ) { + assert.expect( 19 ); var selections = { p: q( "firstp", "sap", "ap", "first" ), @@ -699,34 +699,34 @@ test( "inArray()", function() { }; jQuery.each( tests, function( key, obj ) { - equal( jQuery.inArray( obj.elem, selections[ key ] ), obj.index, "elem is in the array of selections of its tag" ); + assert.equal( jQuery.inArray( obj.elem, selections[ key ] ), obj.index, "elem is in the array of selections of its tag" ); // Third argument (fromIndex) - equal( !!~jQuery.inArray( obj.elem, selections[ key ], 5 ), false, "elem is NOT in the array of selections given a starting index greater than its position" ); - equal( !!~jQuery.inArray( obj.elem, selections[ key ], 1 ), true, "elem is in the array of selections given a starting index less than or equal to its position" ); - equal( !!~jQuery.inArray( obj.elem, selections[ key ], -3 ), true, "elem is in the array of selections given a negative index" ); + assert.equal( !!~jQuery.inArray( obj.elem, selections[ key ], 5 ), false, "elem is NOT in the array of selections given a starting index greater than its position" ); + assert.equal( !!~jQuery.inArray( obj.elem, selections[ key ], 1 ), true, "elem is in the array of selections given a starting index less than or equal to its position" ); + assert.equal( !!~jQuery.inArray( obj.elem, selections[ key ], -3 ), true, "elem is in the array of selections given a negative index" ); } ); jQuery.each( falseTests, function( key, elem ) { - equal( !!~jQuery.inArray( elem, selections[ key ] ), false, "elem is NOT in the array of selections" ); + assert.equal( !!~jQuery.inArray( elem, selections[ key ] ), false, "elem is NOT in the array of selections" ); } ); } ); -test( "get(Number)", function() { - expect( 2 ); - equal( jQuery( "#qunit-fixture p" ).get( 0 ), document.getElementById( "firstp" ), "Get A Single Element" ); - strictEqual( jQuery( "#firstp" ).get( 1 ), undefined, "Try get with index larger elements count" ); +QUnit.test( "get(Number)", function( assert ) { + assert.expect( 2 ); + assert.equal( jQuery( "#qunit-fixture p" ).get( 0 ), document.getElementById( "firstp" ), "Get A Single Element" ); + assert.strictEqual( jQuery( "#firstp" ).get( 1 ), undefined, "Try get with index larger elements count" ); } ); -test( "get(-Number)", function() { - expect( 2 ); - equal( jQuery( "p" ).get( -1 ), document.getElementById( "first" ), "Get a single element with negative index" ); - strictEqual( jQuery( "#firstp" ).get( -2 ), undefined, "Try get with index negative index larger then elements count" ); +QUnit.test( "get(-Number)", function( assert ) { + assert.expect( 2 ); + assert.equal( jQuery( "p" ).get( -1 ), document.getElementById( "first" ), "Get a single element with negative index" ); + assert.strictEqual( jQuery( "#firstp" ).get( -2 ), undefined, "Try get with index negative index larger then elements count" ); } ); -test( "each(Function)", function() { - expect( 1 ); +QUnit.test( "each(Function)", function( assert ) { + assert.expect( 1 ); var div, pass, i; div = jQuery( "div" ); @@ -737,40 +737,40 @@ test( "each(Function)", function() { pass = false; } } - ok( pass, "Execute a function, Relative" ); + assert.ok( pass, "Execute a function, Relative" ); } ); -test( "slice()", function() { - expect( 7 ); +QUnit.test( "slice()", function( assert ) { + assert.expect( 7 ); var $links = jQuery( "#ap a" ); - deepEqual( $links.slice( 1, 2 ).get(), q( "groups" ), "slice(1,2)" ); - deepEqual( $links.slice( 1 ).get(), q( "groups", "anchor1", "mark" ), "slice(1)" ); - deepEqual( $links.slice( 0, 3 ).get(), q( "google", "groups", "anchor1" ), "slice(0,3)" ); - deepEqual( $links.slice( -1 ).get(), q( "mark" ), "slice(-1)" ); + assert.deepEqual( $links.slice( 1, 2 ).get(), q( "groups" ), "slice(1,2)" ); + assert.deepEqual( $links.slice( 1 ).get(), q( "groups", "anchor1", "mark" ), "slice(1)" ); + assert.deepEqual( $links.slice( 0, 3 ).get(), q( "google", "groups", "anchor1" ), "slice(0,3)" ); + assert.deepEqual( $links.slice( -1 ).get(), q( "mark" ), "slice(-1)" ); - deepEqual( $links.eq( 1 ).get(), q( "groups" ), "eq(1)" ); - deepEqual( $links.eq( "2" ).get(), q( "anchor1" ), "eq('2')" ); - deepEqual( $links.eq( -1 ).get(), q( "mark" ), "eq(-1)" ); + assert.deepEqual( $links.eq( 1 ).get(), q( "groups" ), "eq(1)" ); + assert.deepEqual( $links.eq( "2" ).get(), q( "anchor1" ), "eq('2')" ); + assert.deepEqual( $links.eq( -1 ).get(), q( "mark" ), "eq(-1)" ); } ); -test( "first()/last()", function() { - expect( 4 ); +QUnit.test( "first()/last()", function( assert ) { + assert.expect( 4 ); var $links = jQuery( "#ap a" ), $none = jQuery( "asdf" ); - deepEqual( $links.first().get(), q( "google" ), "first()" ); - deepEqual( $links.last().get(), q( "mark" ), "last()" ); + assert.deepEqual( $links.first().get(), q( "google" ), "first()" ); + assert.deepEqual( $links.last().get(), q( "mark" ), "last()" ); - deepEqual( $none.first().get(), [], "first() none" ); - deepEqual( $none.last().get(), [], "last() none" ); + assert.deepEqual( $none.first().get(), [], "first() none" ); + assert.deepEqual( $none.last().get(), [], "last() none" ); } ); -test( "map()", function() { - expect( 2 ); +QUnit.test( "map()", function( assert ) { + assert.expect( 2 ); - deepEqual( + assert.deepEqual( jQuery( "#ap" ).map( function() { return jQuery( this ).find( "a" ).get(); } ).get(), @@ -778,7 +778,7 @@ test( "map()", function() { "Array Map" ); - deepEqual( + assert.deepEqual( jQuery( "#ap > a" ).map( function() { return this.parentNode; } ).get(), @@ -787,40 +787,40 @@ test( "map()", function() { ); } ); -test( "jQuery.map", function() { - expect( 25 ); +QUnit.test( "jQuery.map", function( assert ) { + assert.expect( 25 ); var i, label, result, callback; result = jQuery.map( [ 3, 4, 5 ], function( v, k ) { return k; } ); - equal( result.join( "" ), "012", "Map the keys from an array" ); + assert.equal( result.join( "" ), "012", "Map the keys from an array" ); result = jQuery.map( [ 3, 4, 5 ], function( v ) { return v; } ); - equal( result.join( "" ), "345", "Map the values from an array" ); + assert.equal( result.join( "" ), "345", "Map the values from an array" ); result = jQuery.map( { a: 1, b: 2 }, function( v, k ) { return k; } ); - equal( result.join( "" ), "ab", "Map the keys from an object" ); + assert.equal( result.join( "" ), "ab", "Map the keys from an object" ); result = jQuery.map( { a: 1, b: 2 }, function( v ) { return v; } ); - equal( result.join( "" ), "12", "Map the values from an object" ); + assert.equal( result.join( "" ), "12", "Map the values from an object" ); result = jQuery.map( [ "a", undefined, null, "b" ], function( v ) { return v; } ); - equal( result.join( "" ), "ab", "Array iteration does not include undefined/null results" ); + assert.equal( result.join( "" ), "ab", "Array iteration does not include undefined/null results" ); result = jQuery.map( { a: "a", b: undefined, c: null, d: "b" }, function( v ) { return v; } ); - equal( result.join( "" ), "ab", "Object iteration does not include undefined/null results" ); + assert.equal( result.join( "" ), "ab", "Object iteration does not include undefined/null results" ); result = { Zero: function() {}, @@ -828,7 +828,7 @@ test( "jQuery.map", function() { Two: function( a, b ) { a = a; b = b; } }; callback = function( v, k ) { - equal( k, "foo", label + "-argument function treated like object" ); + assert.equal( k, "foo", label + "-argument function treated like object" ); }; for ( i in result ) { label = i; @@ -848,7 +848,7 @@ test( "jQuery.map", function() { "excess": 1 }; callback = function( v, k ) { - equal( k, "length", "Object with " + label + " length treated like object" ); + assert.equal( k, "length", "Object with " + label + " length treated like object" ); }; for ( i in result ) { label = i; @@ -864,7 +864,7 @@ test( "jQuery.map", function() { callback = function( v, k ) { if ( result[ label ] ) { delete result[ label ]; - equal( k, "0", label + " treated like array" ); + assert.equal( k, "0", label + " treated like array" ); } }; for ( i in result ) { @@ -876,104 +876,104 @@ test( "jQuery.map", function() { jQuery.map( { length: 0 }, function() { result = true; } ); - ok( !result, "length: 0 plain object treated like array" ); + assert.ok( !result, "length: 0 plain object treated like array" ); result = false; jQuery.map( document.getElementsByTagName( "asdf" ), function() { result = true; } ); - ok( !result, "empty NodeList treated like array" ); + assert.ok( !result, "empty NodeList treated like array" ); result = jQuery.map( Array( 4 ), function( v, k ) { return k % 2 ? k : [ k,k,k ]; } ); - equal( result.join( "" ), "00012223", "Array results flattened (#2616)" ); + assert.equal( result.join( "" ), "00012223", "Array results flattened (#2616)" ); } ); -test( "jQuery.merge()", function() { - expect( 10 ); +QUnit.test( "jQuery.merge()", function( assert ) { + assert.expect( 10 ); - deepEqual( + assert.deepEqual( jQuery.merge( [], [] ), [], "Empty arrays" ); - deepEqual( + assert.deepEqual( jQuery.merge( [ 1 ], [ 2 ] ), [ 1, 2 ], "Basic (single-element)" ); - deepEqual( + assert.deepEqual( jQuery.merge( [ 1, 2 ], [ 3, 4 ] ), [ 1, 2, 3, 4 ], "Basic (multiple-element)" ); - deepEqual( + assert.deepEqual( jQuery.merge( [ 1, 2 ], [] ), [ 1, 2 ], "Second empty" ); - deepEqual( + assert.deepEqual( jQuery.merge( [], [ 1, 2 ] ), [ 1, 2 ], "First empty" ); // Fixed at [5998], #3641 - deepEqual( + assert.deepEqual( jQuery.merge( [ -2, -1 ], [ 0, 1, 2 ] ), [ -2, -1, 0, 1, 2 ], "Second array including a zero (falsy)" ); // After fixing #5527 - deepEqual( + assert.deepEqual( jQuery.merge( [], [ null, undefined ] ), [ null, undefined ], "Second array including null and undefined values" ); - deepEqual( + assert.deepEqual( jQuery.merge( { length: 0 }, [ 1, 2 ] ), { length: 2, 0: 1, 1: 2 }, "First array like" ); - deepEqual( + assert.deepEqual( jQuery.merge( [ 1, 2 ], { length: 1, 0: 3 } ), [ 1, 2, 3 ], "Second array like" ); - deepEqual( + assert.deepEqual( jQuery.merge( [], document.getElementById( "lengthtest" ).getElementsByTagName( "input" ) ), [ document.getElementById( "length" ), document.getElementById( "idTest" ) ], "Second NodeList" ); } ); -test( "jQuery.grep()", function() { - expect( 8 ); +QUnit.test( "jQuery.grep()", function( assert ) { + assert.expect( 8 ); var searchCriterion = function( value ) { return value % 2 === 0; }; - deepEqual( jQuery.grep( [], searchCriterion ), [], "Empty array" ); - deepEqual( jQuery.grep( new Array( 4 ), searchCriterion ), [], "Sparse array" ); + assert.deepEqual( jQuery.grep( [], searchCriterion ), [], "Empty array" ); + assert.deepEqual( jQuery.grep( new Array( 4 ), searchCriterion ), [], "Sparse array" ); - deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion ), [ 2, 4, 6 ], "Satisfying elements present" ); - deepEqual( jQuery.grep( [ 1, 3, 5, 7 ], searchCriterion ), [], "Satisfying elements absent" ); + assert.deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion ), [ 2, 4, 6 ], "Satisfying elements present" ); + assert.deepEqual( jQuery.grep( [ 1, 3, 5, 7 ], searchCriterion ), [], "Satisfying elements absent" ); - deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion, true ), [ 1, 3, 5 ], "Satisfying elements present and grep inverted" ); - deepEqual( jQuery.grep( [ 1, 3, 5, 7 ], searchCriterion, true ), [ 1, 3, 5, 7 ], "Satisfying elements absent and grep inverted" ); + assert.deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion, true ), [ 1, 3, 5 ], "Satisfying elements present and grep inverted" ); + assert.deepEqual( jQuery.grep( [ 1, 3, 5, 7 ], searchCriterion, true ), [ 1, 3, 5, 7 ], "Satisfying elements absent and grep inverted" ); - deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion, false ), [ 2, 4, 6 ], "Satisfying elements present but grep explicitly uninverted" ); - deepEqual( jQuery.grep( [ 1, 3, 5, 7 ], searchCriterion, false ), [], "Satisfying elements absent and grep explicitly uninverted" ); + assert.deepEqual( jQuery.grep( [ 1, 2, 3, 4, 5, 6 ], searchCriterion, false ), [ 2, 4, 6 ], "Satisfying elements present but grep explicitly uninverted" ); + assert.deepEqual( jQuery.grep( [ 1, 3, 5, 7 ], searchCriterion, false ), [], "Satisfying elements absent and grep explicitly uninverted" ); } ); -test( "jQuery.extend(Object, Object)", function() { - expect( 28 ); +QUnit.test( "jQuery.extend(Object, Object)", function( assert ) { + assert.expect( 28 ); var empty, optionsWithLength, optionsWithDate, myKlass, customObject, optionsWithCustomObject, MyNumber, ret, @@ -991,33 +991,33 @@ test( "jQuery.extend(Object, Object)", function() { nestedarray = { "arr": arr }; jQuery.extend( settings, options ); - deepEqual( settings, merged, "Check if extended: settings must be extended" ); - deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" ); + assert.deepEqual( settings, merged, "Check if extended: settings must be extended" ); + assert.deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" ); jQuery.extend( settings, null, options ); - deepEqual( settings, merged, "Check if extended: settings must be extended" ); - deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" ); + assert.deepEqual( settings, merged, "Check if extended: settings must be extended" ); + assert.deepEqual( options, optionsCopy, "Check if not modified: options must not be modified" ); jQuery.extend( true, deep1, deep2 ); - deepEqual( deep1[ "foo" ], deepmerged[ "foo" ], "Check if foo: settings must be extended" ); - deepEqual( deep2[ "foo" ], deep2copy[ "foo" ], "Check if not deep2: options must not be modified" ); - equal( deep1[ "foo2" ], document, "Make sure that a deep clone was not attempted on the document" ); + assert.deepEqual( deep1[ "foo" ], deepmerged[ "foo" ], "Check if foo: settings must be extended" ); + assert.deepEqual( deep2[ "foo" ], deep2copy[ "foo" ], "Check if not deep2: options must not be modified" ); + assert.equal( deep1[ "foo2" ], document, "Make sure that a deep clone was not attempted on the document" ); - ok( jQuery.extend( true, {}, nestedarray )[ "arr" ] !== arr, "Deep extend of object must clone child array" ); + assert.ok( jQuery.extend( true, {}, nestedarray )[ "arr" ] !== arr, "Deep extend of object must clone child array" ); // #5991 - ok( jQuery.isArray( jQuery.extend( true, { "arr": {} }, nestedarray )[ "arr" ] ), "Cloned array have to be an Array" ); - ok( jQuery.isPlainObject( jQuery.extend( true, { "arr": arr }, { "arr": {} } )[ "arr" ] ), "Cloned object have to be an plain object" ); + assert.ok( jQuery.isArray( jQuery.extend( true, { "arr": {} }, nestedarray )[ "arr" ] ), "Cloned array have to be an Array" ); + assert.ok( jQuery.isPlainObject( jQuery.extend( true, { "arr": arr }, { "arr": {} } )[ "arr" ] ), "Cloned object have to be an plain object" ); empty = {}; optionsWithLength = { "foo": { "length": -1 } }; jQuery.extend( true, empty, optionsWithLength ); - deepEqual( empty[ "foo" ], optionsWithLength[ "foo" ], "The length property must copy correctly" ); + assert.deepEqual( empty[ "foo" ], optionsWithLength[ "foo" ], "The length property must copy correctly" ); empty = {}; optionsWithDate = { "foo": { "date": new Date() } }; jQuery.extend( true, empty, optionsWithDate ); - deepEqual( empty[ "foo" ], optionsWithDate[ "foo" ], "Dates copy correctly" ); + assert.deepEqual( empty[ "foo" ], optionsWithDate[ "foo" ], "Dates copy correctly" ); /** @constructor */ myKlass = function() {}; @@ -1025,50 +1025,50 @@ test( "jQuery.extend(Object, Object)", function() { optionsWithCustomObject = { "foo": { "date": customObject } }; empty = {}; jQuery.extend( true, empty, optionsWithCustomObject ); - ok( empty[ "foo" ] && empty[ "foo" ][ "date" ] === customObject, "Custom objects copy correctly (no methods)" ); + assert.ok( empty[ "foo" ] && empty[ "foo" ][ "date" ] === customObject, "Custom objects copy correctly (no methods)" ); // Makes the class a little more realistic myKlass.prototype = { "someMethod": function() {} }; empty = {}; jQuery.extend( true, empty, optionsWithCustomObject ); - ok( empty[ "foo" ] && empty[ "foo" ][ "date" ] === customObject, "Custom objects copy correctly" ); + assert.ok( empty[ "foo" ] && empty[ "foo" ][ "date" ] === customObject, "Custom objects copy correctly" ); MyNumber = Number; ret = jQuery.extend( true, { "foo": 4 }, { "foo": new MyNumber( 5 ) } ); - ok( parseInt( ret.foo, 10 ) === 5, "Wrapped numbers copy correctly" ); + assert.ok( parseInt( ret.foo, 10 ) === 5, "Wrapped numbers copy correctly" ); nullUndef; nullUndef = jQuery.extend( {}, options, { "xnumber2": null } ); - ok( nullUndef[ "xnumber2" ] === null, "Check to make sure null values are copied" ); + assert.ok( nullUndef[ "xnumber2" ] === null, "Check to make sure null values are copied" ); nullUndef = jQuery.extend( {}, options, { "xnumber2": undefined } ); - ok( nullUndef[ "xnumber2" ] === options[ "xnumber2" ], "Check to make sure undefined values are not copied" ); + assert.ok( nullUndef[ "xnumber2" ] === options[ "xnumber2" ], "Check to make sure undefined values are not copied" ); nullUndef = jQuery.extend( {}, options, { "xnumber0": null } ); - ok( nullUndef[ "xnumber0" ] === null, "Check to make sure null values are inserted" ); + assert.ok( nullUndef[ "xnumber0" ] === null, "Check to make sure null values are inserted" ); target = {}; recursive = { foo:target, bar:5 }; jQuery.extend( true, target, recursive ); - deepEqual( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" ); + assert.deepEqual( target, { bar:5 }, "Check to make sure a recursive obj doesn't go never-ending loop by not copying it over" ); ret = jQuery.extend( true, { foo: [] }, { foo: [ 0 ] } ); // 1907 - equal( ret.foo.length, 1, "Check to make sure a value with coercion 'false' copies over when necessary to fix #1907" ); + assert.equal( ret.foo.length, 1, "Check to make sure a value with coercion 'false' copies over when necessary to fix #1907" ); ret = jQuery.extend( true, { foo: "1,2,3" }, { foo: [ 1, 2, 3 ] } ); - ok( typeof ret.foo !== "string", "Check to make sure values equal with coercion (but not actually equal) overwrite correctly" ); + assert.ok( typeof ret.foo !== "string", "Check to make sure values equal with coercion (but not actually equal) overwrite correctly" ); ret = jQuery.extend( true, { foo:"bar" }, { foo:null } ); - ok( typeof ret.foo !== "undefined", "Make sure a null value doesn't crash with deep extend, for #1908" ); + assert.ok( typeof ret.foo !== "undefined", "Make sure a null value doesn't crash with deep extend, for #1908" ); obj = { foo:null }; jQuery.extend( true, obj, { foo:"notnull" } ); - equal( obj.foo, "notnull", "Make sure a null value can be overwritten" ); + assert.equal( obj.foo, "notnull", "Make sure a null value can be overwritten" ); function func() {} jQuery.extend( func, { key: "value" } ); - equal( func.key, "value", "Verify a function can be extended" ); + assert.equal( func.key, "value", "Verify a function can be extended" ); defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" }; defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" }; @@ -1079,14 +1079,14 @@ test( "jQuery.extend(Object, Object)", function() { merged2 = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" }; settings = jQuery.extend( {}, defaults, options1, options2 ); - deepEqual( settings, merged2, "Check if extended: settings must be extended" ); - deepEqual( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" ); - deepEqual( options1, options1Copy, "Check if not modified: options1 must not be modified" ); - deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" ); + assert.deepEqual( settings, merged2, "Check if extended: settings must be extended" ); + assert.deepEqual( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" ); + assert.deepEqual( options1, options1Copy, "Check if not modified: options1 must not be modified" ); + assert.deepEqual( options2, options2Copy, "Check if not modified: options2 must not be modified" ); } ); -test( "jQuery.each(Object,Function)", function() { - expect( 23 ); +QUnit.test( "jQuery.each(Object,Function)", function( assert ) { + assert.expect( 23 ); var i, label, seen, callback; @@ -1094,13 +1094,13 @@ test( "jQuery.each(Object,Function)", function() { jQuery.each( [ 3, 4, 5 ], function( k, v ) { seen[ k ] = v; } ); - deepEqual( seen, { "0": 3, "1": 4, "2": 5 }, "Array iteration" ); + assert.deepEqual( seen, { "0": 3, "1": 4, "2": 5 }, "Array iteration" ); seen = {}; jQuery.each( { name: "name", lang: "lang" }, function( k, v ) { seen[ k ] = v; } ); - deepEqual( seen, { name: "name", lang: "lang" }, "Object iteration" ); + assert.deepEqual( seen, { name: "name", lang: "lang" }, "Object iteration" ); seen = []; jQuery.each( [ 1, 2, 3 ], function( k, v ) { @@ -1109,14 +1109,14 @@ test( "jQuery.each(Object,Function)", function() { return false; } } ); - deepEqual( seen, [ 1, 2 ], "Broken array iteration" ); + assert.deepEqual( seen, [ 1, 2 ], "Broken array iteration" ); seen = []; jQuery.each( { "a": 1, "b": 2,"c": 3 }, function( k, v ) { seen.push( v ); return false; } ); - deepEqual( seen, [ 1 ], "Broken object iteration" ); + assert.deepEqual( seen, [ 1 ], "Broken object iteration" ); seen = { Zero: function() {}, @@ -1124,7 +1124,7 @@ test( "jQuery.each(Object,Function)", function() { Two: function( a, b ) { a = a; b = b; } }; callback = function( k ) { - equal( k, "foo", label + "-argument function treated like object" ); + assert.equal( k, "foo", label + "-argument function treated like object" ); }; for ( i in seen ) { label = i; @@ -1144,7 +1144,7 @@ test( "jQuery.each(Object,Function)", function() { "excess": 1 }; callback = function( k ) { - equal( k, "length", "Object with " + label + " length treated like object" ); + assert.equal( k, "length", "Object with " + label + " length treated like object" ); }; for ( i in seen ) { label = i; @@ -1160,7 +1160,7 @@ test( "jQuery.each(Object,Function)", function() { callback = function( k ) { if ( seen[ label ] ) { delete seen[ label ]; - equal( k, "0", label + " treated like array" ); + assert.equal( k, "0", label + " treated like array" ); return false; } }; @@ -1173,37 +1173,37 @@ test( "jQuery.each(Object,Function)", function() { jQuery.each( { length: 0 }, function() { seen = true; } ); - ok( !seen, "length: 0 plain object treated like array" ); + assert.ok( !seen, "length: 0 plain object treated like array" ); seen = false; jQuery.each( document.getElementsByTagName( "asdf" ), function() { seen = true; } ); - ok( !seen, "empty NodeList treated like array" ); + assert.ok( !seen, "empty NodeList treated like array" ); i = 0; jQuery.each( document.styleSheets, function() { i++; } ); - equal( i, document.styleSheets.length, "Iteration over document.styleSheets" ); + assert.equal( i, document.styleSheets.length, "Iteration over document.styleSheets" ); } ); -test( "jQuery.each/map(undefined/null,Function)", function() { - expect( 1 ); +QUnit.test( "jQuery.each/map(undefined/null,Function)", function( assert ) { + assert.expect( 1 ); try { jQuery.each( undefined, jQuery.noop ); jQuery.each( null, jQuery.noop ); jQuery.map( undefined, jQuery.noop ); jQuery.map( null, jQuery.noop ); - ok( true, "jQuery.each/map( undefined/null, function() {} );" ); + assert.ok( true, "jQuery.each/map( undefined/null, function() {} );" ); } catch ( e ) { - ok( false, "each/map must accept null and undefined values" ); + assert.ok( false, "each/map must accept null and undefined values" ); } } ); -test( "JIT compilation does not interfere with length retrieval (gh-2145)", function() { - expect( 4 ); +QUnit.test( "JIT compilation does not interfere with length retrieval (gh-2145)", function( assert ) { + assert.expect( 4 ); var i; @@ -1216,73 +1216,73 @@ test( "JIT compilation does not interfere with length retrieval (gh-2145)", func i = 0; jQuery.each( { 1: "1", 2: "2", 3: "3" }, function( index ) { - equal( ++i, index, "Iteration over object with solely " + + assert.equal( ++i, index, "Iteration over object with solely " + "numeric indices (gh-2145 JIT iOS 8 bug)" ); } ); - equal( i, 3, "Iteration over object with solely " + + assert.equal( i, 3, "Iteration over object with solely " + "numeric indices (gh-2145 JIT iOS 8 bug)" ); } ); -test( "jQuery.makeArray", function() { - expect( 15 ); +QUnit.test( "jQuery.makeArray", function( assert ) { + assert.expect( 15 ); - equal( jQuery.makeArray( jQuery( "html>*" ) )[ 0 ].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" ); + assert.equal( jQuery.makeArray( jQuery( "html>*" ) )[ 0 ].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" ); - equal( jQuery.makeArray( document.getElementsByName( "PWD" ) ).slice( 0, 1 )[ 0 ].name, "PWD", "Pass makeArray a nodelist" ); + assert.equal( jQuery.makeArray( document.getElementsByName( "PWD" ) ).slice( 0, 1 )[ 0 ].name, "PWD", "Pass makeArray a nodelist" ); - equal( ( function() { return jQuery.makeArray( arguments ); } )( 1, 2 ).join( "" ), "12", "Pass makeArray an arguments array" ); + assert.equal( ( function() { return jQuery.makeArray( arguments ); } )( 1, 2 ).join( "" ), "12", "Pass makeArray an arguments array" ); - equal( jQuery.makeArray( [ 1,2,3 ] ).join( "" ), "123", "Pass makeArray a real array" ); + assert.equal( jQuery.makeArray( [ 1,2,3 ] ).join( "" ), "123", "Pass makeArray a real array" ); - equal( jQuery.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" ); + assert.equal( jQuery.makeArray().length, 0, "Pass nothing to makeArray and expect an empty array" ); - equal( jQuery.makeArray( 0 )[ 0 ], 0, "Pass makeArray a number" ); + assert.equal( jQuery.makeArray( 0 )[ 0 ], 0, "Pass makeArray a number" ); - equal( jQuery.makeArray( "foo" )[ 0 ], "foo", "Pass makeArray a string" ); + assert.equal( jQuery.makeArray( "foo" )[ 0 ], "foo", "Pass makeArray a string" ); - equal( jQuery.makeArray( true )[ 0 ].constructor, Boolean, "Pass makeArray a boolean" ); + assert.equal( jQuery.makeArray( true )[ 0 ].constructor, Boolean, "Pass makeArray a boolean" ); - equal( jQuery.makeArray( document.createElement( "div" ) )[ 0 ].nodeName.toUpperCase(), "DIV", "Pass makeArray a single node" ); + assert.equal( jQuery.makeArray( document.createElement( "div" ) )[ 0 ].nodeName.toUpperCase(), "DIV", "Pass makeArray a single node" ); - equal( jQuery.makeArray( { length:2, 0:"a", 1:"b" } ).join( "" ), "ab", "Pass makeArray an array like map (with length)" ); + assert.equal( jQuery.makeArray( { length:2, 0:"a", 1:"b" } ).join( "" ), "ab", "Pass makeArray an array like map (with length)" ); - ok( !!jQuery.makeArray( document.documentElement.childNodes ).slice( 0, 1 )[ 0 ].nodeName, "Pass makeArray a childNodes array" ); + assert.ok( !!jQuery.makeArray( document.documentElement.childNodes ).slice( 0, 1 )[ 0 ].nodeName, "Pass makeArray a childNodes array" ); // function, is tricky as it has length - equal( jQuery.makeArray( function() { return 1;} )[ 0 ](), 1, "Pass makeArray a function" ); + assert.equal( jQuery.makeArray( function() { return 1;} )[ 0 ](), 1, "Pass makeArray a function" ); //window, also has length - equal( jQuery.makeArray( window )[ 0 ], window, "Pass makeArray the window" ); + assert.equal( jQuery.makeArray( window )[ 0 ], window, "Pass makeArray the window" ); - equal( jQuery.makeArray( /a/ )[ 0 ].constructor, RegExp, "Pass makeArray a regex" ); + assert.equal( jQuery.makeArray( /a/ )[ 0 ].constructor, RegExp, "Pass makeArray a regex" ); // Some nodes inherit traits of nodelists - ok( jQuery.makeArray( document.getElementById( "form" ) ).length >= 13, + assert.ok( jQuery.makeArray( document.getElementById( "form" ) ).length >= 13, "Pass makeArray a form (treat as elements)" ); } ); -test( "jQuery.inArray", function() { - expect( 3 ); +QUnit.test( "jQuery.inArray", function( assert ) { + assert.expect( 3 ); - equal( jQuery.inArray( 0, false ), -1, "Search in 'false' as array returns -1 and doesn't throw exception" ); + assert.equal( jQuery.inArray( 0, false ), -1, "Search in 'false' as array returns -1 and doesn't throw exception" ); - equal( jQuery.inArray( 0, null ), -1, "Search in 'null' as array returns -1 and doesn't throw exception" ); + assert.equal( jQuery.inArray( 0, null ), -1, "Search in 'null' as array returns -1 and doesn't throw exception" ); - equal( jQuery.inArray( 0, undefined ), -1, "Search in 'undefined' as array returns -1 and doesn't throw exception" ); + assert.equal( jQuery.inArray( 0, undefined ), -1, "Search in 'undefined' as array returns -1 and doesn't throw exception" ); } ); -test( "jQuery.isEmptyObject", function() { - expect( 2 ); +QUnit.test( "jQuery.isEmptyObject", function( assert ) { + assert.expect( 2 ); - equal( true, jQuery.isEmptyObject( {} ), "isEmptyObject on empty object literal" ); - equal( false, jQuery.isEmptyObject( { a:1 } ), "isEmptyObject on non-empty object literal" ); + assert.equal( true, jQuery.isEmptyObject( {} ), "isEmptyObject on empty object literal" ); + assert.equal( false, jQuery.isEmptyObject( { a:1 } ), "isEmptyObject on non-empty object literal" ); // What about this ? // equal(true, jQuery.isEmptyObject(null), "isEmptyObject on null" ); } ); -test( "jQuery.proxy", function() { - expect( 9 ); +QUnit.test( "jQuery.proxy", function( assert ) { + assert.expect( 9 ); var test2, test3, test4, fn, cb, test = function() { equal( this, thisObject, "Make sure that scope is set properly." ); }, @@ -1298,7 +1298,7 @@ test( "jQuery.proxy", function() { jQuery.proxy( thisObject, "method" )(); // Make sure it doesn't freak out - equal( jQuery.proxy( null, thisObject ), undefined, "Make sure no function was returned." ); + assert.equal( jQuery.proxy( null, thisObject ), undefined, "Make sure no function was returned." ); // Partial application test2 = function( a ) { equal( a, "pre-applied", "Ensure arguments can be pre-applied." ); }; @@ -1314,57 +1314,57 @@ test( "jQuery.proxy", function() { // jQuery 1.9 improved currying with `this` object fn = function() { - equal( Array.prototype.join.call( arguments, "," ), "arg1,arg2,arg3", "args passed" ); - equal( this.foo, "bar", "this-object passed" ); + assert.equal( Array.prototype.join.call( arguments, "," ), "arg1,arg2,arg3", "args passed" ); + assert.equal( this.foo, "bar", "this-object passed" ); }; cb = jQuery.proxy( fn, null, "arg1", "arg2" ); cb.call( thisObject, "arg3" ); } ); -test( "jQuery.parseHTML", function() { - expect( 22 ); +QUnit.test( "jQuery.parseHTML", function( assert ) { + assert.expect( 22 ); var html, nodes; - deepEqual( jQuery.parseHTML(), [], "Without arguments" ); - deepEqual( jQuery.parseHTML( undefined ), [], "Undefined" ); - deepEqual( jQuery.parseHTML( null ), [], "Null" ); - deepEqual( jQuery.parseHTML( false ), [], "Boolean false" ); - deepEqual( jQuery.parseHTML( 0 ), [], "Zero" ); - deepEqual( jQuery.parseHTML( true ), [], "Boolean true" ); - deepEqual( jQuery.parseHTML( 42 ), [], "Positive number" ); - deepEqual( jQuery.parseHTML( "" ), [], "Empty string" ); - throws( function() { + assert.deepEqual( jQuery.parseHTML(), [], "Without arguments" ); + assert.deepEqual( jQuery.parseHTML( undefined ), [], "Undefined" ); + assert.deepEqual( jQuery.parseHTML( null ), [], "Null" ); + assert.deepEqual( jQuery.parseHTML( false ), [], "Boolean false" ); + assert.deepEqual( jQuery.parseHTML( 0 ), [], "Zero" ); + assert.deepEqual( jQuery.parseHTML( true ), [], "Boolean true" ); + assert.deepEqual( jQuery.parseHTML( 42 ), [], "Positive number" ); + assert.deepEqual( jQuery.parseHTML( "" ), [], "Empty string" ); + assert.throws( function() { jQuery.parseHTML( "<div></div>", document.getElementById( "form" ) ); }, "Passing an element as the context raises an exception (context should be a document)" ); nodes = jQuery.parseHTML( jQuery( "body" )[ 0 ].innerHTML ); - ok( nodes.length > 4, "Parse a large html string" ); - equal( jQuery.type( nodes ), "array", "parseHTML returns an array rather than a nodelist" ); + assert.ok( nodes.length > 4, "Parse a large html string" ); + assert.equal( jQuery.type( nodes ), "array", "parseHTML returns an array rather than a nodelist" ); html = "<script>undefined()</script>"; - equal( jQuery.parseHTML( html ).length, 0, "Ignore scripts by default" ); - equal( jQuery.parseHTML( html, true )[ 0 ].nodeName.toLowerCase(), "script", "Preserve scripts when requested" ); + assert.equal( jQuery.parseHTML( html ).length, 0, "Ignore scripts by default" ); + assert.equal( jQuery.parseHTML( html, true )[ 0 ].nodeName.toLowerCase(), "script", "Preserve scripts when requested" ); html += "<div></div>"; - equal( jQuery.parseHTML( html )[ 0 ].nodeName.toLowerCase(), "div", "Preserve non-script nodes" ); - equal( jQuery.parseHTML( html, true )[ 0 ].nodeName.toLowerCase(), "script", "Preserve script position" ); + assert.equal( jQuery.parseHTML( html )[ 0 ].nodeName.toLowerCase(), "div", "Preserve non-script nodes" ); + assert.equal( jQuery.parseHTML( html, true )[ 0 ].nodeName.toLowerCase(), "script", "Preserve script position" ); - equal( jQuery.parseHTML( "text" )[ 0 ].nodeType, 3, "Parsing text returns a text node" ); - equal( jQuery.parseHTML( "\t<div></div>" )[ 0 ].nodeValue, "\t", "Preserve leading whitespace" ); + assert.equal( jQuery.parseHTML( "text" )[ 0 ].nodeType, 3, "Parsing text returns a text node" ); + assert.equal( jQuery.parseHTML( "\t<div></div>" )[ 0 ].nodeValue, "\t", "Preserve leading whitespace" ); - equal( jQuery.parseHTML( " <div/> " )[ 0 ].nodeType, 3, "Leading spaces are treated as text nodes (#11290)" ); + assert.equal( jQuery.parseHTML( " <div/> " )[ 0 ].nodeType, 3, "Leading spaces are treated as text nodes (#11290)" ); html = jQuery.parseHTML( "<div>test div</div>" ); - equal( html[ 0 ].parentNode.nodeType, 11, "parentNode should be documentFragment" ); - equal( html[ 0 ].innerHTML, "test div", "Content should be preserved" ); + assert.equal( html[ 0 ].parentNode.nodeType, 11, "parentNode should be documentFragment" ); + assert.equal( html[ 0 ].innerHTML, "test div", "Content should be preserved" ); - equal( jQuery.parseHTML( "<span><span>" ).length, 1, "Incorrect html-strings should not break anything" ); - equal( jQuery.parseHTML( "<td><td>" )[ 1 ].parentNode.nodeType, 11, "parentNode should be documentFragment" ); + assert.equal( jQuery.parseHTML( "<span><span>" ).length, 1, "Incorrect html-strings should not break anything" ); + assert.equal( jQuery.parseHTML( "<td><td>" )[ 1 ].parentNode.nodeType, 11, "parentNode should be documentFragment" ); } ); if ( jQuery.support.createHTMLDocument ) { - asyncTest( "jQuery.parseHTML", function() { + QUnit.asyncTest( "jQuery.parseHTML", function( assert ) { expect ( 1 ); Globals.register( "parseHTMLError" ); @@ -1373,69 +1373,69 @@ if ( jQuery.support.createHTMLDocument ) { jQuery.parseHTML( "<img src=x onerror='parseHTMLError = true'>" ); window.setTimeout( function() { - start(); - equal( window.parseHTMLError, false, "onerror eventhandler has not been called." ); + QUnit.start(); + assert.equal( window.parseHTMLError, false, "onerror eventhandler has not been called." ); }, 2000 ); } ); } -test( "jQuery.parseJSON", function() { - expect( 20 ); +QUnit.test( "jQuery.parseJSON", function( assert ) { + assert.expect( 20 ); - strictEqual( jQuery.parseJSON( null ), null, "primitive null" ); - strictEqual( jQuery.parseJSON( "0.88" ), 0.88, "Number" ); - strictEqual( + assert.strictEqual( jQuery.parseJSON( null ), null, "primitive null" ); + assert.strictEqual( jQuery.parseJSON( "0.88" ), 0.88, "Number" ); + assert.strictEqual( jQuery.parseJSON( "\" \\\" \\\\ \\/ \\b \\f \\n \\r \\t \\u007E \\u263a \"" ), " \" \\ / \b \f \n \r \t ~ \u263A ", "String escapes" ); - deepEqual( jQuery.parseJSON( "{}" ), {}, "Empty object" ); - deepEqual( jQuery.parseJSON( "{\"test\":1}" ), { "test": 1 }, "Plain object" ); - deepEqual( jQuery.parseJSON( "[0]" ), [ 0 ], "Simple array" ); + assert.deepEqual( jQuery.parseJSON( "{}" ), {}, "Empty object" ); + assert.deepEqual( jQuery.parseJSON( "{\"test\":1}" ), { "test": 1 }, "Plain object" ); + assert.deepEqual( jQuery.parseJSON( "[0]" ), [ 0 ], "Simple array" ); - deepEqual( + assert.deepEqual( jQuery.parseJSON( "[ \"string\", -4.2, 2.7180e0, 3.14E-1, {}, [], true, false, null ]" ), [ "string", -4.2, 2.718, 0.314, {}, [], true, false, null ], "Array of all data types" ); - deepEqual( + assert.deepEqual( jQuery.parseJSON( "{ \"string\": \"\", \"number\": 4.2e+1, \"object\": {}," + "\"array\": [[]], \"boolean\": [ true, false ], \"null\": null }" ), { string: "", number: 42, object: {}, array: [ [] ], "boolean": [ true, false ], "null": null }, "Dictionary of all data types" ); - deepEqual( jQuery.parseJSON( "\n{\"test\":1}\t" ), { "test": 1 }, + assert.deepEqual( jQuery.parseJSON( "\n{\"test\":1}\t" ), { "test": 1 }, "Leading and trailing whitespace are ignored" ); - throws( function() { + assert.throws( function() { jQuery.parseJSON(); }, null, "Undefined raises an error" ); - throws( function() { + assert.throws( function() { jQuery.parseJSON( "" ); }, null, "Empty string raises an error" ); - throws( function() { + assert.throws( function() { jQuery.parseJSON( "''" ); }, null, "Single-quoted string raises an error" ); /* // Broken on IE8 - throws(function() { + assert.throws(function() { jQuery.parseJSON("\" \\a \""); }, null, "Invalid string escape raises an error" ); // Broken on IE8, Safari 5.1 Windows - throws(function() { + assert.throws(function() { jQuery.parseJSON("\"\t\""); }, null, "Unescaped control character raises an error" ); // Broken on IE8 - throws(function() { + assert.throws(function() { jQuery.parseJSON(".123"); }, null, "Number with no integer component raises an error" ); */ - throws( function() { + assert.throws( function() { var result = jQuery.parseJSON( "0101" ); // Support: IE9+ @@ -1444,63 +1444,63 @@ test( "jQuery.parseJSON", function() { throw new Error( "close enough" ); } }, null, "Leading-zero number raises an error or is parsed as decimal" ); - throws( function() { + assert.throws( function() { jQuery.parseJSON( "{a:1}" ); }, null, "Unquoted property raises an error" ); - throws( function() { + assert.throws( function() { jQuery.parseJSON( "{'a':1}" ); }, null, "Single-quoted property raises an error" ); - throws( function() { + assert.throws( function() { jQuery.parseJSON( "[,]" ); }, null, "Array element elision raises an error" ); - throws( function() { + assert.throws( function() { jQuery.parseJSON( "{},[]" ); }, null, "Comma expression raises an error" ); - throws( function() { + assert.throws( function() { jQuery.parseJSON( "[]\n,{}" ); }, null, "Newline-containing comma expression raises an error" ); - throws( function() { + assert.throws( function() { jQuery.parseJSON( "\"\"\n\"\"" ); }, null, "Automatic semicolon insertion raises an error" ); - strictEqual( jQuery.parseJSON( [ 0 ] ), 0, "Input cast to string" ); + assert.strictEqual( jQuery.parseJSON( [ 0 ] ), 0, "Input cast to string" ); } ); -test( "jQuery.parseXML", function() { - expect( 8 ); +QUnit.test( "jQuery.parseXML", function( assert ) { + assert.expect( 8 ); var xml, tmp; try { xml = jQuery.parseXML( "<p>A <b>well-formed</b> xml string</p>" ); tmp = xml.getElementsByTagName( "p" )[ 0 ]; - ok( !!tmp, "<p> present in document" ); + assert.ok( !!tmp, "<p> present in document" ); tmp = tmp.getElementsByTagName( "b" )[ 0 ]; - ok( !!tmp, "<b> present in document" ); - strictEqual( tmp.childNodes[ 0 ].nodeValue, "well-formed", "<b> text is as expected" ); + assert.ok( !!tmp, "<b> present in document" ); + assert.strictEqual( tmp.childNodes[ 0 ].nodeValue, "well-formed", "<b> text is as expected" ); } catch ( e ) { - strictEqual( e, undefined, "unexpected error" ); + assert.strictEqual( e, undefined, "unexpected error" ); } try { xml = jQuery.parseXML( "<p>Not a <<b>well-formed</b> xml string</p>" ); - ok( false, "invalid xml not detected" ); + assert.ok( false, "invalid xml not detected" ); } catch ( e ) { - strictEqual( e.message, "Invalid XML: <p>Not a <<b>well-formed</b> xml string</p>", "invalid xml detected" ); + assert.strictEqual( e.message, "Invalid XML: <p>Not a <<b>well-formed</b> xml string</p>", "invalid xml detected" ); } try { xml = jQuery.parseXML( "" ); - strictEqual( xml, null, "empty string => null document" ); + assert.strictEqual( xml, null, "empty string => null document" ); xml = jQuery.parseXML(); - strictEqual( xml, null, "undefined string => null document" ); + assert.strictEqual( xml, null, "undefined string => null document" ); xml = jQuery.parseXML( null ); - strictEqual( xml, null, "null string => null document" ); + assert.strictEqual( xml, null, "null string => null document" ); xml = jQuery.parseXML( true ); - strictEqual( xml, null, "non-string => null document" ); + assert.strictEqual( xml, null, "non-string => null document" ); } catch ( e ) { - ok( false, "empty input throws exception" ); + assert.ok( false, "empty input throws exception" ); } } ); -test( "jQuery.camelCase()", function() { +QUnit.test( "jQuery.camelCase()", function( assert ) { var tests = { "foo-bar": "fooBar", @@ -1512,47 +1512,59 @@ test( "jQuery.camelCase()", function() { "-ms-take": "msTake" }; - expect( 7 ); + assert.expect( 7 ); jQuery.each( tests, function( key, val ) { - equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val ); + assert.equal( jQuery.camelCase( key ), val, "Converts: " + key + " => " + val ); } ); } ); -testIframeWithCallback( "Conditional compilation compatibility (#13274)", "core/cc_on.html", function( cc_on, errors, $ ) { - expect( 3 ); - ok( true, "JScript conditional compilation " + ( cc_on ? "supported" : "not supported" ) ); - deepEqual( errors, [], "No errors" ); - ok( $(), "jQuery executes" ); -} ); +testIframeWithCallback( + "Conditional compilation compatibility (#13274)", + "core/cc_on.html", + function( cc_on, errors, $, assert ) { + assert.expect( 3 ); + assert.ok( true, "JScript conditional compilation " + ( cc_on ? "supported" : "not supported" ) ); + assert.deepEqual( errors, [], "No errors" ); + assert.ok( $(), "jQuery executes" ); + } +); // iOS7 doesn't fire the load event if the long-loading iframe gets its source reset to about:blank. // This makes this test fail but it doesn't seem to cause any real-life problems so blacklisting // this test there is preferred to complicating the hard-to-test core/ready code further. if ( !/iphone os 7_/i.test( navigator.userAgent ) ) { - testIframeWithCallback( "document ready when jQuery loaded asynchronously (#13655)", "core/dynamic_ready.html", function( ready ) { - expect( 1 ); - equal( true, ready, "document ready correctly fired when jQuery is loaded after DOMContentLoaded" ); - } ); + testIframeWithCallback( + "document ready when jQuery loaded asynchronously (#13655)", + "core/dynamic_ready.html", + function( ready, assert ) { + assert.expect( 1 ); + assert.equal( true, ready, "document ready correctly fired when jQuery is loaded after DOMContentLoaded" ); + } + ); } -testIframeWithCallback( "Tolerating alias-masked DOM properties (#14074)", "core/aliased.html", - function( errors ) { - expect( 1 ); - deepEqual( errors, [], "jQuery loaded" ); +testIframeWithCallback( + "Tolerating alias-masked DOM properties (#14074)", + "core/aliased.html", + function( errors, assert ) { + assert.expect( 1 ); + assert.deepEqual( errors, [], "jQuery loaded" ); } ); -testIframeWithCallback( "Don't call window.onready (#14802)", "core/onready.html", - function( error ) { - expect( 1 ); - equal( error, false, "no call to user-defined onready" ); +testIframeWithCallback( + "Don't call window.onready (#14802)", + "core/onready.html", + function( error, assert ) { + assert.expect( 1 ); + assert.equal( error, false, "no call to user-defined onready" ); } ); -test( "Iterability of jQuery objects (gh-1693)", function() { +QUnit.test( "Iterability of jQuery objects (gh-1693)", function( assert ) { /* jshint unused: false */ - expect( 1 ); + assert.expect( 1 ); var i, elem, result; @@ -1564,8 +1576,8 @@ test( "Iterability of jQuery objects (gh-1693)", function() { try { eval( "for ( i of elem ) { result += i.nodeName; }" ); } catch ( e ) {} - equal( result, "DIVSPANA", "for-of works on jQuery objects" ); + assert.equal( result, "DIVSPANA", "for-of works on jQuery objects" ); } else { - ok( true, "The browser doesn't support Symbols" ); + assert.ok( true, "The browser doesn't support Symbols" ); } } ); diff --git a/test/unit/css.js b/test/unit/css.js index ac569fdff..dd532f1a7 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -1,35 +1,35 @@ if ( jQuery.css ) { -module( "css", { teardown: moduleTeardown } ); +QUnit.module( "css", { teardown: moduleTeardown } ); -test( "css(String|Hash)", function() { - expect( 43 ); +QUnit.test( "css(String|Hash)", function( assert ) { + assert.expect( 43 ); - equal( jQuery( "#qunit-fixture" ).css( "display" ), "block", "Check for css property \"display\"" ); + assert.equal( jQuery( "#qunit-fixture" ).css( "display" ), "block", "Check for css property \"display\"" ); var $child, div, div2, width, height, child, prctval, checkval, old; $child = jQuery( "#nothiddendivchild" ).css( { "width": "20%", "height": "20%" } ); - notEqual( $child.css( "width" ), "20px", "Retrieving a width percentage on the child of a hidden div returns percentage" ); - notEqual( $child.css( "height" ), "20px", "Retrieving a height percentage on the child of a hidden div returns percentage" ); + assert.notEqual( $child.css( "width" ), "20px", "Retrieving a width percentage on the child of a hidden div returns percentage" ); + assert.notEqual( $child.css( "height" ), "20px", "Retrieving a height percentage on the child of a hidden div returns percentage" ); div = jQuery( "<div/>" ); // These should be "auto" (or some better value) // temporarily provide "0px" for backwards compat - equal( div.css( "width" ), "0px", "Width on disconnected node." ); - equal( div.css( "height" ), "0px", "Height on disconnected node." ); + assert.equal( div.css( "width" ), "0px", "Width on disconnected node." ); + assert.equal( div.css( "height" ), "0px", "Height on disconnected node." ); div.css( { "width": 4, "height": 4 } ); - equal( div.css( "width" ), "4px", "Width on disconnected node." ); - equal( div.css( "height" ), "4px", "Height on disconnected node." ); + assert.equal( div.css( "width" ), "4px", "Width on disconnected node." ); + assert.equal( div.css( "height" ), "4px", "Height on disconnected node." ); div2 = jQuery( "<div style='display:none;'><input type='text' style='height:20px;'/><textarea style='height:20px;'/><div style='height:20px;'></div></div>" ).appendTo( "body" ); - equal( div2.find( "input" ).css( "height" ), "20px", "Height on hidden input." ); - equal( div2.find( "textarea" ).css( "height" ), "20px", "Height on hidden textarea." ); - equal( div2.find( "div" ).css( "height" ), "20px", "Height on hidden div." ); + assert.equal( div2.find( "input" ).css( "height" ), "20px", "Height on hidden input." ); + assert.equal( div2.find( "textarea" ).css( "height" ), "20px", "Height on hidden textarea." ); + assert.equal( div2.find( "div" ).css( "height" ), "20px", "Height on hidden div." ); div2.remove(); @@ -39,45 +39,45 @@ test( "css(String|Hash)", function() { width = parseFloat( jQuery( "#nothiddendiv" ).css( "width" ) ); height = parseFloat( jQuery( "#nothiddendiv" ).css( "height" ) ); jQuery( "#nothiddendiv" ).css( { "overflow":"hidden", "width": -1, "height": -1 } ); - equal( parseFloat( jQuery( "#nothiddendiv" ).css( "width" ) ), 0, "Test negative width set to 0" ); - equal( parseFloat( jQuery( "#nothiddendiv" ).css( "height" ) ), 0, "Test negative height set to 0" ); + assert.equal( parseFloat( jQuery( "#nothiddendiv" ).css( "width" ) ), 0, "Test negative width set to 0" ); + assert.equal( parseFloat( jQuery( "#nothiddendiv" ).css( "height" ) ), 0, "Test negative height set to 0" ); - equal( jQuery( "<div style='display: none;'/>" ).css( "display" ), "none", "Styles on disconnected nodes" ); + assert.equal( jQuery( "<div style='display: none;'/>" ).css( "display" ), "none", "Styles on disconnected nodes" ); jQuery( "#floatTest" ).css( { "float": "right" } ); - equal( jQuery( "#floatTest" ).css( "float" ), "right", "Modified CSS float using \"float\": Assert float is right" ); + assert.equal( jQuery( "#floatTest" ).css( "float" ), "right", "Modified CSS float using \"float\": Assert float is right" ); jQuery( "#floatTest" ).css( { "font-size": "30px" } ); - equal( jQuery( "#floatTest" ).css( "font-size" ), "30px", "Modified CSS font-size: Assert font-size is 30px" ); + assert.equal( jQuery( "#floatTest" ).css( "font-size" ), "30px", "Modified CSS font-size: Assert font-size is 30px" ); jQuery.each( "0,0.25,0.5,0.75,1".split( "," ), function( i, n ) { jQuery( "#foo" ).css( { "opacity": n } ); - equal( jQuery( "#foo" ).css( "opacity" ), parseFloat( n ), "Assert opacity is " + parseFloat( n ) + " as a String" ); + assert.equal( jQuery( "#foo" ).css( "opacity" ), parseFloat( n ), "Assert opacity is " + parseFloat( n ) + " as a String" ); jQuery( "#foo" ).css( { "opacity": parseFloat( n ) } ); - equal( jQuery( "#foo" ).css( "opacity" ), parseFloat( n ), "Assert opacity is " + parseFloat( n ) + " as a Number" ); + assert.equal( jQuery( "#foo" ).css( "opacity" ), parseFloat( n ), "Assert opacity is " + parseFloat( n ) + " as a Number" ); } ); jQuery( "#foo" ).css( { "opacity": "" } ); - equal( jQuery( "#foo" ).css( "opacity" ), "1", "Assert opacity is 1 when set to an empty String" ); + assert.equal( jQuery( "#foo" ).css( "opacity" ), "1", "Assert opacity is 1 when set to an empty String" ); - equal( jQuery( "#empty" ).css( "opacity" ), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" ); + assert.equal( jQuery( "#empty" ).css( "opacity" ), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" ); jQuery( "#empty" ).css( { "opacity": "1" } ); - equal( jQuery( "#empty" ).css( "opacity" ), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" ); + assert.equal( jQuery( "#empty" ).css( "opacity" ), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" ); jQuery.support.opacity ? - ok( true, "Requires the same number of tests" ) : - ok( ~jQuery( "#empty" )[ 0 ].currentStyle.filter.indexOf( "gradient" ), "Assert setting opacity doesn't overwrite other filters of the stylesheet in IE" ); + assert.ok( true, "Requires the same number of tests" ) : + assert.ok( ~jQuery( "#empty" )[ 0 ].currentStyle.filter.indexOf( "gradient" ), "Assert setting opacity doesn't overwrite other filters of the stylesheet in IE" ); div = jQuery( "#nothiddendiv" ); child = jQuery( "#nothiddendivchild" ); - equal( parseInt( div.css( "fontSize" ), 10 ), 16, "Verify fontSize px set." ); - equal( parseInt( div.css( "font-size" ), 10 ), 16, "Verify fontSize px set." ); - equal( parseInt( child.css( "fontSize" ), 10 ), 16, "Verify fontSize px set." ); - equal( parseInt( child.css( "font-size" ), 10 ), 16, "Verify fontSize px set." ); + assert.equal( parseInt( div.css( "fontSize" ), 10 ), 16, "Verify fontSize px set." ); + assert.equal( parseInt( div.css( "font-size" ), 10 ), 16, "Verify fontSize px set." ); + assert.equal( parseInt( child.css( "fontSize" ), 10 ), 16, "Verify fontSize px set." ); + assert.equal( parseInt( child.css( "font-size" ), 10 ), 16, "Verify fontSize px set." ); child.css( "height", "100%" ); - equal( child[ 0 ].style.height, "100%", "Make sure the height is being set correctly." ); + assert.equal( child[ 0 ].style.height, "100%", "Make sure the height is being set correctly." ); child.attr( "class", "em" ); - equal( parseInt( child.css( "fontSize" ), 10 ), 32, "Verify fontSize em set." ); + assert.equal( parseInt( child.css( "fontSize" ), 10 ), 32, "Verify fontSize em set." ); // Have to verify this as the result depends upon the browser's CSS // support for font-size percentages @@ -88,140 +88,140 @@ test( "css(String|Hash)", function() { checkval = prctval; } - equal( prctval, checkval, "Verify fontSize % set." ); + assert.equal( prctval, checkval, "Verify fontSize % set." ); - equal( typeof child.css( "width" ), "string", "Make sure that a string width is returned from css('width')." ); + assert.equal( typeof child.css( "width" ), "string", "Make sure that a string width is returned from css('width')." ); old = child[ 0 ].style.height; // Test NaN child.css( "height", parseFloat( "zoo" ) ); - equal( child[ 0 ].style.height, old, "Make sure height isn't changed on NaN." ); + assert.equal( child[ 0 ].style.height, old, "Make sure height isn't changed on NaN." ); // Test null child.css( "height", null ); - equal( child[ 0 ].style.height, old, "Make sure height isn't changed on null." ); + assert.equal( child[ 0 ].style.height, old, "Make sure height isn't changed on null." ); old = child[ 0 ].style.fontSize; // Test NaN child.css( "font-size", parseFloat( "zoo" ) ); - equal( child[ 0 ].style.fontSize, old, "Make sure font-size isn't changed on NaN." ); + assert.equal( child[ 0 ].style.fontSize, old, "Make sure font-size isn't changed on NaN." ); // Test null child.css( "font-size", null ); - equal( child[ 0 ].style.fontSize, old, "Make sure font-size isn't changed on null." ); + assert.equal( child[ 0 ].style.fontSize, old, "Make sure font-size isn't changed on null." ); - strictEqual( child.css( "x-fake" ), undefined, "Make sure undefined is returned from css(nonexistent)." ); + assert.strictEqual( child.css( "x-fake" ), undefined, "Make sure undefined is returned from css(nonexistent)." ); div = jQuery( "<div/>" ).css( { position: "absolute", "z-index": 1000 } ).appendTo( "#qunit-fixture" ); - strictEqual( div.css( "z-index" ), "1000", + assert.strictEqual( div.css( "z-index" ), "1000", "Make sure that a string z-index is returned from css('z-index') (#14432)." ); } ); -test( "css(String) computed values", function() { - expect( 3 ); +QUnit.test( "css(String) computed values", function( assert ) { + assert.expect( 3 ); var div = jQuery( "<div/>" ).addClass( "get-computed-value" ), fixture = document.getElementById( "qunit-fixture" ); div.appendTo( fixture ); - strictEqual( div.css( "padding-left" ), "500px", "should get computed value for padding-left property" ); - strictEqual( div.css( "width" ), "200px", "should get computed value for width property" ); - strictEqual( div.css( "font-size" ), "32px", "should get computed value for font-size property" ); + assert.strictEqual( div.css( "padding-left" ), "500px", "should get computed value for padding-left property" ); + assert.strictEqual( div.css( "width" ), "200px", "should get computed value for width property" ); + assert.strictEqual( div.css( "font-size" ), "32px", "should get computed value for font-size property" ); } ); -test( "css() explicit and relative values", function() { - expect( 29 ); +QUnit.test( "css() explicit and relative values", function( assert ) { + assert.expect( 29 ); var $elem = jQuery( "#nothiddendiv" ); $elem.css( { "width": 1, "height": 1, "paddingLeft": "1px", "opacity": 1 } ); - equal( $elem.css( "width" ), "1px", "Initial css set or width/height works (hash)" ); - equal( $elem.css( "paddingLeft" ), "1px", "Initial css set of paddingLeft works (hash)" ); - equal( $elem.css( "opacity" ), "1", "Initial css set of opacity works (hash)" ); + assert.equal( $elem.css( "width" ), "1px", "Initial css set or width/height works (hash)" ); + assert.equal( $elem.css( "paddingLeft" ), "1px", "Initial css set of paddingLeft works (hash)" ); + assert.equal( $elem.css( "opacity" ), "1", "Initial css set of opacity works (hash)" ); $elem.css( { width: "+=9" } ); - equal( $elem.css( "width" ), "10px", "'+=9' on width (hash)" ); + assert.equal( $elem.css( "width" ), "10px", "'+=9' on width (hash)" ); $elem.css( { "width": "-=9" } ); - equal( $elem.css( "width" ), "1px", "'-=9' on width (hash)" ); + assert.equal( $elem.css( "width" ), "1px", "'-=9' on width (hash)" ); $elem.css( { "width": "+=9px" } ); - equal( $elem.css( "width" ), "10px", "'+=9px' on width (hash)" ); + assert.equal( $elem.css( "width" ), "10px", "'+=9px' on width (hash)" ); $elem.css( { "width": "-=9px" } ); - equal( $elem.css( "width" ), "1px", "'-=9px' on width (hash)" ); + assert.equal( $elem.css( "width" ), "1px", "'-=9px' on width (hash)" ); $elem.css( "width", "+=9" ); - equal( $elem.css( "width" ), "10px", "'+=9' on width (params)" ); + assert.equal( $elem.css( "width" ), "10px", "'+=9' on width (params)" ); $elem.css( "width", "-=9" ) ; - equal( $elem.css( "width" ), "1px", "'-=9' on width (params)" ); + assert.equal( $elem.css( "width" ), "1px", "'-=9' on width (params)" ); $elem.css( "width", "+=9px" ); - equal( $elem.css( "width" ), "10px", "'+=9px' on width (params)" ); + assert.equal( $elem.css( "width" ), "10px", "'+=9px' on width (params)" ); $elem.css( "width", "-=9px" ); - equal( $elem.css( "width" ), "1px", "'-=9px' on width (params)" ); + assert.equal( $elem.css( "width" ), "1px", "'-=9px' on width (params)" ); $elem.css( "width", "-=-9px" ); - equal( $elem.css( "width" ), "10px", "'-=-9px' on width (params)" ); + assert.equal( $elem.css( "width" ), "10px", "'-=-9px' on width (params)" ); $elem.css( "width", "+=-9px" ); - equal( $elem.css( "width" ), "1px", "'+=-9px' on width (params)" ); + assert.equal( $elem.css( "width" ), "1px", "'+=-9px' on width (params)" ); $elem.css( { "paddingLeft": "+=4" } ); - equal( $elem.css( "paddingLeft" ), "5px", "'+=4' on paddingLeft (hash)" ); + assert.equal( $elem.css( "paddingLeft" ), "5px", "'+=4' on paddingLeft (hash)" ); $elem.css( { "paddingLeft": "-=4" } ); - equal( $elem.css( "paddingLeft" ), "1px", "'-=4' on paddingLeft (hash)" ); + assert.equal( $elem.css( "paddingLeft" ), "1px", "'-=4' on paddingLeft (hash)" ); $elem.css( { "paddingLeft": "+=4px" } ); - equal( $elem.css( "paddingLeft" ), "5px", "'+=4px' on paddingLeft (hash)" ); + assert.equal( $elem.css( "paddingLeft" ), "5px", "'+=4px' on paddingLeft (hash)" ); $elem.css( { "paddingLeft": "-=4px" } ); - equal( $elem.css( "paddingLeft" ), "1px", "'-=4px' on paddingLeft (hash)" ); + assert.equal( $elem.css( "paddingLeft" ), "1px", "'-=4px' on paddingLeft (hash)" ); $elem.css( { "padding-left": "+=4" } ); - equal( $elem.css( "paddingLeft" ), "5px", "'+=4' on padding-left (hash)" ); + assert.equal( $elem.css( "paddingLeft" ), "5px", "'+=4' on padding-left (hash)" ); $elem.css( { "padding-left": "-=4" } ); - equal( $elem.css( "paddingLeft" ), "1px", "'-=4' on padding-left (hash)" ); + assert.equal( $elem.css( "paddingLeft" ), "1px", "'-=4' on padding-left (hash)" ); $elem.css( { "padding-left": "+=4px" } ); - equal( $elem.css( "paddingLeft" ), "5px", "'+=4px' on padding-left (hash)" ); + assert.equal( $elem.css( "paddingLeft" ), "5px", "'+=4px' on padding-left (hash)" ); $elem.css( { "padding-left": "-=4px" } ); - equal( $elem.css( "paddingLeft" ), "1px", "'-=4px' on padding-left (hash)" ); + assert.equal( $elem.css( "paddingLeft" ), "1px", "'-=4px' on padding-left (hash)" ); $elem.css( "paddingLeft", "+=4" ); - equal( $elem.css( "paddingLeft" ), "5px", "'+=4' on paddingLeft (params)" ); + assert.equal( $elem.css( "paddingLeft" ), "5px", "'+=4' on paddingLeft (params)" ); $elem.css( "paddingLeft", "-=4" ); - equal( $elem.css( "paddingLeft" ), "1px", "'-=4' on paddingLeft (params)" ); + assert.equal( $elem.css( "paddingLeft" ), "1px", "'-=4' on paddingLeft (params)" ); $elem.css( "padding-left", "+=4px" ); - equal( $elem.css( "paddingLeft" ), "5px", "'+=4px' on padding-left (params)" ); + assert.equal( $elem.css( "paddingLeft" ), "5px", "'+=4px' on padding-left (params)" ); $elem.css( "padding-left", "-=4px" ); - equal( $elem.css( "paddingLeft" ), "1px", "'-=4px' on padding-left (params)" ); + assert.equal( $elem.css( "paddingLeft" ), "1px", "'-=4px' on padding-left (params)" ); $elem.css( { "opacity": "-=0.5" } ); - equal( $elem.css( "opacity" ), "0.5", "'-=0.5' on opacity (hash)" ); + assert.equal( $elem.css( "opacity" ), "0.5", "'-=0.5' on opacity (hash)" ); $elem.css( { "opacity": "+=0.5" } ); - equal( $elem.css( "opacity" ), "1", "'+=0.5' on opacity (hash)" ); + assert.equal( $elem.css( "opacity" ), "1", "'+=0.5' on opacity (hash)" ); $elem.css( "opacity", "-=0.5" ); - equal( $elem.css( "opacity" ), "0.5", "'-=0.5' on opacity (params)" ); + assert.equal( $elem.css( "opacity" ), "0.5", "'-=0.5' on opacity (params)" ); $elem.css( "opacity", "+=0.5" ); - equal( $elem.css( "opacity" ), "1", "'+=0.5' on opacity (params)" ); + assert.equal( $elem.css( "opacity" ), "1", "'+=0.5' on opacity (params)" ); } ); -test( "css() non-px relative values (gh-1711)", function() { - expect( 17 ); +QUnit.test( "css() non-px relative values (gh-1711)", function( assert ) { + assert.expect( 17 ); var cssCurrent, units = {}, @@ -240,11 +240,11 @@ test( "css() non-px relative values (gh-1711)", function() { // Require a difference of no more than one pixel difference = Math.abs( cssCurrent - expected ); if ( difference <= 1 ) { - ok( true, message ); + assert.ok( true, message ); // ...or fail with actual and expected values } else { - ok( false, message + " (actual " + cssCurrent + ", expected " + expected + ")" ); + assert.ok( false, message + " (actual " + cssCurrent + ", expected " + expected + ")" ); } }, getUnits = function( prop ) { @@ -286,36 +286,36 @@ test( "css() non-px relative values (gh-1711)", function() { add( "lineHeight", 50, "%" ); } ); -test( "css(String, Object)", function() { - expect( 19 ); +QUnit.test( "css(String, Object)", function( assert ) { + assert.expect( 19 ); var j, div, display, ret, success; jQuery( "#floatTest" ).css( "float", "left" ); - equal( jQuery( "#floatTest" ).css( "float" ), "left", "Modified CSS float using \"float\": Assert float is left" ); + assert.equal( jQuery( "#floatTest" ).css( "float" ), "left", "Modified CSS float using \"float\": Assert float is left" ); jQuery( "#floatTest" ).css( "font-size", "20px" ); - equal( jQuery( "#floatTest" ).css( "font-size" ), "20px", "Modified CSS font-size: Assert font-size is 20px" ); + assert.equal( jQuery( "#floatTest" ).css( "font-size" ), "20px", "Modified CSS font-size: Assert font-size is 20px" ); jQuery.each( "0,0.25,0.5,0.75,1".split( "," ), function( i, n ) { jQuery( "#foo" ).css( "opacity", n ); - equal( jQuery( "#foo" ).css( "opacity" ), parseFloat( n ), "Assert opacity is " + parseFloat( n ) + " as a String" ); + assert.equal( jQuery( "#foo" ).css( "opacity" ), parseFloat( n ), "Assert opacity is " + parseFloat( n ) + " as a String" ); jQuery( "#foo" ).css( "opacity", parseFloat( n ) ); - equal( jQuery( "#foo" ).css( "opacity" ), parseFloat( n ), "Assert opacity is " + parseFloat( n ) + " as a Number" ); + assert.equal( jQuery( "#foo" ).css( "opacity" ), parseFloat( n ), "Assert opacity is " + parseFloat( n ) + " as a Number" ); } ); jQuery( "#foo" ).css( "opacity", "" ); - equal( jQuery( "#foo" ).css( "opacity" ), "1", "Assert opacity is 1 when set to an empty String" ); + assert.equal( jQuery( "#foo" ).css( "opacity" ), "1", "Assert opacity is 1 when set to an empty String" ); // using contents will get comments regular, text, and comment nodes j = jQuery( "#nonnodes" ).contents(); j.css( "overflow", "visible" ); - equal( j.css( "overflow" ), "visible", "Check node,textnode,comment css works" ); - equal( jQuery( "#t2037 .hidden" ).css( "display" ), "none", "Make sure browser thinks it is hidden" ); + assert.equal( j.css( "overflow" ), "visible", "Check node,textnode,comment css works" ); + assert.equal( jQuery( "#t2037 .hidden" ).css( "display" ), "none", "Make sure browser thinks it is hidden" ); div = jQuery( "#nothiddendiv" ); display = div.css( "display" ); ret = div.css( "display", undefined ); - equal( ret, div, "Make sure setting undefined returns the original set." ); - equal( div.css( "display" ), display, "Make sure that the display wasn't changed." ); + assert.equal( ret, div, "Make sure setting undefined returns the original set." ); + assert.equal( div.css( "display" ), display, "Make sure that the display wasn't changed." ); success = true; try { @@ -324,30 +324,30 @@ test( "css(String, Object)", function() { catch ( e ) { success = false; } - ok( success, "Setting RGBA values does not throw Error (#5509)" ); + assert.ok( success, "Setting RGBA values does not throw Error (#5509)" ); jQuery( "#foo" ).css( "font", "7px/21px sans-serif" ); - strictEqual( jQuery( "#foo" ).css( "line-height" ), "21px", + assert.strictEqual( jQuery( "#foo" ).css( "line-height" ), "21px", "Set font shorthand property (#14759)" ); } ); -test( "css(String, Object) with negative values", function() { - expect( 4 ); +QUnit.test( "css(String, Object) with negative values", function( assert ) { + assert.expect( 4 ); jQuery( "#nothiddendiv" ).css( "margin-top", "-10px" ); jQuery( "#nothiddendiv" ).css( "margin-left", "-10px" ); - equal( jQuery( "#nothiddendiv" ).css( "margin-top" ), "-10px", "Ensure negative top margins work." ); - equal( jQuery( "#nothiddendiv" ).css( "margin-left" ), "-10px", "Ensure negative left margins work." ); + assert.equal( jQuery( "#nothiddendiv" ).css( "margin-top" ), "-10px", "Ensure negative top margins work." ); + assert.equal( jQuery( "#nothiddendiv" ).css( "margin-left" ), "-10px", "Ensure negative left margins work." ); jQuery( "#nothiddendiv" ).css( "position", "absolute" ); jQuery( "#nothiddendiv" ).css( "top", "-20px" ); jQuery( "#nothiddendiv" ).css( "left", "-20px" ); - equal( jQuery( "#nothiddendiv" ).css( "top" ), "-20px", "Ensure negative top values work." ); - equal( jQuery( "#nothiddendiv" ).css( "left" ), "-20px", "Ensure negative left values work." ); + assert.equal( jQuery( "#nothiddendiv" ).css( "top" ), "-20px", "Ensure negative top values work." ); + assert.equal( jQuery( "#nothiddendiv" ).css( "left" ), "-20px", "Ensure negative left values work." ); } ); -test( "css(Array)", function() { - expect( 2 ); +QUnit.test( "css(Array)", function( assert ) { + assert.expect( 2 ); var expectedMany = { "overflow": "visible", @@ -358,31 +358,31 @@ test( "css(Array)", function() { }, elem = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" ); - deepEqual( elem.css( expectedMany ).css( [ "overflow", "width" ] ), expectedMany, "Getting multiple element array" ); - deepEqual( elem.css( expectedSingle ).css( [ "width" ] ), expectedSingle, "Getting single element array" ); + assert.deepEqual( elem.css( expectedMany ).css( [ "overflow", "width" ] ), expectedMany, "Getting multiple element array" ); + assert.deepEqual( elem.css( expectedSingle ).css( [ "width" ] ), expectedSingle, "Getting single element array" ); } ); if ( !jQuery.support.opacity ) { - test( "css(String, Object) for MSIE", function() { - expect( 5 ); + QUnit.test( "css(String, Object) for MSIE", function( assert ) { + assert.expect( 5 ); // for #1438, IE throws JS error when filter exists but doesn't have opacity in it jQuery( "#foo" ).css( "filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');" ); - equal( jQuery( "#foo" ).css( "opacity" ), "1", "Assert opacity is 1 when a different filter is set in IE, #1438" ); + assert.equal( jQuery( "#foo" ).css( "opacity" ), "1", "Assert opacity is 1 when a different filter is set in IE, #1438" ); var filterVal = "progid:DXImageTransform.Microsoft.Alpha(opacity=30) progid:DXImageTransform.Microsoft.Blur(pixelradius=5)", filterVal2 = "progid:DXImageTransform.Microsoft.alpha(opacity=100) progid:DXImageTransform.Microsoft.Blur(pixelradius=5)", filterVal3 = "progid:DXImageTransform.Microsoft.Blur(pixelradius=5)"; jQuery( "#foo" ).css( "filter", filterVal ); - equal( jQuery( "#foo" ).css( "filter" ), filterVal, "css('filter', val) works" ); + assert.equal( jQuery( "#foo" ).css( "filter" ), filterVal, "css('filter', val) works" ); jQuery( "#foo" ).css( "opacity", 1 ); - equal( jQuery( "#foo" ).css( "filter" ), filterVal2, "Setting opacity in IE doesn't duplicate opacity filter" ); - equal( jQuery( "#foo" ).css( "opacity" ), 1, "Setting opacity in IE with other filters works" ); + assert.equal( jQuery( "#foo" ).css( "filter" ), filterVal2, "Setting opacity in IE doesn't duplicate opacity filter" ); + assert.equal( jQuery( "#foo" ).css( "opacity" ), 1, "Setting opacity in IE with other filters works" ); jQuery( "#foo" ).css( "filter", filterVal3 ).css( "opacity", 1 ); - ok( jQuery( "#foo" ).css( "filter" ).indexOf( filterVal3 ) !== -1, "Setting opacity in IE doesn't clobber other filters" ); + assert.ok( jQuery( "#foo" ).css( "filter" ).indexOf( filterVal3 ) !== -1, "Setting opacity in IE doesn't clobber other filters" ); } ); - test( "Setting opacity to 1 properly removes filter: style (#6652)", function() { + QUnit.test( "Setting opacity to 1 properly removes filter: style (#6652)", function( assert ) { var rfilter = /filter:[^;]*/i, test = jQuery( "#t6652" ).css( "opacity", 1 ), test2 = test.find( "div" ).css( "opacity", 1 ); @@ -390,14 +390,14 @@ if ( !jQuery.support.opacity ) { function hasFilter( elem ) { return !!rfilter.exec( elem[ 0 ].style.cssText ); } - expect( 2 ); - ok( !hasFilter( test ), "Removed filter attribute on element without filter in stylesheet" ); - ok( hasFilter( test2 ), "Filter attribute remains on element that had filter in stylesheet" ); + assert.expect( 2 ); + assert.ok( !hasFilter( test ), "Removed filter attribute on element without filter in stylesheet" ); + assert.ok( hasFilter( test2 ), "Filter attribute remains on element that had filter in stylesheet" ); } ); } -test( "css(String, Function)", function() { - expect( 3 ); +QUnit.test( "css(String, Function)", function( assert ) { + assert.expect( 3 ); var index, sizes = [ "10px", "20px", "30px" ]; @@ -420,15 +420,15 @@ test( "css(String, Function)", function() { jQuery( "#cssFunctionTest div" ).each( function() { var computedSize = jQuery( this ).css( "font-size" ), expectedSize = sizes[ index ]; - equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize ); + assert.equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize ); index++; } ); jQuery( "#cssFunctionTest" ).remove(); } ); -test( "css(String, Function) with incoming value", function() { - expect( 3 ); +QUnit.test( "css(String, Function) with incoming value", function( assert ) { + assert.expect( 3 ); var index, sizes = [ "10px", "20px", "30px" ]; @@ -450,7 +450,7 @@ test( "css(String, Function) with incoming value", function() { jQuery( "#cssFunctionTest div" ).css( "font-size", function( i, computedSize ) { var expectedSize = sizes[ index ]; - equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize ); + assert.equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize ); index++; return computedSize; } ); @@ -458,8 +458,8 @@ test( "css(String, Function) with incoming value", function() { jQuery( "#cssFunctionTest" ).remove(); } ); -test( "css(Object) where values are Functions", function() { - expect( 3 ); +QUnit.test( "css(Object) where values are Functions", function( assert ) { + assert.expect( 3 ); var index, sizes = [ "10px", "20px", "30px" ]; @@ -482,15 +482,15 @@ test( "css(Object) where values are Functions", function() { jQuery( "#cssFunctionTest div" ).each( function() { var computedSize = jQuery( this ).css( "font-size" ), expectedSize = sizes[ index ]; - equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize ); + assert.equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize ); index++; } ); jQuery( "#cssFunctionTest" ).remove(); } ); -test( "css(Object) where values are Functions with incoming values", function() { - expect( 3 ); +QUnit.test( "css(Object) where values are Functions with incoming values", function( assert ) { + assert.expect( 3 ); var index, sizes = [ "10px", "20px", "30px" ]; @@ -512,7 +512,7 @@ test( "css(Object) where values are Functions with incoming values", function() jQuery( "#cssFunctionTest div" ).css( { "font-size": function( i, computedSize ) { var expectedSize = sizes[ index ]; - equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize ); + assert.equal( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize ); index++; return computedSize; } } ); @@ -520,38 +520,38 @@ test( "css(Object) where values are Functions with incoming values", function() jQuery( "#cssFunctionTest" ).remove(); } ); -test( "show(); hide()", function() { - expect( 4 ); +QUnit.test( "show(); hide()", function( assert ) { + assert.expect( 4 ); var hiddendiv, div; hiddendiv = jQuery( "div.hidden" ); hiddendiv.hide(); - equal( hiddendiv.css( "display" ), "none", "Cascade-hidden div after hide()" ); + assert.equal( hiddendiv.css( "display" ), "none", "Cascade-hidden div after hide()" ); hiddendiv.show(); - equal( hiddendiv.css( "display" ), "none", "Show does not trump CSS cascade" ); + assert.equal( hiddendiv.css( "display" ), "none", "Show does not trump CSS cascade" ); div = jQuery( "<div>" ).hide(); - equal( div.css( "display" ), "none", "Detached div hidden" ); + assert.equal( div.css( "display" ), "none", "Detached div hidden" ); div.appendTo( "#qunit-fixture" ).show(); - equal( div.css( "display" ), "block", "Initially-detached div after show()" ); + assert.equal( div.css( "display" ), "block", "Initially-detached div after show()" ); } ); -test( "show();", function() { +QUnit.test( "show();", function( assert ) { - expect( 18 ); + assert.expect( 18 ); var hiddendiv, div, pass, test; hiddendiv = jQuery( "div.hidden" ); - equal( jQuery.css( hiddendiv[ 0 ], "display" ), "none", "hiddendiv is display: none" ); + assert.equal( jQuery.css( hiddendiv[ 0 ], "display" ), "none", "hiddendiv is display: none" ); hiddendiv.css( "display", "block" ); - equal( jQuery.css( hiddendiv[ 0 ], "display" ), "block", "hiddendiv is display: block" ); + assert.equal( jQuery.css( hiddendiv[ 0 ], "display" ), "block", "hiddendiv is display: block" ); hiddendiv.show(); - equal( jQuery.css( hiddendiv[ 0 ], "display" ), "block", "hiddendiv is display: block" ); + assert.equal( jQuery.css( hiddendiv[ 0 ], "display" ), "block", "hiddendiv is display: block" ); hiddendiv.css( "display", "" ); @@ -562,7 +562,7 @@ test( "show();", function() { pass = false; } } ); - ok( pass, "Show" ); + assert.ok( pass, "Show" ); jQuery( "<div id='show-tests'>" + @@ -593,7 +593,7 @@ test( "show();", function() { jQuery.each( test, function( selector, expected ) { var elem = jQuery( selector, "#show-tests" ).show(); - equal( elem.css( "display" ), expected, "Show using correct display type for " + selector ); + assert.equal( elem.css( "display" ), expected, "Show using correct display type for " + selector ); } ); // Make sure that showing or hiding a text node doesn't cause an error @@ -601,73 +601,73 @@ test( "show();", function() { jQuery( "<div>test</div> text <span>test</span>" ).hide().remove(); } ); -test( "show() resolves correct default display for detached nodes", function() { - expect( 16 ); +QUnit.test( "show() resolves correct default display for detached nodes", function( assert ) { + assert.expect( 16 ); var div, span, tr; div = jQuery( "<div class='hidden'>" ); div.show().appendTo( "#qunit-fixture" ); - equal( div.css( "display" ), "none", + assert.equal( div.css( "display" ), "none", "A shown-while-detached div can be hidden by the CSS cascade" ); div = jQuery( "<div><div class='hidden'></div></div>" ).children( "div" ); div.show().appendTo( "#qunit-fixture" ); - equal( div.css( "display" ), "none", + assert.equal( div.css( "display" ), "none", "A shown-while-detached div inside a visible div can be hidden by the CSS cascade" ); span = jQuery( "<span class='hidden'/>" ); span.show().appendTo( "#qunit-fixture" ); - equal( span.css( "display" ), "none", + assert.equal( span.css( "display" ), "none", "A shown-while-detached span can be hidden by the CSS cascade" ); div = jQuery( "div.hidden" ); div.detach().show(); - ok( !div[ 0 ].style.display, + assert.ok( !div[ 0 ].style.display, "show() does not update inline style of a cascade-hidden-before-detach div" ); div.appendTo( "#qunit-fixture" ); - equal( div.css( "display" ), "none", + assert.equal( div.css( "display" ), "none", "A shown-while-detached cascade-hidden div is hidden after attachment" ); div.remove(); span = jQuery( "<span class='hidden'/>" ); span.appendTo( "#qunit-fixture" ).detach().show().appendTo( "#qunit-fixture" ); - equal( span.css( "display" ), "none", + assert.equal( span.css( "display" ), "none", "A shown-while-detached cascade-hidden span is hidden after attachment" ); span.remove(); div = jQuery( document.createElement( "div" ) ); div.show().appendTo( "#qunit-fixture" ); - ok( !div[ 0 ].style.display, "A shown-while-detached div has no inline style" ); - equal( div.css( "display" ), "block", + assert.ok( !div[ 0 ].style.display, "A shown-while-detached div has no inline style" ); + assert.equal( div.css( "display" ), "block", "A shown-while-detached div has default display after attachment" ); div.remove(); div = jQuery( "<div style='display: none'>" ); div.show(); - equal( div[ 0 ].style.display, "", + assert.equal( div[ 0 ].style.display, "", "show() updates inline style of a detached inline-hidden div" ); div.appendTo( "#qunit-fixture" ); - equal( div.css( "display" ), "block", + assert.equal( div.css( "display" ), "block", "A shown-while-detached inline-hidden div has default display after attachment" ); div = jQuery( "<div><div style='display: none'></div></div>" ).children( "div" ); div.show().appendTo( "#qunit-fixture" ); - equal( div.css( "display" ), "block", + assert.equal( div.css( "display" ), "block", "A shown-while-detached inline-hidden div inside a visible div has default display " + "after attachment" ); span = jQuery( "<span style='display: none'/>" ); span.show(); - equal( span[ 0 ].style.display, "", + assert.equal( span[ 0 ].style.display, "", "show() updates inline style of a detached inline-hidden span" ); span.appendTo( "#qunit-fixture" ); - equal( span.css( "display" ), "inline", + assert.equal( span.css( "display" ), "inline", "A shown-while-detached inline-hidden span has default display after attachment" ); div = jQuery( "<div style='display: inline'/>" ); div.show().appendTo( "#qunit-fixture" ); - equal( div.css( "display" ), "inline", + assert.equal( div.css( "display" ), "inline", "show() does not update inline style of a detached inline-visible div" ); div.remove(); @@ -675,74 +675,74 @@ test( "show() resolves correct default display for detached nodes", function() { jQuery( "#table" ).append( tr ); tr.detach().hide().show(); - ok( !tr[ 0 ].style.display, "Not-hidden detached tr elements have no inline style" ); + assert.ok( !tr[ 0 ].style.display, "Not-hidden detached tr elements have no inline style" ); tr.remove(); span = jQuery( "<span/>" ).hide().show(); - ok( !span[ 0 ].style.display, "Not-hidden detached span elements have no inline style" ); + assert.ok( !span[ 0 ].style.display, "Not-hidden detached span elements have no inline style" ); span.remove(); } ); -test( "toggle()", function() { - expect( 9 ); +QUnit.test( "toggle()", function( assert ) { + assert.expect( 9 ); var div, oldHide, x = jQuery( "#foo" ); - ok( x.is( ":visible" ), "is visible" ); + assert.ok( x.is( ":visible" ), "is visible" ); x.toggle(); - ok( x.is( ":hidden" ), "is hidden" ); + assert.ok( x.is( ":hidden" ), "is hidden" ); x.toggle(); - ok( x.is( ":visible" ), "is visible again" ); + assert.ok( x.is( ":visible" ), "is visible again" ); x.toggle( true ); - ok( x.is( ":visible" ), "is visible" ); + assert.ok( x.is( ":visible" ), "is visible" ); x.toggle( false ); - ok( x.is( ":hidden" ), "is hidden" ); + assert.ok( x.is( ":hidden" ), "is hidden" ); x.toggle( true ); - ok( x.is( ":visible" ), "is visible again" ); + assert.ok( x.is( ":visible" ), "is visible again" ); div = jQuery( "<div style='display:none'><div></div></div>" ).appendTo( "#qunit-fixture" ); x = div.find( "div" ); - strictEqual( x.toggle().css( "display" ), "none", "is hidden" ); - strictEqual( x.toggle().css( "display" ), "block", "is visible" ); + assert.strictEqual( x.toggle().css( "display" ), "none", "is hidden" ); + assert.strictEqual( x.toggle().css( "display" ), "block", "is visible" ); // Ensure hide() is called when toggled (#12148) oldHide = jQuery.fn.hide; jQuery.fn.hide = function() { - ok( true, name + " method called on toggle" ); + assert.ok( true, name + " method called on toggle" ); return oldHide.apply( this, arguments ); }; x.toggle( name === "show" ); jQuery.fn.hide = oldHide; } ); -test( "hide hidden elements (bug #7141)", function() { - expect( 3 ); +QUnit.test( "hide hidden elements (bug #7141)", function( assert ) { + assert.expect( 3 ); var div = jQuery( "<div style='display:none'></div>" ).appendTo( "#qunit-fixture" ); - equal( div.css( "display" ), "none", "Element is hidden by default" ); + assert.equal( div.css( "display" ), "none", "Element is hidden by default" ); div.hide(); - ok( !jQuery._data( div, "display" ), "display data is undefined after hiding an already-hidden element" ); + assert.ok( !jQuery._data( div, "display" ), "display data is undefined after hiding an already-hidden element" ); div.show(); - equal( div.css( "display" ), "block", "Show a double-hidden element" ); + assert.equal( div.css( "display" ), "block", "Show a double-hidden element" ); div.remove(); } ); -test( "jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function() { - expect( 4 ); +QUnit.test( "jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function( assert ) { + assert.expect( 4 ); var $checkedtest = jQuery( "#checkedtest" ); jQuery.css( $checkedtest[ 0 ], "height" ); - ok( jQuery( "input[type='radio']", $checkedtest ).first().attr( "checked" ), "Check first radio still checked." ); - ok( !jQuery( "input[type='radio']", $checkedtest ).last().attr( "checked" ), "Check last radio still NOT checked." ); - ok( jQuery( "input[type='checkbox']", $checkedtest ).first().attr( "checked" ), "Check first checkbox still checked." ); - ok( !jQuery( "input[type='checkbox']", $checkedtest ).last().attr( "checked" ), "Check last checkbox still NOT checked." ); + assert.ok( jQuery( "input[type='radio']", $checkedtest ).first().attr( "checked" ), "Check first radio still checked." ); + assert.ok( !jQuery( "input[type='radio']", $checkedtest ).last().attr( "checked" ), "Check last radio still NOT checked." ); + assert.ok( jQuery( "input[type='checkbox']", $checkedtest ).first().attr( "checked" ), "Check first checkbox still checked." ); + assert.ok( !jQuery( "input[type='checkbox']", $checkedtest ).last().attr( "checked" ), "Check last checkbox still NOT checked." ); } ); -test( "internal ref to elem.runtimeStyle (bug #7608)", function() { - expect( 1 ); +QUnit.test( "internal ref to elem.runtimeStyle (bug #7608)", function( assert ) { + assert.expect( 1 ); var result = true; try { @@ -751,11 +751,11 @@ test( "internal ref to elem.runtimeStyle (bug #7608)", function() { result = false; } - ok( result, "elem.runtimeStyle does not throw exception" ); + assert.ok( result, "elem.runtimeStyle does not throw exception" ); } ); -test( "marginRight computed style (bug #3333)", function() { - expect( 1 ); +QUnit.test( "marginRight computed style (bug #3333)", function( assert ) { + assert.expect( 1 ); var $div = jQuery( "#foo" ); $div.css( { @@ -763,22 +763,22 @@ test( "marginRight computed style (bug #3333)", function() { "marginRight": 0 } ); - equal( $div.css( "marginRight" ), "0px", "marginRight correctly calculated with a width and display block" ); + assert.equal( $div.css( "marginRight" ), "0px", "marginRight correctly calculated with a width and display block" ); } ); -test( "box model properties incorrectly returning % instead of px, see #10639 and #12088", function() { - expect( 2 ); +QUnit.test( "box model properties incorrectly returning % instead of px, see #10639 and #12088", function( assert ) { + assert.expect( 2 ); var container = jQuery( "<div/>" ).width( 400 ).appendTo( "#qunit-fixture" ), el = jQuery( "<div/>" ).css( { "width": "50%", "marginRight": "50%" } ).appendTo( container ), el2 = jQuery( "<div/>" ).css( { "width": "50%", "minWidth": "300px", "marginLeft": "25%" } ).appendTo( container ); - equal( el.css( "marginRight" ), "200px", "css('marginRight') returning % instead of px, see #10639" ); - equal( el2.css( "marginLeft" ), "100px", "css('marginLeft') returning incorrect pixel value, see #12088" ); + assert.equal( el.css( "marginRight" ), "200px", "css('marginRight') returning % instead of px, see #10639" ); + assert.equal( el2.css( "marginLeft" ), "100px", "css('marginLeft') returning incorrect pixel value, see #12088" ); } ); -test( "jQuery.cssProps behavior, (bug #8402)", function() { - expect( 2 ); +QUnit.test( "jQuery.cssProps behavior, (bug #8402)", function( assert ) { + assert.expect( 2 ); var div = jQuery( "<div>" ).appendTo( document.body ).css( { "position": "absolute", @@ -786,49 +786,49 @@ test( "jQuery.cssProps behavior, (bug #8402)", function() { "left": 10 } ); jQuery.cssProps.top = "left"; - equal( div.css( "top" ), "10px", "the fixed property is used when accessing the computed style" ); + assert.equal( div.css( "top" ), "10px", "the fixed property is used when accessing the computed style" ); div.css( "top", "100px" ); - equal( div[ 0 ].style.left, "100px", "the fixed property is used when setting the style" ); + assert.equal( div[ 0 ].style.left, "100px", "the fixed property is used when setting the style" ); // cleanup jQuery.cssProps jQuery.cssProps.top = undefined; } ); -test( "widows & orphans #8936", function() { +QUnit.test( "widows & orphans #8936", function( assert ) { var $p = jQuery( "<p>" ).appendTo( "#qunit-fixture" ); if ( "widows" in $p[ 0 ].style ) { - expect( 2 ); + assert.expect( 2 ); $p.css( { "widows": 3, "orphans": 3 } ); - equal( $p.css( "widows" ) || jQuery.style( $p[ 0 ], "widows" ), 3, "widows correctly set to 3" ); - equal( $p.css( "orphans" ) || jQuery.style( $p[ 0 ], "orphans" ), 3, "orphans correctly set to 3" ); + assert.equal( $p.css( "widows" ) || jQuery.style( $p[ 0 ], "widows" ), 3, "widows correctly set to 3" ); + assert.equal( $p.css( "orphans" ) || jQuery.style( $p[ 0 ], "orphans" ), 3, "orphans correctly set to 3" ); } else { - expect( 1 ); - ok( true, "jQuery does not attempt to test for style props that definitely don't exist in older versions of IE" ); + assert.expect( 1 ); + assert.ok( true, "jQuery does not attempt to test for style props that definitely don't exist in older versions of IE" ); } $p.remove(); } ); -test( "can't get css for disconnected in IE<9, see #10254 and #8388", function() { - expect( 2 ); +QUnit.test( "can't get css for disconnected in IE<9, see #10254 and #8388", function( assert ) { + assert.expect( 2 ); var span, div; span = jQuery( "<span/>" ).css( "background-image", "url(data/1x1.jpg)" ); - notEqual( span.css( "background-image" ), null, "can't get background-image in IE<9, see #10254" ); + assert.notEqual( span.css( "background-image" ), null, "can't get background-image in IE<9, see #10254" ); div = jQuery( "<div/>" ).css( "top", 10 ); - equal( div.css( "top" ), "10px", "can't get top in IE<9, see #8388" ); + assert.equal( div.css( "top" ), "10px", "can't get top in IE<9, see #8388" ); } ); -test( "can't get background-position in IE<9, see #10796", function() { +QUnit.test( "can't get background-position in IE<9, see #10796", function( assert ) { var div = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ), units = [ "0 0", @@ -843,33 +843,33 @@ test( "can't get background-position in IE<9, see #10796", function() { l = units.length, i = 0; - expect( l ); + assert.expect( l ); for ( ; i < l; i++ ) { div.css( "background-position", units [ i ] ); - ok( div.css( "background-position" ), "can't get background-position in IE<9, see #10796" ); + assert.ok( div.css( "background-position" ), "can't get background-position in IE<9, see #10796" ); } } ); -test( "percentage properties for bottom and right in IE<9 should not be incorrectly transformed to pixels, see #11311", function() { - expect( 1 ); +QUnit.test( "percentage properties for bottom and right in IE<9 should not be incorrectly transformed to pixels, see #11311", function( assert ) { + assert.expect( 1 ); var div = jQuery( "<div style='position: absolute; width: 1px; height: 20px; bottom:50%;'></div>" ).appendTo( "#qunit-fixture" ); - ok( window.getComputedStyle || div.css( "bottom" ) === "50%", "position properties get incorrectly transformed in IE<8, see #11311" ); + assert.ok( window.getComputedStyle || div.css( "bottom" ) === "50%", "position properties get incorrectly transformed in IE<8, see #11311" ); } ); if ( jQuery.fn.offset ) { - test( "percentage properties for left and top should be transformed to pixels, see #9505", function() { - expect( 2 ); + QUnit.test( "percentage properties for left and top should be transformed to pixels, see #9505", function( assert ) { + assert.expect( 2 ); var parent = jQuery( "<div style='position:relative;width:200px;height:200px;margin:0;padding:0;border-width:0'></div>" ).appendTo( "#qunit-fixture" ), div = jQuery( "<div style='position: absolute; width: 20px; height: 20px; top:50%; left:50%'></div>" ).appendTo( parent ); - equal( div.css( "top" ), "100px", "position properties not transformed to pixels, see #9505" ); - equal( div.css( "left" ), "100px", "position properties not transformed to pixels, see #9505" ); + assert.equal( div.css( "top" ), "100px", "position properties not transformed to pixels, see #9505" ); + assert.equal( div.css( "left" ), "100px", "position properties not transformed to pixels, see #9505" ); } ); } -test( "Do not append px (#9548, #12990)", function() { - expect( 2 ); +QUnit.test( "Do not append px (#9548, #12990)", function( assert ) { + assert.expect( 2 ); var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ); @@ -877,37 +877,38 @@ test( "Do not append px (#9548, #12990)", function() { // Support: Android 2.3 (no support for fill-opacity) if ( $div.css( "fill-opacity" ) ) { - equal( $div.css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" ); + assert.equal( $div.css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" ); } else { - ok( true, "No support for fill-opacity CSS property" ); + assert.ok( true, "No support for fill-opacity CSS property" ); } $div.css( "column-count", 1 ); if ( $div.css( "column-count" ) ) { - equal( $div.css( "column-count" ), 1, "Do not append px to 'column-count'" ); + assert.equal( $div.css( "column-count" ), 1, "Do not append px to 'column-count'" ); } else { - ok( true, "No support for column-count CSS property" ); + assert.ok( true, "No support for column-count CSS property" ); } } ); -test( "css('width') and css('height') should respect box-sizing, see #11004", function() { - expect( 4 ); +QUnit.test( "css('width') and css('height') should respect box-sizing, see #11004", function( assert ) { + assert.expect( 4 ); // Support: Android 2.3 (-webkit-box-sizing). var el_dis = jQuery( "<div style='width:300px;height:300px;margin:2px;padding:2px;-webkit-box-sizing:border-box;box-sizing:border-box;'>test</div>" ), el = el_dis.clone().appendTo( "#qunit-fixture" ); - equal( el.css( "width" ), el.css( "width", el.css( "width" ) ).css( "width" ), "css('width') is not respecting box-sizing, see #11004" ); - equal( el_dis.css( "width" ), el_dis.css( "width", el_dis.css( "width" ) ).css( "width" ), "css('width') is not respecting box-sizing for disconnected element, see #11004" ); - equal( el.css( "height" ), el.css( "height", el.css( "height" ) ).css( "height" ), "css('height') is not respecting box-sizing, see #11004" ); - equal( el_dis.css( "height" ), el_dis.css( "height", el_dis.css( "height" ) ).css( "height" ), "css('height') is not respecting box-sizing for disconnected element, see #11004" ); + assert.equal( el.css( "width" ), el.css( "width", el.css( "width" ) ).css( "width" ), "css('width') is not respecting box-sizing, see #11004" ); + assert.equal( el_dis.css( "width" ), el_dis.css( "width", el_dis.css( "width" ) ).css( "width" ), "css('width') is not respecting box-sizing for disconnected element, see #11004" ); + assert.equal( el.css( "height" ), el.css( "height", el.css( "height" ) ).css( "height" ), "css('height') is not respecting box-sizing, see #11004" ); + assert.equal( el_dis.css( "height" ), el_dis.css( "height", el_dis.css( "height" ) ).css( "height" ), "css('height') is not respecting box-sizing for disconnected element, see #11004" ); } ); -testIframeWithCallback( "css('width') should work correctly before document ready (#14084)", +testIframeWithCallback( + "css('width') should work correctly before document ready (#14084)", "css/cssWidthBeforeDocReady.html", - function( cssWidthBeforeDocReady ) { - expect( 1 ); - strictEqual( cssWidthBeforeDocReady, "100px", "elem.css('width') works correctly before document ready" ); + function( cssWidthBeforeDocReady, assert ) { + assert.expect( 1 ); + assert.strictEqual( cssWidthBeforeDocReady, "100px", "elem.css('width') works correctly before document ready" ); } ); @@ -921,63 +922,63 @@ testIframeWithCallback( "css('width') should work correctly before document read div.getBoundingClientRect().width.toFixed( 1 ) === "3.3"; qunitFixture.removeChild( div ); - test( "css('width') and css('height') should return fractional values for nodes in the document", function() { + QUnit.test( "css('width') and css('height') should return fractional values for nodes in the document", function( assert ) { if ( !supportsFractionalGBCR ) { - expect( 1 ); - ok( true, "This browser doesn't support fractional values in getBoundingClientRect()" ); + assert.expect( 1 ); + assert.ok( true, "This browser doesn't support fractional values in getBoundingClientRect()" ); return; } - expect( 2 ); + assert.expect( 2 ); var el = jQuery( "<div class='test-div'></div>" ).appendTo( "#qunit-fixture" ); jQuery( "<style>.test-div { width: 33.3px; height: 88.8px; }</style>" ).appendTo( "#qunit-fixture" ); - equal( Number( el.css( "width" ).replace( /px$/, "" ) ).toFixed( 1 ), "33.3", + assert.equal( Number( el.css( "width" ).replace( /px$/, "" ) ).toFixed( 1 ), "33.3", "css('width') should return fractional values" ); - equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8", + assert.equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8", "css('height') should return fractional values" ); } ); - test( "css('width') and css('height') should return fractional values for disconnected nodes", function() { + QUnit.test( "css('width') and css('height') should return fractional values for disconnected nodes", function( assert ) { if ( !supportsFractionalGBCR ) { - expect( 1 ); - ok( true, "This browser doesn't support fractional values in getBoundingClientRect()" ); + assert.expect( 1 ); + assert.ok( true, "This browser doesn't support fractional values in getBoundingClientRect()" ); return; } - expect( 2 ); + assert.expect( 2 ); var el = jQuery( "<div style='width: 33.3px; height: 88.8px;'></div>" ); - equal( Number( el.css( "width" ).replace( /px$/, "" ) ).toFixed( 1 ), "33.3", + assert.equal( Number( el.css( "width" ).replace( /px$/, "" ) ).toFixed( 1 ), "33.3", "css('width') should return fractional values" ); - equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8", + assert.equal( Number( el.css( "height" ).replace( /px$/, "" ) ).toFixed( 1 ), "88.8", "css('height') should return fractional values" ); } ); } )(); -test( "certain css values of 'normal' should be convertable to a number, see #8627", function() { +QUnit.test( "certain css values of 'normal' should be convertable to a number, see #8627", function( assert ) { expect ( 3 ); var el = jQuery( "<div style='letter-spacing:normal;font-weight:normal;'>test</div>" ).appendTo( "#qunit-fixture" ); - ok( jQuery.isNumeric( parseFloat( el.css( "letterSpacing" ) ) ), "css('letterSpacing') not convertable to number, see #8627" ); - ok( jQuery.isNumeric( parseFloat( el.css( "fontWeight" ) ) ), "css('fontWeight') not convertable to number, see #8627" ); - equal( typeof el.css( "fontWeight" ), "string", ".css() returns a string" ); + assert.ok( jQuery.isNumeric( parseFloat( el.css( "letterSpacing" ) ) ), "css('letterSpacing') not convertable to number, see #8627" ); + assert.ok( jQuery.isNumeric( parseFloat( el.css( "fontWeight" ) ) ), "css('fontWeight') not convertable to number, see #8627" ); + assert.equal( typeof el.css( "fontWeight" ), "string", ".css() returns a string" ); } ); // only run this test in IE9 if ( document.documentMode === 9 ) { - test( ".css('filter') returns a string in IE9, see #12537", function() { - expect( 1 ); + QUnit.test( ".css('filter') returns a string in IE9, see #12537", function( assert ) { + assert.expect( 1 ); - equal( jQuery( "<div style='-ms-filter:\"progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFFFFF, endColorstr=#ECECEC)\";'></div>" ).css( "filter" ), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFFFFF, endColorstr=#ECECEC)", "IE9 returns the correct value from css('filter')." ); + assert.equal( jQuery( "<div style='-ms-filter:\"progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFFFFF, endColorstr=#ECECEC)\";'></div>" ).css( "filter" ), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFFFFF, endColorstr=#ECECEC)", "IE9 returns the correct value from css('filter')." ); } ); } -test( "cssHooks - expand", function() { - expect( 15 ); +QUnit.test( "cssHooks - expand", function( assert ) { + assert.expect( 15 ); var result, properties = { margin: [ "marginTop", "marginRight", "marginBottom", "marginLeft" ], @@ -992,32 +993,32 @@ test( "cssHooks - expand", function() { expected[ key ] = 10; } ); result = hook.expand( 10 ); - deepEqual( result, expected, property + " expands properly with a number" ); + assert.deepEqual( result, expected, property + " expands properly with a number" ); jQuery.each( keys, function( _, key ) { expected[ key ] = "10px"; } ); result = hook.expand( "10px" ); - deepEqual( result, expected, property + " expands properly with '10px'" ); + assert.deepEqual( result, expected, property + " expands properly with '10px'" ); expected[ keys[ 1 ] ] = expected[ keys[ 3 ] ] = "20px"; result = hook.expand( "10px 20px" ); - deepEqual( result, expected, property + " expands properly with '10px 20px'" ); + assert.deepEqual( result, expected, property + " expands properly with '10px 20px'" ); expected[ keys[ 2 ] ] = "30px"; result = hook.expand( "10px 20px 30px" ); - deepEqual( result, expected, property + " expands properly with '10px 20px 30px'" ); + assert.deepEqual( result, expected, property + " expands properly with '10px 20px 30px'" ); expected[ keys[ 3 ] ] = "40px"; result = hook.expand( "10px 20px 30px 40px" ); - deepEqual( result, expected, property + " expands properly with '10px 20px 30px 40px'" ); + assert.deepEqual( result, expected, property + " expands properly with '10px 20px 30px 40px'" ); } ); } ); -test( "css opacity consistency across browsers (#12685)", function() { - expect( 4 ); +QUnit.test( "css opacity consistency across browsers (#12685)", function( assert ) { + assert.expect( 4 ); var el, fixture = jQuery( "#qunit-fixture" ); @@ -1027,39 +1028,39 @@ test( "css opacity consistency across browsers (#12685)", function() { el = jQuery( "<div class='opacityWithSpaces_t12685'></div>" ).appendTo( fixture ); - equal( Math.round( el.css( "opacity" ) * 100 ), 10, "opacity from style sheet (-ms-filter:alpha with spaces)" ); + assert.equal( Math.round( el.css( "opacity" ) * 100 ), 10, "opacity from style sheet (-ms-filter:alpha with spaces)" ); el.removeClass( "opacityWithSpaces_t12685" ).addClass( "opacityNoSpaces_t12685" ); - equal( Math.round( el.css( "opacity" ) * 100 ), 20, "opacity from style sheet (-ms-filter:alpha without spaces)" ); + assert.equal( Math.round( el.css( "opacity" ) * 100 ), 20, "opacity from style sheet (-ms-filter:alpha without spaces)" ); el.css( "opacity", 0.3 ); - equal( Math.round( el.css( "opacity" ) * 100 ), 30, "override opacity" ); + assert.equal( Math.round( el.css( "opacity" ) * 100 ), 30, "override opacity" ); el.css( "opacity", "" ); - equal( Math.round( el.css( "opacity" ) * 100 ), 20, "remove opacity override" ); + assert.equal( Math.round( el.css( "opacity" ) * 100 ), 20, "remove opacity override" ); } ); -test( ":visible/:hidden selectors", function() { - expect( 17 ); +QUnit.test( ":visible/:hidden selectors", function( assert ) { + assert.expect( 17 ); var $div, $table, $a; - ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modifying CSS display: Assert element is visible" ); + assert.ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modifying CSS display: Assert element is visible" ); jQuery( "#nothiddendiv" ).css( { display: "none" } ); - ok( !jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is hidden" ); + assert.ok( !jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is hidden" ); jQuery( "#nothiddendiv" ).css( { "display": "block" } ); - ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is visible" ); - ok( !jQuery( window ).is( ":visible" ), "Calling is(':visible') on window does not throw an exception (#10267)." ); - ok( !jQuery( document ).is( ":visible" ), "Calling is(':visible') on document does not throw an exception (#10267)." ); + assert.ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is visible" ); + assert.ok( !jQuery( window ).is( ":visible" ), "Calling is(':visible') on window does not throw an exception (#10267)." ); + assert.ok( !jQuery( document ).is( ":visible" ), "Calling is(':visible') on document does not throw an exception (#10267)." ); - ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modifying CSS display: Assert element is visible" ); + assert.ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modifying CSS display: Assert element is visible" ); jQuery( "#nothiddendiv" ).css( "display", "none" ); - ok( !jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is hidden" ); + assert.ok( !jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is hidden" ); jQuery( "#nothiddendiv" ).css( "display", "block" ); - ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is visible" ); + assert.ok( jQuery( "#nothiddendiv" ).is( ":visible" ), "Modified CSS display: Assert element is visible" ); - ok( jQuery( "#siblingspan" ).is( ":visible" ), "Span with no content is visible" ); + assert.ok( jQuery( "#siblingspan" ).is( ":visible" ), "Span with no content is visible" ); $div = jQuery( "<div><span></span></div>" ).appendTo( "#qunit-fixture" ); - equal( $div.find( ":visible" ).length, 1, "Span with no content is visible" ); + assert.equal( $div.find( ":visible" ).length, 1, "Span with no content is visible" ); $div.css( { width: 0, height: 0, overflow: "hidden" } ); - ok( $div.is( ":visible" ), "Div with width and height of 0 is still visible (gh-2227)" ); + assert.ok( $div.is( ":visible" ), "Div with width and height of 0 is still visible (gh-2227)" ); // Safari 6-7 and iOS 6-7 report 0 width for br elements // When newer browsers propagate, re-enable this test @@ -1068,39 +1069,39 @@ test( ":visible/:hidden selectors", function() { $table = jQuery( "#table" ); $table.html( "<tr><td style='display:none'>cell</td><td>cell</td></tr>" ); - equal( jQuery( "#table td:visible" ).length, 1, "hidden cell is not perceived as visible (#4512). Works on table elements" ); + assert.equal( jQuery( "#table td:visible" ).length, 1, "hidden cell is not perceived as visible (#4512). Works on table elements" ); $table.css( "display", "none" ).html( "<tr><td>cell</td><td>cell</td></tr>" ); - equal( jQuery( "#table td:visible" ).length, 0, "hidden cell children not perceived as visible (#4512)" ); + assert.equal( jQuery( "#table td:visible" ).length, 0, "hidden cell children not perceived as visible (#4512)" ); t( "Is Visible", "#qunit-fixture div:visible:lt(2)", [ "foo", "nothiddendiv" ] ); t( "Is Not Hidden", "#qunit-fixture:hidden", [] ); t( "Is Hidden", "#form input:hidden", [ "hidden1","hidden2" ] ); $a = jQuery( "<a href='#'><h1>Header</h1></a>" ).appendTo( "#qunit-fixture" ); - ok( $a.is( ":visible" ), "Anchor tag with flow content is visible (gh-2227)" ); + assert.ok( $a.is( ":visible" ), "Anchor tag with flow content is visible (gh-2227)" ); } ); -test( "Keep the last style if the new one isn't recognized by the browser (#14836)", function() { - expect( 2 ); +QUnit.test( "Keep the last style if the new one isn't recognized by the browser (#14836)", function( assert ) { + assert.expect( 2 ); var el; el = jQuery( "<div></div>" ).css( "position", "absolute" ).css( "position", "fake value" ); - equal( el.css( "position" ), "absolute", "The old style is kept when setting an unrecognized value" ); + assert.equal( el.css( "position" ), "absolute", "The old style is kept when setting an unrecognized value" ); el = jQuery( "<div></div>" ).css( "position", "absolute" ).css( "position", " " ); - equal( el.css( "position" ), "absolute", "The old style is kept when setting to a space" ); + assert.equal( el.css( "position" ), "absolute", "The old style is kept when setting to a space" ); } ); -test( "Reset the style if set to an empty string", function() { - expect( 1 ); +QUnit.test( "Reset the style if set to an empty string", function( assert ) { + assert.expect( 1 ); var el = jQuery( "<div></div>" ).css( "position", "absolute" ).css( "position", "" ); // Some browsers return an empty string; others "static". Both those cases mean the style // was reset successfully so accept them both. - equal( el.css( "position" ) || "static", "static", + assert.equal( el.css( "position" ) || "static", "static", "The style can be reset by setting to an empty string" ); } ); -asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)", 24, function() { +QUnit.asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)", 24, function( assert ) { var baseUrl = document.location.href.replace( /([^\/]*)$/, "" ), styles = [ { name: "backgroundAttachment", @@ -1149,9 +1150,9 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme style.expected = style.expected.concat( [ "", "auto" ] ); if ( source.style[ style.name ] === undefined ) { - ok( true, style.name + ": style isn't supported and therefore not an issue" ); - ok( true ); - ok( true ); + assert.ok( true, style.name + ": style isn't supported and therefore not an issue" ); + assert.ok( true ); + assert.ok( true ); return true; } @@ -1165,14 +1166,14 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme $clonedChildren.css( style.name, "" ); window.setTimeout( function() { - notEqual( $clone.css( style.name ), style.value[ 0 ], "Cloned css was changed" ); + assert.notEqual( $clone.css( style.name ), style.value[ 0 ], "Cloned css was changed" ); - ok( jQuery.inArray( $source.css( style.name ) !== -1, style.value ), + assert.ok( jQuery.inArray( $source.css( style.name ) !== -1, style.value ), "Clearing clone.css() doesn't affect source.css(): " + style.name + "; result: " + $source.css( style.name ) + "; expected: " + style.value.join( "," ) ); - ok( jQuery.inArray( $children.css( style.name ) !== -1, style.value ), + assert.ok( jQuery.inArray( $children.css( style.name ) !== -1, style.value ), "Clearing clonedChildren.css() doesn't affect children.css(): " + style.name + "; result: " + $children.css( style.name ) + "; expected: " + style.value.join( "," ) ); @@ -1182,8 +1183,8 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme window.setTimeout( start, 1000 ); } ); -test( "show() after hide() should always set display to initial value (#14750)", function() { - expect( 1 ); +QUnit.test( "show() after hide() should always set display to initial value (#14750)", function( assert ) { + assert.expect( 1 ); var div = jQuery( "<div />" ), fixture = jQuery( "#qunit-fixture" ); @@ -1191,7 +1192,7 @@ test( "show() after hide() should always set display to initial value (#14750)", fixture.append( div ); div.css( "display", "inline" ).hide().show().css( "display", "list-item" ).hide().show(); - equal( div.css( "display" ), "list-item", "should get last set display value" ); + assert.equal( div.css( "display" ), "list-item", "should get last set display value" ); } ); // Support: IE < 11 @@ -1203,19 +1204,19 @@ test( "show() after hide() should always set display to initial value (#14750)", exist = "order" in style || "WebkitOrder" in style; if ( exist ) { - test( "Don't append px to CSS \"order\" value (#14049)", function() { - expect( 1 ); + QUnit.test( "Don't append px to CSS \"order\" value (#14049)", function( assert ) { + assert.expect( 1 ); var $elem = jQuery( "<div/>" ); $elem.css( "order", 2 ); - equal( $elem.css( "order" ), "2", "2 on order" ); + assert.equal( $elem.css( "order" ), "2", "2 on order" ); } ); } } )(); -test( "Do not throw on frame elements from css method (#15098)", function() { - expect( 1 ); +QUnit.test( "Do not throw on frame elements from css method (#15098)", function( assert ) { + assert.expect( 1 ); var frameWin, frameDoc, frameElement = document.createElement( "iframe" ), @@ -1233,14 +1234,14 @@ test( "Do not throw on frame elements from css method (#15098)", function() { try { jQuery( frameDoc.body ).css( "direction" ); - ok( true, "It didn't throw" ); + assert.ok( true, "It didn't throw" ); } catch ( _ ) { - ok( false, "It did throw" ); + assert.ok( false, "It did throw" ); } } ); -test( "get upper case alpha opacity in IE8", function() { - expect( 1 ); +QUnit.test( "get upper case alpha opacity in IE8", function( assert ) { + assert.expect( 1 ); var div = document.createElement( "div" ), fixture = document.getElementById( "qunit-fixture" ); @@ -1248,7 +1249,7 @@ test( "get upper case alpha opacity in IE8", function() { div.className = "fix-get-alpha-opacity-in-ie8"; fixture.appendChild( div ); - equal( jQuery( div ).css( "opacity" ), "0.5", "get upper case alpha opacity in IE8 ok" ); + assert.equal( jQuery( div ).css( "opacity" ), "0.5", "get upper case alpha opacity in IE8 ok" ); fixture.removeChild( div ); } ); @@ -1263,7 +1264,7 @@ test( "get upper case alpha opacity in IE8", function() { } ); } - test( "Don't default to a cached previously used wrong prefixed name (gh-2015)", function() { + QUnit.test( "Don't default to a cached previously used wrong prefixed name (gh-2015)", function( assert ) { // Note: this test needs a property we know is only supported in a prefixed version // by at least one of our main supported browsers. This may get out of date so let's @@ -1294,7 +1295,7 @@ test( "get upper case alpha opacity in IE8", function() { } ); } - expect( !!appearanceName + !!transformName + 1 ); + assert.expect( !!appearanceName + !!transformName + 1 ); resetCssPropsFor( "appearance" ); resetCssPropsFor( "transform" ); @@ -1312,23 +1313,23 @@ test( "get upper case alpha opacity in IE8", function() { elemStyle = elem[ 0 ].style; if ( appearanceName ) { - equal( elemStyle[ appearanceName ], "none", "setting properly-prefixed appearance" ); + assert.equal( elemStyle[ appearanceName ], "none", "setting properly-prefixed appearance" ); } if ( transformName ) { - equal( elemStyle[ transformName ], transformVal, "setting properly-prefixed transform" ); + assert.equal( elemStyle[ transformName ], transformVal, "setting properly-prefixed transform" ); } - equal( elemStyle[ "undefined" ], undefined, "Nothing writes to node.style.undefined" ); + assert.equal( elemStyle[ "undefined" ], undefined, "Nothing writes to node.style.undefined" ); } ); - test( "Don't detect fake set properties on a node when caching the prefixed version", function() { - expect( 1 ); + QUnit.test( "Don't detect fake set properties on a node when caching the prefixed version", function( assert ) { + assert.expect( 1 ); var elem = jQuery( "<div/>" ), style = elem[ 0 ].style; style.MozFakeProperty = "old value"; elem.css( "fakeProperty", "new value" ); - equal( style.MozFakeProperty, "old value", "Fake prefixed property is not cached" ); + assert.equal( style.MozFakeProperty, "old value", "Fake prefixed property is not cached" ); } ); } )(); diff --git a/test/unit/data.js b/test/unit/data.js index cf98a816c..ae4596225 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -1,81 +1,151 @@ -module( "data", { teardown: moduleTeardown } ); +QUnit.module( "data", { teardown: moduleTeardown } ); -test( "expando", function() { - expect( 1 ); +QUnit.test( "expando", function( assert ) { + assert.expect( 1 ); - equal( jQuery.expando !== undefined, true, "jQuery is exposing the expando" ); + assert.equal( + jQuery.expando !== undefined, true, "jQuery is exposing the expando" + ); } ); -function dataTests( elem ) { +function dataTests( elem, assert ) { var dataObj, internalDataObj; - equal( jQuery.data( elem, "foo" ), undefined, "No data exists initially" ); - strictEqual( jQuery.hasData( elem ), false, "jQuery.hasData agrees no data exists initially" ); + assert.equal( + jQuery.data( elem, "foo" ), undefined, "No data exists initially" + ); + assert.strictEqual( + jQuery.hasData( elem ), false, "jQuery.hasData agrees no data exists initially" + ); dataObj = jQuery.data( elem ); - equal( typeof dataObj, "object", "Calling data with no args gives us a data object reference" ); - strictEqual( jQuery.data( elem ), dataObj, "Calling jQuery.data returns the same data object when called multiple times" ); - - strictEqual( jQuery.hasData( elem ), false, "jQuery.hasData agrees no data exists even when an empty data obj exists" ); + assert.equal( + typeof dataObj, "object", "Calling data with no args gives us a data object reference" + ); + assert.strictEqual( + jQuery.data( elem ), dataObj, + "Calling jQuery.data returns the same data object when called multiple times" + ); + + assert.strictEqual( + jQuery.hasData( elem ), false, + "jQuery.hasData agrees no data exists even when an empty data obj exists" + ); dataObj[ "foo" ] = "bar"; - equal( jQuery.data( elem, "foo" ), "bar", "Data is readable by jQuery.data when set directly on a returned data object" ); + assert.equal( + jQuery.data( elem, "foo" ), + "bar", + "Data is readable by jQuery.data when set directly on a returned data object" + ); - strictEqual( jQuery.hasData( elem ), true, "jQuery.hasData agrees data exists when data exists" ); + assert.strictEqual( + jQuery.hasData( elem ), true, "jQuery.hasData agrees data exists when data exists" + ); jQuery.data( elem, "foo", "baz" ); - equal( jQuery.data( elem, "foo" ), "baz", "Data can be changed by jQuery.data" ); - equal( dataObj[ "foo" ], "baz", "Changes made through jQuery.data propagate to referenced data object" ); + assert.equal( + jQuery.data( elem, "foo" ), "baz", "Data can be changed by jQuery.data" + ); + assert.equal( + dataObj[ "foo" ], + "baz", + "Changes made through jQuery.data propagate to referenced data object" + ); jQuery.data( elem, "foo", undefined ); - equal( jQuery.data( elem, "foo" ), "baz", "Data is not unset by passing undefined to jQuery.data" ); + assert.equal( + jQuery.data( elem, "foo" ), "baz", "Data is not unset by passing undefined to jQuery.data" + ); jQuery.data( elem, "foo", null ); - strictEqual( jQuery.data( elem, "foo" ), null, "Setting null using jQuery.data works OK" ); + assert.strictEqual( + jQuery.data( elem, "foo" ), null, "Setting null using jQuery.data works OK" + ); jQuery.data( elem, "foo", "foo1" ); jQuery.data( elem, { "bar": "baz", "boom": "bloz" } ); - strictEqual( jQuery.data( elem, "foo" ), "foo1", "Passing an object extends the data object instead of replacing it" ); - equal( jQuery.data( elem, "boom" ), "bloz", "Extending the data object works" ); + assert.strictEqual( + jQuery.data( elem, "foo" ), + "foo1", + "Passing an object extends the data object instead of replacing it" + ); + assert.equal( + jQuery.data( elem, "boom" ), "bloz", "Extending the data object works" + ); jQuery._data( elem, "foo", "foo2", true ); - equal( jQuery._data( elem, "foo" ), "foo2", "Setting internal data works" ); - equal( jQuery.data( elem, "foo" ), "foo1", "Setting internal data does not override user data" ); + assert.equal( + jQuery._data( elem, "foo" ), "foo2", "Setting internal data works" + ); + assert.equal( + jQuery.data( elem, "foo" ), "foo1", "Setting internal data does not override user data" + ); internalDataObj = jQuery._data( elem ); - ok( internalDataObj, "Internal data object exists" ); - notStrictEqual( dataObj, internalDataObj, "Internal data object is not the same as user data object" ); + assert.ok( + internalDataObj, "Internal data object exists" + ); + assert.notStrictEqual( + dataObj, internalDataObj, "Internal data object is not the same as user data object" + ); - strictEqual( elem.boom, undefined, "Data is never stored directly on the object" ); + assert.strictEqual( + elem.boom, undefined, "Data is never stored directly on the object" + ); jQuery.removeData( elem, "foo" ); - strictEqual( jQuery.data( elem, "foo" ), undefined, "jQuery.removeData removes single properties" ); + assert.strictEqual( + jQuery.data( elem, "foo" ), undefined, "jQuery.removeData removes single properties" + ); jQuery.removeData( elem ); - strictEqual( jQuery._data( elem ), internalDataObj, "jQuery.removeData does not remove internal data if it exists" ); + assert.strictEqual( + jQuery._data( elem ), + internalDataObj, + "jQuery.removeData does not remove internal data if it exists" + ); jQuery.data( elem, "foo", "foo1" ); jQuery._data( elem, "foo", "foo2" ); - equal( jQuery.data( elem, "foo" ), "foo1", "(sanity check) Ensure data is set in user data object" ); - equal( jQuery._data( elem, "foo" ), "foo2", "(sanity check) Ensure data is set in internal data object" ); - - strictEqual( jQuery._data( elem, jQuery.expando ), undefined, "Removing the last item in internal data destroys the internal data object" ); + assert.equal( + jQuery.data( elem, "foo" ), "foo1", "(sanity check) Ensure data is set in user data object" + ); + assert.equal( + jQuery._data( elem, "foo" ), + "foo2", + "(sanity check) Ensure data is set in internal data object" + ); + + assert.strictEqual( + jQuery._data( elem, jQuery.expando ), + undefined, + "Removing the last item in internal data destroys the internal data object" + ); jQuery._data( elem, "foo", "foo2" ); - equal( jQuery._data( elem, "foo" ), "foo2", "(sanity check) Ensure data is set in internal data object" ); + assert.equal( + jQuery._data( elem, "foo" ), + "foo2", + "(sanity check) Ensure data is set in internal data object" + ); jQuery.removeData( elem, "foo" ); - equal( jQuery._data( elem, "foo" ), "foo2", "(sanity check) jQuery.removeData for user data does not remove internal data" ); + assert.equal( + jQuery._data( elem, "foo" ), + "foo2", + "(sanity check) jQuery.removeData for user data does not remove internal data" + ); } -test( "jQuery.data(div)", function() { - expect( 25 ); +QUnit.test( "jQuery.data(div)", function( assert ) { + assert.expect( 25 ); var div = document.createElement( "div" ); - dataTests( div ); + dataTests( div, assert ); // We stored one key in the private data // assert that nothing else was put in there, and that that @@ -83,37 +153,40 @@ test( "jQuery.data(div)", function() { QUnit.expectJqData( this, div, "foo" ); } ); -test( "jQuery.data({})", function() { - expect( 25 ); +QUnit.test( "jQuery.data({})", function( assert ) { + assert.expect( 25 ); - dataTests( {} ); + dataTests( {}, assert ); } ); -test( "jQuery.data(window)", function() { - expect( 25 ); +QUnit.test( "jQuery.data(window)", function( assert ) { + assert.expect( 25 ); - // remove bound handlers from window object to stop potential false positives caused by fix for #5280 in + // Remove bound handlers from window object to stop + // potential false positives caused by fix for #5280 in // transports/xhr.js jQuery( window ).off( "unload" ); - dataTests( window ); + dataTests( window, assert ); } ); -test( "jQuery.data(document)", function() { - expect( 25 ); +QUnit.test( "jQuery.data(document)", function( assert ) { + assert.expect( 25 ); - dataTests( document ); + dataTests( document, assert ); QUnit.expectJqData( this, document, "foo" ); } ); -test( "Expando cleanup", function() { - expect( 4 ); +QUnit.test( "Expando cleanup", function( assert ) { + assert.expect( 4 ); var div = document.createElement( "div" ); function assertExpandoAbsent( message ) { - strictEqual( div[ jQuery.expando ], undefined, message ); + assert.strictEqual( + div[ jQuery.expando ], undefined, message + ); } assertExpandoAbsent( "There is no expando on new elements" ); @@ -121,11 +194,15 @@ test( "Expando cleanup", function() { jQuery.data( div, "foo", 100 ); jQuery.data( div, "bar", 200 ); - ok( jQuery.expando in div, "There is an expando on the element after using $.data()" ); + assert.ok( + jQuery.expando in div, "There is an expando on the element after using $.data()" + ); jQuery.removeData( div, "foo" ); - ok( jQuery.expando in div, "There is still an expando on the element after removing (some) of the data" ); + assert.ok( + jQuery.expando in div, "There is still an expando on the element after removing (some) of the data" + ); jQuery.removeData( div, "bar" ); @@ -135,75 +212,114 @@ test( "Expando cleanup", function() { jQuery( div ).remove(); } ); -test( "Data is not being set on comment and text nodes", function() { - expect( 2 ); +QUnit.test( "Data is not being set on comment and text nodes", function( assert ) { + assert.expect( 2 ); - ok( !jQuery.hasData( jQuery( "<!-- comment -->" ).data( "foo", 0 ) ) ); - ok( !jQuery.hasData( jQuery( "<span>text</span>" ).contents().data( "foo", 0 ) ) ); + assert.ok( + !jQuery.hasData( jQuery( "<!-- comment -->" ).data( "foo", 0 ) ) + ); + assert.ok( + !jQuery.hasData( jQuery( "<span>text</span>" ).contents().data( "foo", 0 ) ) + ); } ); -test( "jQuery.acceptData", function() { - expect( 10 ); +QUnit.test( "jQuery.acceptData", function( assert ) { + assert.expect( 10 ); var flash, pdf; - ok( jQuery.acceptData( document ), "document" ); - ok( jQuery.acceptData( document.documentElement ), "documentElement" ); - ok( jQuery.acceptData( {} ), "object" ); - ok( !jQuery.acceptData( document.createElement( "embed" ) ), "embed" ); + assert.ok( + jQuery.acceptData( document ), "document" + ); + assert.ok( + jQuery.acceptData( document.documentElement ), "documentElement" + ); + assert.ok( + jQuery.acceptData( {} ), "object" + ); + assert.ok( + !jQuery.acceptData( document.createElement( "embed" ) ), "embed" + ); flash = document.createElement( "object" ); flash.setAttribute( "classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ); - ok( jQuery.acceptData( flash ), "flash" ); + assert.ok( + jQuery.acceptData( flash ), "flash" + ); pdf = document.createElement( "object" ); pdf.setAttribute( "classid", "clsid:CA8A9780-280D-11CF-A24D-444553540000" ); - ok( !jQuery.acceptData( pdf ), "pdf" ); - - ok( !jQuery.acceptData( document.createComment( "" ) ), "comment" ); - ok( !jQuery.acceptData( document.createTextNode( "" ) ), "text" ); - ok( !jQuery.acceptData( document.createDocumentFragment() ), "documentFragment" ); - - ok( jQuery.acceptData( - jQuery( "#form" ).append( "<input id='nodeType'/><input id='nodeName'/>" )[ 0 ] ), - "form with aliased DOM properties" ); + assert.ok( + !jQuery.acceptData( pdf ), "pdf" + ); + + assert.ok( + !jQuery.acceptData( document.createComment( "" ) ), "comment" + ); + assert.ok( + !jQuery.acceptData( document.createTextNode( "" ) ), "text" + ); + assert.ok( + !jQuery.acceptData( document.createDocumentFragment() ), "documentFragment" + ); + + assert.ok( + jQuery.acceptData( + jQuery( "#form" ).append( "<input id='nodeType'/><input id='nodeName'/>" )[ 0 ] + ), + "form with aliased DOM properties" + ); } ); // attempting to access the data of an undefined jQuery element should be undefined -test( "jQuery().data() === undefined (#14101)", function() { - expect( 2 ); - - strictEqual( jQuery().data(), undefined ); - strictEqual( jQuery().data( "key" ), undefined ); +QUnit.test( "jQuery().data() === undefined (#14101)", function( assert ) { + assert.expect( 2 ); + + assert.strictEqual( + jQuery().data(), undefined + ); + assert.strictEqual( + jQuery().data( "key" ), undefined + ); } ); -test( ".data()", function() { - expect( 5 ); +QUnit.test( ".data()", function( assert ) { + assert.expect( 5 ); var div, dataObj, nodiv, obj; div = jQuery( "#foo" ); - strictEqual( div.data( "foo" ), undefined, "Make sure that missing result is undefined" ); + assert.strictEqual( + div.data( "foo" ), undefined, "Make sure that missing result is undefined" + ); div.data( "test", "success" ); dataObj = div.data(); - deepEqual( dataObj, { test: "success" }, "data() returns entire data object with expected properties" ); - strictEqual( div.data( "foo" ), undefined, "Make sure that missing result is still undefined" ); + assert.deepEqual( + dataObj, { test: "success" }, "data() returns entire data object with expected properties" + ); + assert.strictEqual( + div.data( "foo" ), undefined, "Make sure that missing result is still undefined" + ); nodiv = jQuery( "#unfound" ); - equal( nodiv.data(), null, "data() on empty set returns null" ); + assert.equal( + nodiv.data(), null, "data() on empty set returns null" + ); obj = { foo: "bar" }; jQuery( obj ).data( "foo", "baz" ); dataObj = jQuery.extend( true, {}, jQuery( obj ).data() ); - deepEqual( dataObj, { "foo": "baz" }, "Retrieve data object from a wrapped JS object (#7524)" ); + assert.deepEqual( + dataObj, { "foo": "baz" }, "Retrieve data object from a wrapped JS object (#7524)" + ); } ); -function testDataTypes( $obj ) { +function testDataTypes( $obj, assert ) { jQuery.each( { "null": null, "true": true, @@ -219,71 +335,115 @@ function testDataTypes( $obj ) { "regex": /test/, "function": function() {} }, function( type, value ) { - strictEqual( $obj.data( "test", value ).data( "test" ), value, "Data set to " + type ); + assert.strictEqual( + $obj.data( "test", value ).data( "test" ), value, "Data set to " + type + ); } ); } -test( "jQuery(Element).data(String, Object).data(String)", function() { - expect( 18 ); +QUnit.test( "jQuery(Element).data(String, Object).data(String)", function( assert ) { + assert.expect( 18 ); var parent = jQuery( "<div><div></div></div>" ), div = parent.children(); - strictEqual( div.data( "test" ), undefined, "No data exists initially" ); - strictEqual( div.data( "test", "success" ).data( "test" ), "success", "Data added" ); - strictEqual( div.data( "test", "overwritten" ).data( "test" ), "overwritten", "Data overwritten" ); - strictEqual( div.data( "test", undefined ).data( "test" ), "overwritten", ".data(key,undefined) does nothing but is chainable (#5571)" ); - strictEqual( div.data( "notexist" ), undefined, "No data exists for unset key" ); - testDataTypes( div ); + assert.strictEqual( + div.data( "test" ), undefined, "No data exists initially" + ); + assert.strictEqual( + div.data( "test", "success" ).data( "test" ), "success", "Data added" + ); + assert.strictEqual( + div.data( "test", "overwritten" ).data( "test" ), "overwritten", "Data overwritten" + ); + assert.strictEqual( + div.data( "test", undefined ).data( "test" ), + "overwritten", + ".data(key,undefined) does nothing but is chainable (#5571)" + ); + assert.strictEqual( + div.data( "notexist" ), undefined, "No data exists for unset key" + ); + testDataTypes( div, assert ); parent.remove(); } ); -test( "jQuery(plain Object).data(String, Object).data(String)", function() { - expect( 16 ); +QUnit.test( "jQuery(plain Object).data(String, Object).data(String)", function( assert ) { + assert.expect( 16 ); // #3748 var $obj = jQuery( { exists: true } ); - strictEqual( $obj.data( "nothing" ), undefined, "Non-existent data returns undefined" ); - strictEqual( $obj.data( "exists" ), undefined, "Object properties are not returned as data" ); - testDataTypes( $obj ); + assert.strictEqual( + $obj.data( "nothing" ), undefined, "Non-existent data returns undefined" + ); + assert.strictEqual( + $obj.data( "exists" ), undefined, "Object properties are not returned as data" + ); + testDataTypes( $obj, assert ); // Clean up $obj.removeData(); - deepEqual( $obj[ 0 ], { exists: true }, "removeData does not clear the object" ); + assert.deepEqual( + $obj[ 0 ], { exists: true }, "removeData does not clear the object" + ); } ); -test( "data-* attributes", function() { - expect( 46 ); +QUnit.test( "data-* attributes", function( assert ) { + assert.expect( 46 ); var prop, i, l, metadata, elem, obj, obj2, check, num, num2, parseJSON = jQuery.parseJSON, div = jQuery( "<div>" ), - child = jQuery( "<div data-myobj='old data' data-ignored=\"DOM\" data-other='test' data-foo-42='boosh'></div>" ), - dummy = jQuery( "<div data-myobj='old data' data-ignored=\"DOM\" data-other='test' data-foo-42='boosh'></div>" ); - - equal( div.data( "attr" ), undefined, "Check for non-existing data-attr attribute" ); + child = jQuery( + "<div data-myobj='old data' data-ignored=\"DOM\"" + + " data-other='test' data-foo-42='boosh'></div>" + ), + dummy = jQuery( + "<div data-myobj='old data' data-ignored=\"DOM\"" + + " data-other='test' data-foo-42='boosh'></div>" + ); + + assert.equal( + div.data( "attr" ), undefined, "Check for non-existing data-attr attribute" + ); div.attr( "data-attr", "exists" ); - equal( div.data( "attr" ), "exists", "Check for existing data-attr attribute" ); + assert.equal( + div.data( "attr" ), "exists", "Check for existing data-attr attribute" + ); div.attr( "data-attr", "exists2" ); - equal( div.data( "attr" ), "exists", "Check that updates to data- don't update .data()" ); + assert.equal( + div.data( "attr" ), "exists", "Check that updates to data- don't update .data()" + ); div.data( "attr", "internal" ).attr( "data-attr", "external" ); - equal( div.data( "attr" ), "internal", "Check for .data('attr') precedence (internal > external data-* attribute)" ); + assert.equal( + div.data( "attr" ), + "internal", + "Check for .data('attr') precedence (internal > external data-* attribute)" + ); div.remove(); child.appendTo( "#qunit-fixture" ); - equal( child.data( "myobj" ), "old data", "Value accessed from data-* attribute" ); - equal( child.data( "foo-42" ), "boosh", "camelCasing does not affect numbers (#1751)" ); + assert.equal( + child.data( "myobj" ), "old data", "Value accessed from data-* attribute" + ); + assert.equal( + child.data( "foo-42" ), "boosh", "camelCasing does not affect numbers (#1751)" + ); child.data( "myobj", "replaced" ); - equal( child.data( "myobj" ), "replaced", "Original data overwritten" ); + assert.equal( + child.data( "myobj" ), "replaced", "Original data overwritten" + ); child.data( "ignored", "cache" ); - equal( child.data( "ignored" ), "cache", "Cached data used before DOM data-* fallback" ); + assert.equal( + child.data( "ignored" ), "cache", "Cached data used before DOM data-* fallback" + ); obj = child.data(); obj2 = dummy.data(); @@ -294,25 +454,35 @@ test( "data-* attributes", function() { dummy.remove(); for ( i = 0, l = check.length; i < l; i++ ) { - ok( obj[ check[ i ] ], "Make sure data- property exists when calling data-." ); - ok( obj2[ check[ i ] ], "Make sure data- property exists when calling data-." ); + assert.ok( + obj[ check[ i ] ], "Make sure data- property exists when calling data-." + ); + assert.ok( + obj2[ check[ i ] ], "Make sure data- property exists when calling data-." + ); } for ( prop in obj ) { num++; } - equal( num, check.length, "Make sure that the right number of properties came through." ); + assert.equal( + num, check.length, "Make sure that the right number of properties came through." + ); for ( prop in obj2 ) { num2++; } - equal( num2, check.length, "Make sure that the right number of properties came through." ); + assert.equal( + num2, check.length, "Make sure that the right number of properties came through." + ); child.attr( "data-other", "newvalue" ); - equal( child.data( "other" ), "test", "Make sure value was pulled in properly from a .data()." ); + assert.equal( + child.data( "other" ), "test", "Make sure value was pulled in properly from a .data()." + ); // attribute parsing i = 0; @@ -341,33 +511,63 @@ test( "data-* attributes", function() { .attr( "data-null", "null" ) .attr( "data-string", "test" ); - strictEqual( child.data( "true" ), true, "Primitive true read from attribute" ); - strictEqual( child.data( "false" ), false, "Primitive false read from attribute" ); - strictEqual( child.data( "five" ), 5, "Integer read from attribute" ); - strictEqual( child.data( "point" ), 5.5, "Floating-point number read from attribute" ); - strictEqual( child.data( "pointe" ), "5.5E3", + assert.strictEqual( + child.data( "true" ), true, "Primitive true read from attribute" + ); + assert.strictEqual( + child.data( "false" ), false, "Primitive false read from attribute" + ); + assert.strictEqual( + child.data( "five" ), 5, "Integer read from attribute" + ); + assert.strictEqual( + child.data( "point" ), 5.5, "Floating-point number read from attribute" + ); + assert.strictEqual( + child.data( "pointe" ), "5.5E3", "Exponential-notation number read from attribute as string" ); - strictEqual( child.data( "grande" ), "5.574E9", + assert.strictEqual( + child.data( "grande" ), "5.574E9", "Big exponential-notation number read from attribute as string" ); - strictEqual( child.data( "hexadecimal" ), "0x42", + assert.strictEqual( + child.data( "hexadecimal" ), "0x42", "Hexadecimal number read from attribute as string" ); - strictEqual( child.data( "pointbad" ), "5..5", + assert.strictEqual( + child.data( "pointbad" ), "5..5", "Extra-point non-number read from attribute as string" ); - strictEqual( child.data( "pointbad2" ), "-.", + assert.strictEqual( + child.data( "pointbad2" ), "-.", "No-digit non-number read from attribute as string" ); - strictEqual( child.data( "bigassnum" ), "123456789123456789123456789", + assert.strictEqual( + child.data( "bigassnum" ), "123456789123456789123456789", "Bad bigass number read from attribute as string" ); - strictEqual( child.data( "badjson" ), "{123}", "Bad JSON object read from attribute as string" ); - strictEqual( child.data( "badjson2" ), "[abc]", "Bad JSON array read from attribute as string" ); - strictEqual( child.data( "notjson" ), " {}", + assert.strictEqual( + child.data( "badjson" ), "{123}", "Bad JSON object read from attribute as string" + ); + assert.strictEqual( + child.data( "badjson2" ), "[abc]", "Bad JSON array read from attribute as string" + ); + assert.strictEqual( + child.data( "notjson" ), " {}", "JSON object with leading non-JSON read from attribute as string" ); - strictEqual( child.data( "notjson2" ), "[] ", - "JSON array with trailing non-JSON read from attribute as string" ); - strictEqual( child.data( "empty" ), "", "Empty string read from attribute" ); - strictEqual( child.data( "space" ), " ", "Whitespace string read from attribute" ); - strictEqual( child.data( "null" ), null, "Primitive null read from attribute" ); - strictEqual( child.data( "string" ), "test", "Typical string read from attribute" ); - equal( i, 2, "Correct number of JSON parse attempts when reading from attributes" ); + assert.strictEqual( + child.data("notjson2"), "[] ", + "JSON array with trailing non-JSON read from attribute as string"); + assert.strictEqual( + child.data( "empty" ), "", "Empty string read from attribute" + ); + assert.strictEqual( + child.data( "space" ), " ", "Whitespace string read from attribute" + ); + assert.strictEqual( + child.data( "null" ), null, "Primitive null read from attribute" + ); + assert.strictEqual( + child.data( "string" ), "test", "Typical string read from attribute" + ); + assert.equal( + i, 2, "Correct number of JSON parse attempts when reading from attributes" + ); jQuery.parseJSON = parseJSON; child.remove(); @@ -376,23 +576,41 @@ test( "data-* attributes", function() { function testData( index, elem ) { switch ( index ) { case 0: - equal( jQuery( elem ).data( "foo" ), "bar", "Check foo property" ); - equal( jQuery( elem ).data( "bar" ), "baz", "Check baz property" ); + assert.equal( + jQuery( elem ).data( "foo" ), "bar", "Check foo property" + ); + assert.equal( + jQuery( elem ).data( "bar" ), "baz", "Check baz property" + ); break; case 1: - equal( jQuery( elem ).data( "test" ), "bar", "Check test property" ); - equal( jQuery( elem ).data( "bar" ), "baz", "Check bar property" ); + assert.equal( + jQuery( elem ).data( "test" ), "bar", "Check test property" + ); + assert.equal( + jQuery( elem ).data( "bar" ), "baz", "Check bar property" + ); break; case 2: - equal( jQuery( elem ).data( "zoooo" ), "bar", "Check zoooo property" ); - deepEqual( jQuery( elem ).data( "bar" ), { "test":"baz" }, "Check bar property" ); + assert.equal( + jQuery( elem ).data( "zoooo" ), "bar", "Check zoooo property" + ); + assert.deepEqual( + jQuery( elem ).data( "bar" ), { "test":"baz" }, "Check bar property" + ); break; case 3: - equal( jQuery( elem ).data( "number" ), true, "Check number property" ); - deepEqual( jQuery( elem ).data( "stuff" ), [ 2,8 ], "Check stuff property" ); + assert.equal( + jQuery( elem ).data( "number" ), true, "Check number property" + ); + assert.deepEqual( + jQuery( elem ).data( "stuff" ), [ 2,8 ], "Check stuff property" + ); break; default: - ok( false, [ "Assertion failed on index ", index, ", with data" ].join( "" ) ); + assert.ok( + false, [ "Assertion failed on index ", index, ", with data" ].join( "" ) + ); } } @@ -403,135 +621,197 @@ test( "data-* attributes", function() { elem.remove(); } ); -test( ".data(Object)", function() { - expect( 4 ); +QUnit.test( ".data(Object)", function( assert ) { + assert.expect( 4 ); var obj, jqobj, div = jQuery( "<div/>" ); div.data( { "test": "in", "test2": "in2" } ); - equal( div.data( "test" ), "in", "Verify setting an object in data" ); - equal( div.data( "test2" ), "in2", "Verify setting an object in data" ); + assert.equal( + div.data( "test" ), "in", "Verify setting an object in data" + ); + assert.equal( + div.data( "test2" ), "in2", "Verify setting an object in data" + ); obj = { test:"unset" }; jqobj = jQuery( obj ); jqobj.data( "test", "unset" ); jqobj.data( { "test": "in", "test2": "in2" } ); - equal( jQuery.data( obj )[ "test" ], "in", "Verify setting an object on an object extends the data object" ); - equal( obj[ "test2" ], undefined, "Verify setting an object on an object does not extend the object" ); + assert.equal( + jQuery.data( obj )[ "test" ], "in", "Verify setting an object on an object extends the data object" + ); + assert.equal( + obj[ "test2" ], undefined, "Verify setting an object on an object does not extend the object" + ); // manually clean up detached elements div.remove(); } ); -test( "jQuery.removeData", function() { - expect( 10 ); +QUnit.test( "jQuery.removeData", function( assert ) { + assert.expect( 10 ); var obj, div = jQuery( "#foo" )[ 0 ]; jQuery.data( div, "test", "testing" ); jQuery.removeData( div, "test" ); - equal( jQuery.data( div, "test" ), undefined, "Check removal of data" ); + assert.equal( + jQuery.data( div, "test" ), undefined, "Check removal of data" + ); jQuery.data( div, "test2", "testing" ); jQuery.removeData( div ); - ok( !jQuery.data( div, "test2" ), "Make sure that the data property no longer exists." ); - ok( !div[ jQuery.expando ], "Make sure the expando no longer exists, as well." ); + assert.ok( + !jQuery.data( div, "test2" ), "Make sure that the data property no longer exists." + ); + assert.ok( + !div[ jQuery.expando ], "Make sure the expando no longer exists, as well." + ); jQuery.data( div, { test3: "testing", test4: "testing" } ); jQuery.removeData( div, "test3 test4" ); - ok( !jQuery.data( div, "test3" ) || jQuery.data( div, "test4" ), "Multiple delete with spaces." ); + assert.ok( + !jQuery.data( div, "test3" ) || jQuery.data( div, "test4" ), "Multiple delete with spaces." + ); jQuery.data( div, { test3: "testing", test4: "testing" } ); jQuery.removeData( div, [ "test3", "test4" ] ); - ok( !jQuery.data( div, "test3" ) || jQuery.data( div, "test4" ), "Multiple delete by array." ); + assert.ok( + !jQuery.data( div, "test3" ) || jQuery.data( div, "test4" ), "Multiple delete by array." + ); jQuery.data( div, { "test3 test4": "testing", "test3": "testing" } ); jQuery.removeData( div, "test3 test4" ); - ok( !jQuery.data( div, "test3 test4" ), "Multiple delete with spaces deleted key with exact name" ); - ok( jQuery.data( div, "test3" ), "Left the partial matched key alone" ); + assert.ok( + !jQuery.data( div, "test3 test4" ), "Multiple delete with spaces deleted key with exact name" + ); + assert.ok( + jQuery.data( div, "test3" ), "Left the partial matched key alone" + ); obj = {}; jQuery.data( obj, "test", "testing" ); - equal( jQuery( obj ).data( "test" ), "testing", "verify data on plain object" ); + assert.equal( + jQuery( obj ).data( "test" ), "testing", "verify data on plain object" + ); jQuery.removeData( obj, "test" ); - equal( jQuery.data( obj, "test" ), undefined, "Check removal of data on plain object" ); + assert.equal( + jQuery.data( obj, "test" ), undefined, "Check removal of data on plain object" + ); jQuery.data( window, "BAD", true ); jQuery.removeData( window, "BAD" ); - ok( !jQuery.data( window, "BAD" ), "Make sure that the value was not still set." ); + assert.ok( + !jQuery.data( window, "BAD" ), "Make sure that the value was not still set." + ); } ); -test( ".removeData()", function() { - expect( 6 ); +QUnit.test( ".removeData()", function( assert ) { + assert.expect( 6 ); var div = jQuery( "#foo" ); div.data( "test", "testing" ); div.removeData( "test" ); - equal( div.data( "test" ), undefined, "Check removal of data" ); + assert.equal( + div.data( "test" ), undefined, "Check removal of data" + ); div.data( "test", "testing" ); div.data( "test.foo", "testing2" ); div.removeData( "test.bar" ); - equal( div.data( "test.foo" ), "testing2", "Make sure data is intact" ); - equal( div.data( "test" ), "testing", "Make sure data is intact" ); + assert.equal( + div.data( "test.foo" ), "testing2", "Make sure data is intact" + ); + assert.equal( + div.data( "test" ), "testing", "Make sure data is intact" + ); div.removeData( "test" ); - equal( div.data( "test.foo" ), "testing2", "Make sure data is intact" ); - equal( div.data( "test" ), undefined, "Make sure data is intact" ); + assert.equal( + div.data( "test.foo" ), "testing2", "Make sure data is intact" + ); + assert.equal( + div.data( "test" ), undefined, "Make sure data is intact" + ); div.removeData( "test.foo" ); - equal( div.data( "test.foo" ), undefined, "Make sure data is intact" ); + assert.equal( + div.data( "test.foo" ), undefined, "Make sure data is intact" + ); } ); if ( window.JSON && window.JSON.stringify ) { - test( "JSON serialization (#8108)", function() { - expect( 1 ); + QUnit.test( "JSON serialization (#8108)", function( assert ) { + assert.expect( 1 ); var obj = { "foo": "bar" }; jQuery.data( obj, "hidden", true ); - equal( JSON.stringify( obj ), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" ); + assert.equal( + JSON.stringify( obj ), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" + ); } ); } -test( "jQuery.data should follow html5 specification regarding camel casing", function() { - expect( 10 ); +QUnit.test( "jQuery.data should follow html5 specification regarding camel casing", function( assert ) { + assert.expect( 10 ); var div = jQuery( "<div id='myObject' data-w-t-f='ftw' data-big-a-little-a='bouncing-b' data-foo='a' data-foo-bar='b' data-foo-bar-baz='c'></div>" ) .prependTo( "body" ); - equal( div.data()[ "wTF" ], "ftw", "Verify single letter data-* key" ); - equal( div.data()[ "bigALittleA" ], "bouncing-b", "Verify single letter mixed data-* key" ); - - equal( div.data()[ "foo" ], "a", "Verify single word data-* key" ); - equal( div.data()[ "fooBar" ], "b", "Verify multiple word data-* key" ); - equal( div.data()[ "fooBarBaz" ], "c", "Verify multiple word data-* key" ); - - equal( div.data( "foo" ), "a", "Verify single word data-* key" ); - equal( div.data( "fooBar" ), "b", "Verify multiple word data-* key" ); - equal( div.data( "fooBarBaz" ), "c", "Verify multiple word data-* key" ); + assert.equal( + div.data()[ "wTF" ], "ftw", "Verify single letter data-* key" + ); + assert.equal( + div.data()[ "bigALittleA" ], "bouncing-b", "Verify single letter mixed data-* key" + ); + + assert.equal( + div.data()[ "foo" ], "a", "Verify single word data-* key" + ); + assert.equal( + div.data()[ "fooBar" ], "b", "Verify multiple word data-* key" + ); + assert.equal( + div.data()[ "fooBarBaz" ], "c", "Verify multiple word data-* key" + ); + + assert.equal( + div.data( "foo" ), "a", "Verify single word data-* key" + ); + assert.equal( + div.data( "fooBar" ), "b", "Verify multiple word data-* key" + ); + assert.equal( + div.data( "fooBarBaz" ), "c", "Verify multiple word data-* key" + ); div.data( "foo-bar", "d" ); - equal( div.data( "fooBar" ), "d", "Verify updated data-* key" ); - equal( div.data( "foo-bar" ), "d", "Verify updated data-* key" ); + assert.equal( + div.data( "fooBar" ), "d", "Verify updated data-* key" + ); + assert.equal( + div.data( "foo-bar" ), "d", "Verify updated data-* key" + ); div.remove(); } ); -test( "jQuery.data should not miss data with preset hyphenated property names", function() { +QUnit.test( "jQuery.data should not miss data with preset hyphenated property names", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var div = jQuery( "<div/>", { id: "hyphened" } ).appendTo( "#qunit-fixture" ), test = { @@ -542,12 +822,14 @@ test( "jQuery.data should not miss data with preset hyphenated property names", div.data( test ); jQuery.each( test, function( i, k ) { - equal( div.data( k ), k, "data with property '" + k + "' was correctly found" ); + assert.equal( + div.data( k ), k, "data with property '" + k + "' was correctly found" + ); } ); } ); -test( ".data should not miss attr() set data-* with hyphenated property names", function() { - expect( 2 ); +QUnit.test( ".data should not miss attr() set data-* with hyphenated property names", function( assert ) { + assert.expect( 2 ); var a, b; @@ -556,7 +838,9 @@ test( ".data should not miss attr() set data-* with hyphenated property names", a.attr( "data-long-param", "test" ); a.data( "long-param", { a: 2 } ); - deepEqual( a.data( "long-param" ), { a: 2 }, "data with property long-param was found, 1" ); + assert.deepEqual( + a.data( "long-param" ), { a: 2 }, "data with property long-param was found, 1" + ); b = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ); @@ -564,11 +848,13 @@ test( ".data should not miss attr() set data-* with hyphenated property names", b.data( "long-param" ); b.data( "long-param", { a: 2 } ); - deepEqual( b.data( "long-param" ), { a: 2 }, "data with property long-param was found, 2" ); + assert.deepEqual( + b.data( "long-param" ), { a: 2 }, "data with property long-param was found, 2" + ); } ); -test( ".data always sets data with the camelCased key (gh-2257)", function() { - expect( 36 ); +QUnit.test( ".data always sets data with the camelCased key (gh-2257)", function( assert ) { + assert.expect( 36 ); var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ), datas = { @@ -590,8 +876,12 @@ test( ".data always sets data with the camelCased key (gh-2257)", function() { jQuery.each( datas, function( key, val ) { div.data( key, val ); var allData = div.data(); - equal( allData[ key ], undefined, ".data(key, val) does not store with hyphenated keys" ); - equal( allData[ jQuery.camelCase( key ) ], val, ".data(key, val) stores the camelCased key" ); + assert.equal( + allData[ key ], undefined, ".data(key, val) does not store with hyphenated keys" + ); + assert.equal( + allData[ jQuery.camelCase( key ) ], val, ".data(key, val) stores the camelCased key" + ); } ); div.removeData(); @@ -599,163 +889,211 @@ test( ".data always sets data with the camelCased key (gh-2257)", function() { div.data( datas ); jQuery.each( datas, function( key, val ) { var allData = div.data(); - equal( allData[ key ], undefined, ".data(object) does not store with hyphenated keys" ); - equal( allData[ jQuery.camelCase( key ) ], val, ".data(object) stores the camelCased key" ); + assert.equal( + allData[ key ], undefined, ".data(object) does not store with hyphenated keys" + ); + assert.equal( + allData[ jQuery.camelCase( key ) ], val, ".data(object) stores the camelCased key" + ); } ); } ); -test( ".data should not strip more than one hyphen when camelCasing (gh-2070)", function() { - expect( 3 ); - var div = jQuery( "<div data-nested-single='single' data-nested--double='double' data-nested---triple='triple'></div>" ).appendTo( "#qunit-fixture" ), - allData = div.data(); - - equal( allData.nestedSingle, "single", "Key is correctly camelCased" ); - equal( allData[ "nested-Double" ], "double", "Key with double hyphens is correctly camelCased" ); - equal( allData[ "nested--Triple" ], "triple", "Key with triple hyphens is correctly camelCased" ); -} ); - -test( ".data supports interoperable hyphenated/camelCase get/set of properties with arbitrary non-null|NaN|undefined values", function() { - var div = jQuery( "<div/>", { id: "hyphened" } ).appendTo( "#qunit-fixture" ), - datas = { - "non-empty": "a string", - "empty-string": "", - "one-value": 1, - "zero-value": 0, - "an-array": [], - "an-object": {}, - "bool-true": true, - "bool-false": false, - - // JSHint enforces double quotes, - // but JSON strings need double quotes to parse - // so we need escaped double quotes here - "some-json": "{ \"foo\": \"bar\" }", - "num-1-middle": true, - "num-end-2": true, - "2-num-start": true - }; - - expect( 24 ); - - jQuery.each( datas, function( key, val ) { - div.data( key, val ); - - deepEqual( div.data( key ), val, "get: " + key ); - deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) ); - } ); -} ); - -test( "jQuery.data supports interoperable removal of hyphenated/camelCase properties", function() { - var div = jQuery( "<div/>", { id: "hyphened" } ).appendTo( "#qunit-fixture" ), - datas = { - "non-empty": "a string", - "empty-string": "", - "one-value": 1, - "zero-value": 0, - "an-array": [], - "an-object": {}, - "bool-true": true, - "bool-false": false, - - // JSHint enforces double quotes, - // but JSON strings need double quotes to parse - // so we need escaped double quotes here - "some-json": "{ \"foo\": \"bar\" }" - }; - - expect( 27 ); - - jQuery.each( datas, function( key, val ) { - div.data( key, val ); +QUnit.test( + ".data should not strip more than one hyphen when camelCasing (gh-2070)", + function( assert ) { + assert.expect( 3 ); + var div = jQuery( "<div data-nested-single='single' data-nested--double='double' data-nested---triple='triple'></div>" ).appendTo( "#qunit-fixture" ), + allData = div.data(); + + assert.equal( + allData.nestedSingle, "single", "Key is correctly camelCased" + ); + assert.equal( + allData[ "nested-Double" ], "double", "Key with double hyphens is correctly camelCased" + ); + assert.equal( + allData[ "nested--Triple" ], "triple", "Key with triple hyphens is correctly camelCased" + ); + } +); + +QUnit.test( + ".data supports interoperable hyphenated/camelCase get/set of" + + " properties with arbitrary non-null|NaN|undefined values", + function( assert ) { + var div = jQuery( "<div/>", { id: "hyphened" } ).appendTo( "#qunit-fixture" ), + datas = { + "non-empty": "a string", + "empty-string": "", + "one-value": 1, + "zero-value": 0, + "an-array": [], + "an-object": {}, + "bool-true": true, + "bool-false": false, + + // JSHint enforces double quotes, + // but JSON strings need double quotes to parse + // so we need escaped double quotes here + "some-json": "{ \"foo\": \"bar\" }", + "num-1-middle": true, + "num-end-2": true, + "2-num-start": true + }; + + assert.expect( 24 ); + + jQuery.each( datas, function( key, val ) { + div.data( key, val ); + + assert.deepEqual( + div.data( key ), val, "get: " + key + ); + assert.deepEqual( + div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) + ); + } ); + } +); + +QUnit.test( + "jQuery.data supports interoperable removal of hyphenated/camelCase properties", + function( assert ) { + var div = jQuery( "<div/>", { id: "hyphened" } ).appendTo( "#qunit-fixture" ), + datas = { + "non-empty": "a string", + "empty-string": "", + "one-value": 1, + "zero-value": 0, + "an-array": [], + "an-object": {}, + "bool-true": true, + "bool-false": false, + + // JSHint enforces double quotes, + // but JSON strings need double quotes to parse + // so we need escaped double quotes here + "some-json": "{ \"foo\": \"bar\" }" + }; + + assert.expect( 27 ); + + jQuery.each( datas, function( key, val ) { + div.data( key, val ); + + assert.deepEqual( + div.data( key ), val, "get: " + key + ); + assert.deepEqual( + div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) + ); + + div.removeData( key ); + + assert.equal( + div.data( key ), undefined, "get: " + key + ); + + } ); + } +); + +QUnit.test( + ".data supports interoperable removal of properties SET TWICE #13850", + function( assert ) { + var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ), + datas = { + "non-empty": "a string", + "empty-string": "", + "one-value": 1, + "zero-value": 0, + "an-array": [], + "an-object": {}, + "bool-true": true, + "bool-false": false, + + // JSHint enforces double quotes, + // but JSON strings need double quotes to parse + // so we need escaped double quotes here + "some-json": "{ \"foo\": \"bar\" }" + }; + + assert.expect( 9 ); + + jQuery.each( datas, function( key, val ) { + div.data( key, val ); + div.data( key, val ); + + div.removeData( key ); + + assert.equal( + div.data( key ), undefined, "removal: " + key + ); + } ); + } +); - deepEqual( div.data( key ), val, "get: " + key ); - deepEqual( div.data( jQuery.camelCase( key ) ), val, "get: " + jQuery.camelCase( key ) ); +QUnit.test( + ".removeData supports removal of hyphenated properties via array (#12786, gh-2257)", + function( assert ) { + assert.expect( 4 ); - div.removeData( key ); + var div, plain, compare; - equal( div.data( key ), undefined, "get: " + key ); + div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ); + plain = jQuery( {} ); - } ); -} ); + // Properties should always be camelCased + compare = { -test( ".data supports interoperable removal of properties SET TWICE #13850", function() { - var div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ), - datas = { - "non-empty": "a string", - "empty-string": "", - "one-value": 1, - "zero-value": 0, - "an-array": [], - "an-object": {}, - "bool-true": true, - "bool-false": false, + // From batch assignment .data({ "a-a": 1 }) + "aA": 1, - // JSHint enforces double quotes, - // but JSON strings need double quotes to parse - // so we need escaped double quotes here - "some-json": "{ \"foo\": \"bar\" }" + // From property, value assignment .data( "b-b", 1 ) + "bB": 1 }; - expect( 9 ); - - jQuery.each( datas, function( key, val ) { - div.data( key, val ); - div.data( key, val ); - - div.removeData( key ); - - equal( div.data( key ), undefined, "removal: " + key ); - } ); -} ); - -test( ".removeData supports removal of hyphenated properties via array (#12786, gh-2257)", function() { - expect( 4 ); - - var div, plain, compare; - - div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ); - plain = jQuery( {} ); - - // Properties should always be camelCased - compare = { - - // From batch assignment .data({ "a-a": 1 }) - "aA": 1, - - // From property, value assignment .data( "b-b", 1 ) - "bB": 1 - }; - - // Mixed assignment - div.data( { "a-a": 1 } ).data( "b-b", 1 ); - plain.data( { "a-a": 1 } ).data( "b-b", 1 ); - - deepEqual( div.data(), compare, "Data appears as expected. (div)" ); - deepEqual( plain.data(), compare, "Data appears as expected. (plain)" ); - - div.removeData( [ "a-a", "b-b" ] ); - plain.removeData( [ "a-a", "b-b" ] ); - - deepEqual( div.data(), {}, "Data is empty. (div)" ); - deepEqual( plain.data(), {}, "Data is empty. (plain)" ); -} ); + // Mixed assignment + div.data( { "a-a": 1 } ).data( "b-b", 1 ); + plain.data( { "a-a": 1 } ).data( "b-b", 1 ); + + assert.deepEqual( + div.data(), compare, "Data appears as expected. (div)" + ); + assert.deepEqual( + plain.data(), compare, "Data appears as expected. (plain)" + ); + + div.removeData( [ "a-a", "b-b" ] ); + plain.removeData( [ "a-a", "b-b" ] ); + + assert.deepEqual( + div.data(), {}, "Data is empty. (div)" + ); + assert.deepEqual( + plain.data(), {}, "Data is empty. (plain)" + ); + } +); // Test originally by Moschel -test( "Triggering the removeData should not throw exceptions. (#10080)", function() { - expect( 1 ); - stop(); +QUnit.test( "Triggering the removeData should not throw exceptions. (#10080)", function( assert ) { + assert.expect( 1 ); + QUnit.stop(); var frame = jQuery( "#loadediframe" ); jQuery( frame[ 0 ].contentWindow ).on( "unload", function() { - ok( true, "called unload" ); - start(); + assert.ok( + true, "called unload" + ); + QUnit.start(); } ); // change the url to trigger unload frame.attr( "src", "data/iframe.html?param=true" ); } ); -test( "Only check element attributes once when calling .data() - #8909", function() { - expect( 2 ); +QUnit.test( "Only check element attributes once when calling .data() - #8909", function( assert ) { + assert.expect( 2 ); var testing = { "test": "testing", "test2": "testing" @@ -765,25 +1103,37 @@ test( "Only check element attributes once when calling .data() - #8909", functio // set an attribute using attr to ensure it node.setAttribute( "data-test2", "testing" ); - deepEqual( element.data(), testing, "Sanity Check" ); + assert.deepEqual( + element.data(), testing, "Sanity Check" + ); node.setAttribute( "data-test3", "testing" ); - deepEqual( element.data(), testing, "The data didn't change even though the data-* attrs did" ); + assert.deepEqual( + element.data(), testing, "The data didn't change even though the data-* attrs did" + ); // clean up data cache element.remove(); } ); -test( "JSON data- attributes can have newlines", function() { - expect( 1 ); +QUnit.test( "JSON data- attributes can have newlines", function( assert ) { + assert.expect( 1 ); var x = jQuery( "<div data-some='{\n\"foo\":\n\t\"bar\"\n}'></div>" ); - equal( x.data( "some" ).foo, "bar", "got a JSON data- attribute with spaces" ); + assert.equal( + x.data( "some" ).foo, "bar", "got a JSON data- attribute with spaces" + ); x.remove(); } ); -testIframeWithCallback( "enumerate data attrs on body (#14894)", "data/dataAttrs.html", function( result ) { - expect( 1 ); +testIframeWithCallback( + "enumerate data attrs on body (#14894)", + "data/dataAttrs.html", + function( result, assert ) { + assert.expect( 1 ); - equal( result, "ok", "enumeration of data- attrs on body" ); -} ); + assert.equal( + result, "ok", "enumeration of data- attrs on body" + ); + } +); diff --git a/test/unit/deferred.js b/test/unit/deferred.js index 3bf6ca49e..33b5b4f16 100644 --- a/test/unit/deferred.js +++ b/test/unit/deferred.js @@ -1,4 +1,4 @@ -module( "deferred", { +QUnit.module( "deferred", { teardown: moduleTeardown } ); @@ -8,51 +8,51 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { return withNew ? new jQuery.Deferred( fn ) : jQuery.Deferred( fn ); } - test( "jQuery.Deferred" + withNew, function() { + QUnit.test( "jQuery.Deferred" + withNew, function( assert ) { - expect( 23 ); + assert.expect( 23 ); var defer = createDeferred(); - ok( jQuery.isFunction( defer.pipe ), "defer.pipe is a function" ); + assert.ok( jQuery.isFunction( defer.pipe ), "defer.pipe is a function" ); createDeferred().resolve().done( function() { - ok( true, "Success on resolve" ); - strictEqual( this.state(), "resolved", "Deferred is resolved (state)" ); + assert.ok( true, "Success on resolve" ); + assert.strictEqual( this.state(), "resolved", "Deferred is resolved (state)" ); } ).fail( function() { - ok( false, "Error on resolve" ); + assert.ok( false, "Error on resolve" ); } ).always( function() { - ok( true, "Always callback on resolve" ); + assert.ok( true, "Always callback on resolve" ); } ); createDeferred().reject().done( function() { - ok( false, "Success on reject" ); + assert.ok( false, "Success on reject" ); } ).fail( function() { - ok( true, "Error on reject" ); - strictEqual( this.state(), "rejected", "Deferred is rejected (state)" ); + assert.ok( true, "Error on reject" ); + assert.strictEqual( this.state(), "rejected", "Deferred is rejected (state)" ); } ).always( function() { - ok( true, "Always callback on reject" ); + assert.ok( true, "Always callback on reject" ); } ); createDeferred( function( defer ) { - ok( this === defer, "Defer passed as this & first argument" ); + assert.ok( this === defer, "Defer passed as this & first argument" ); this.resolve( "done" ); } ).done( function( value ) { - strictEqual( value, "done", "Passed function executed" ); + assert.strictEqual( value, "done", "Passed function executed" ); } ); createDeferred( function( defer ) { var promise = defer.promise(), func = function() {}, funcPromise = defer.promise( func ); - strictEqual( defer.promise(), promise, "promise is always the same" ); - strictEqual( funcPromise, func, "non objects get extended" ); + assert.strictEqual( defer.promise(), promise, "promise is always the same" ); + assert.strictEqual( funcPromise, func, "non objects get extended" ); jQuery.each( promise, function( key ) { if ( !jQuery.isFunction( promise[ key ] ) ) { - ok( false, key + " is a function (" + jQuery.type( promise[ key ] ) + ")" ); + assert.ok( false, key + " is a function (" + jQuery.type( promise[ key ] ) + ")" ); } if ( promise[ key ] !== func[ key ] ) { - strictEqual( func[ key ], promise[ key ], key + " is the same" ); + assert.strictEqual( func[ key ], promise[ key ], key + " is the same" ); } } ); } ); @@ -60,39 +60,39 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) { jQuery.expandedEach = jQuery.each; jQuery.expandedEach( "resolve reject".split( " " ), function( _, change ) { createDeferred( function( defer ) { - strictEqual( defer.state(), "pending", "pending after creation" ); + assert.strictEqual( defer.state(), "pending", "pending after creation" ); var checked = 0; defer.progress( function( value ) { - strictEqual( value, checked, "Progress: right value (" + value + ") received" ); + assert.strictEqual( value, checked, "Progress: right value (" + value + ") received" ); } ); for ( checked = 0; checked < 3; checked++ ) { defer.notify( checked ); } - strictEqual( defer.state(), "pending", "pending after notification" ); + assert.strictEqual( defer.state(), "pending", "pending after notification" ); defer[ change ](); - notStrictEqual( defer.state(), "pending", "not pending after " + change ); + assert.notStrictEqual( defer.state(), "pending", "not pending after " + change ); defer.notify(); } ); } ); } ); } ); -test( "jQuery.Deferred - chainability", function() { +QUnit.test( "jQuery.Deferred - chainability", function( assert ) { var defer = jQuery.Deferred(); - expect( 10 ); + assert.expect( 10 ); jQuery.expandedEach = jQuery.each; jQuery.expandedEach( "resolve reject notify resolveWith rejectWith notifyWith done fail progress always".split( " " ), function( _, method ) { var object = { m: defer[ method ] }; - strictEqual( object.m(), object, method + " is chainable" ); + assert.strictEqual( object.m(), object, method + " is chainable" ); } ); } ); -test( "jQuery.Deferred.then - filtering (done)", function( assert ) { +QUnit.test( "jQuery.Deferred.then - filtering (done)", function( assert ) { assert.expect( 4 ); @@ -129,7 +129,7 @@ test( "jQuery.Deferred.then - filtering (done)", function( assert ) { } ); } ); -test( "jQuery.Deferred.then - filtering (fail)", function( assert ) { +QUnit.test( "jQuery.Deferred.then - filtering (fail)", function( assert ) { assert.expect( 4 ); @@ -166,7 +166,7 @@ test( "jQuery.Deferred.then - filtering (fail)", function( assert ) { } ); } ); -test( "jQuery.Deferred.catch", function( assert ) { +QUnit.test( "jQuery.Deferred.catch", function( assert ) { assert.expect( 4 ); var value1, value2, value3, @@ -202,7 +202,7 @@ test( "jQuery.Deferred.catch", function( assert ) { } ); } ); -test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert ) { +QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert ) { assert.expect( 4 ); @@ -239,7 +239,7 @@ test( "[PIPE ONLY] jQuery.Deferred.pipe - filtering (fail)", function( assert ) } ); } ); -test( "jQuery.Deferred.then - filtering (progress)", function( assert ) { +QUnit.test( "jQuery.Deferred.then - filtering (progress)", function( assert ) { assert.expect( 3 ); @@ -267,7 +267,7 @@ test( "jQuery.Deferred.then - filtering (progress)", function( assert ) { } ); } ); -test( "jQuery.Deferred.then - deferred (done)", function( assert ) { +QUnit.test( "jQuery.Deferred.then - deferred (done)", function( assert ) { assert.expect( 3 ); @@ -299,7 +299,7 @@ test( "jQuery.Deferred.then - deferred (done)", function( assert ) { } ); } ); -test( "jQuery.Deferred.then - deferred (fail)", function( assert ) { +QUnit.test( "jQuery.Deferred.then - deferred (fail)", function( assert ) { assert.expect( 3 ); @@ -331,7 +331,7 @@ test( "jQuery.Deferred.then - deferred (fail)", function( assert ) { } ); } ); -test( "jQuery.Deferred.then - deferred (progress)", function( assert ) { +QUnit.test( "jQuery.Deferred.then - deferred (progress)", function( assert ) { assert.expect( 3 ); @@ -371,7 +371,7 @@ test( "jQuery.Deferred.then - deferred (progress)", function( assert ) { } ); } ); -test( "[PIPE ONLY] jQuery.Deferred.pipe - deferred (progress)", function( assert ) { +QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - deferred (progress)", function( assert ) { assert.expect( 3 ); @@ -403,7 +403,7 @@ test( "[PIPE ONLY] jQuery.Deferred.pipe - deferred (progress)", function( assert } ); } ); -test( "jQuery.Deferred.then - context", function( assert ) { +QUnit.test( "jQuery.Deferred.then - context", function( assert ) { assert.expect( 7 ); @@ -454,7 +454,7 @@ test( "jQuery.Deferred.then - context", function( assert ) { } ); } ); -test( "[PIPE ONLY] jQuery.Deferred.pipe - context", function( assert ) { +QUnit.test( "[PIPE ONLY] jQuery.Deferred.pipe - context", function( assert ) { assert.expect( 7 ); @@ -505,9 +505,9 @@ test( "[PIPE ONLY] jQuery.Deferred.pipe - context", function( assert ) { } ); } ); -asyncTest( "jQuery.Deferred.then - spec compatibility", function() { +QUnit.asyncTest( "jQuery.Deferred.then - spec compatibility", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var defer = jQuery.Deferred().done( function() { setTimeout( start ); @@ -515,7 +515,7 @@ asyncTest( "jQuery.Deferred.then - spec compatibility", function() { } ); defer.then( function() { - ok( true, "errors in .done callbacks don't stop .then handlers" ); + assert.ok( true, "errors in .done callbacks don't stop .then handlers" ); } ); try { @@ -523,9 +523,9 @@ asyncTest( "jQuery.Deferred.then - spec compatibility", function() { } catch ( _ ) {} } ); -test( "jQuery.Deferred - 1.x/2.x compatibility", function( assert ) { +QUnit.test( "jQuery.Deferred - 1.x/2.x compatibility", function( assert ) { - expect( 8 ); + assert.expect( 8 ); var context = { id: "callback context" }, thenable = jQuery.Deferred().resolve( "thenable fulfillment" ).promise(), @@ -574,16 +574,16 @@ test( "jQuery.Deferred - 1.x/2.x compatibility", function( assert ) { } ); } ); -test( "jQuery.Deferred.then - progress and thenables", function( assert ) { +QUnit.test( "jQuery.Deferred.then - progress and thenables", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var trigger = jQuery.Deferred().notify(), expectedProgress = [ "baz", "baz" ], done = jQuery.map( new Array( 2 ), function() { return assert.async(); } ), failer = function( evt ) { return function() { - ok( false, "no unexpected " + evt ); + assert.ok( false, "no unexpected " + evt ); }; }; @@ -600,9 +600,9 @@ test( "jQuery.Deferred.then - progress and thenables", function( assert ) { trigger.notify(); } ); -test( "jQuery.Deferred - notify and resolve", function( assert ) { +QUnit.test( "jQuery.Deferred - notify and resolve", function( assert ) { - expect( 7 ); + assert.expect( 7 ); var notifiedResolved = jQuery.Deferred().notify( "foo" )/*xxx .resolve( "bar" )*/, done = jQuery.map( new Array( 3 ), function() { return assert.async(); } ); @@ -649,9 +649,9 @@ test( "jQuery.Deferred - notify and resolve", function( assert ) { } ); } ); -test( "jQuery.when", function() { +QUnit.test( "jQuery.when", function( assert ) { - expect( 37 ); + assert.expect( 37 ); // Some other objects jQuery.each( { @@ -667,22 +667,22 @@ test( "jQuery.when", function() { "an array": [ 1, 2, 3 ] }, function( message, value ) { - ok( + assert.ok( jQuery.isFunction( jQuery.when( value ).done( function( resolveValue ) { - strictEqual( this, window, "Context is the global object with " + message ); - strictEqual( resolveValue, value, "Test the promise was resolved with " + message ); + assert.strictEqual( this, window, "Context is the global object with " + message ); + assert.strictEqual( resolveValue, value, "Test the promise was resolved with " + message ); } ).promise ), "Test " + message + " triggers the creation of a new Promise" ); } ); - ok( + assert.ok( jQuery.isFunction( jQuery.when().done( function( resolveValue ) { - strictEqual( this, window, "Test the promise was resolved with window as its context" ); - strictEqual( resolveValue, undefined, "Test the promise was resolved with no parameter" ); + assert.strictEqual( this, window, "Test the promise was resolved with window as its context" ); + assert.strictEqual( resolveValue, undefined, "Test the promise was resolved with no parameter" ); } ).promise ), "Test calling when with no parameter triggers the creation of a new Promise" @@ -692,7 +692,7 @@ test( "jQuery.when", function() { context = {}; jQuery.when( jQuery.Deferred().resolveWith( context ) ).done( function() { - strictEqual( this, context, "when( promise ) propagates context" ); + assert.strictEqual( this, context, "when( promise ) propagates context" ); } ); jQuery.each( [ 1, 2, 3 ], function( k, i ) { @@ -702,16 +702,16 @@ test( "jQuery.when", function() { } ) ).done( function( value ) { - strictEqual( value, 1, "Function executed" + ( i > 1 ? " only once" : "" ) ); + assert.strictEqual( value, 1, "Function executed" + ( i > 1 ? " only once" : "" ) ); cache = value; } ); } ); } ); -test( "jQuery.when - joined", function() { +QUnit.test( "jQuery.when - joined", function( assert ) { - expect( 195 ); + assert.expect( 195 ); var deferreds = { rawValue: 1, @@ -741,11 +741,11 @@ test( "jQuery.when - joined", function() { }, counter = 49; - stop(); + QUnit.stop(); function restart() { if ( !--counter ) { - start(); + QUnit.start(); } } @@ -764,22 +764,22 @@ test( "jQuery.when - joined", function() { jQuery.when( defer1, defer2 ).done( function( a, b ) { if ( shouldResolve ) { - deepEqual( [ a, b ], expected, code + " => resolve" ); - strictEqual( this[ 0 ], context1, code + " => first context OK" ); - strictEqual( this[ 1 ], context2, code + " => second context OK" ); + assert.deepEqual( [ a, b ], expected, code + " => resolve" ); + assert.strictEqual( this[ 0 ], context1, code + " => first context OK" ); + assert.strictEqual( this[ 1 ], context2, code + " => second context OK" ); } else { - ok( false, code + " => resolve" ); + assert.ok( false, code + " => resolve" ); } } ).fail( function( a, b ) { if ( shouldError ) { - deepEqual( [ a, b ], expected, code + " => reject" ); + assert.deepEqual( [ a, b ], expected, code + " => reject" ); } else { - ok( false, code + " => reject" ); + assert.ok( false, code + " => reject" ); } } ).progress( function( a, b ) { - deepEqual( [ a, b ], expectedNotify, code + " => progress" ); - strictEqual( this[ 0 ], expectedNotify[ 0 ] ? context1 : undefined, code + " => first context OK" ); - strictEqual( this[ 1 ], expectedNotify[ 1 ] ? context2 : undefined, code + " => second context OK" ); + assert.deepEqual( [ a, b ], expectedNotify, code + " => progress" ); + assert.strictEqual( this[ 0 ], expectedNotify[ 0 ] ? context1 : undefined, code + " => first context OK" ); + assert.strictEqual( this[ 1 ], expectedNotify[ 1 ] ? context2 : undefined, code + " => second context OK" ); } ).always( restart ); } ); } ); @@ -787,69 +787,69 @@ test( "jQuery.when - joined", function() { deferreds.eventuallyRejected.reject( 0 ); } ); -test( "jQuery.when - resolved", function() { +QUnit.test( "jQuery.when - resolved", function( assert ) { - expect( 6 ); + assert.expect( 6 ); var a = jQuery.Deferred().notify( 1 ).resolve( 4 ), b = jQuery.Deferred().notify( 2 ).resolve( 5 ), c = jQuery.Deferred().notify( 3 ).resolve( 6 ); jQuery.when( a, b, c ).progress( function( a, b, c ) { - strictEqual( a, 1, "first notify value ok" ); - strictEqual( b, 2, "second notify value ok" ); - strictEqual( c, 3, "third notify value ok" ); + assert.strictEqual( a, 1, "first notify value ok" ); + assert.strictEqual( b, 2, "second notify value ok" ); + assert.strictEqual( c, 3, "third notify value ok" ); } ).done( function( a, b, c ) { - strictEqual( a, 4, "first resolve value ok" ); - strictEqual( b, 5, "second resolve value ok" ); - strictEqual( c, 6, "third resolve value ok" ); + assert.strictEqual( a, 4, "first resolve value ok" ); + assert.strictEqual( b, 5, "second resolve value ok" ); + assert.strictEqual( c, 6, "third resolve value ok" ); } ).fail( function() { - ok( false, "Error on resolve" ); + assert.ok( false, "Error on resolve" ); } ); } ); -test( "jQuery.when - filtering", function() { +QUnit.test( "jQuery.when - filtering", function( assert ) { - expect( 2 ); + assert.expect( 2 ); function increment( x ) { return x + 1; } - stop(); + QUnit.stop(); jQuery.when( jQuery.Deferred().resolve( 3 ).then( increment ), jQuery.Deferred().reject( 5 ).then( null, increment ) ).done( function( four, six ) { - strictEqual( four, 4, "resolved value incremented" ); - strictEqual( six, 6, "rejected value incremented" ); - start(); + assert.strictEqual( four, 4, "resolved value incremented" ); + assert.strictEqual( six, 6, "rejected value incremented" ); + QUnit.start(); } ); } ); -test( "jQuery.when - exceptions", function() { +QUnit.test( "jQuery.when - exceptions", function( assert ) { - expect( 2 ); + assert.expect( 2 ); function woops() { throw "exception thrown"; } - stop(); + QUnit.stop(); jQuery.Deferred().resolve().then( woops ).fail( function( doneException ) { - strictEqual( doneException, "exception thrown", "throwing in done handler" ); + assert.strictEqual( doneException, "exception thrown", "throwing in done handler" ); jQuery.Deferred().reject().then( null, woops ).fail( function( failException ) { - strictEqual( failException, "exception thrown", "throwing in fail handler" ); - start(); + assert.strictEqual( failException, "exception thrown", "throwing in fail handler" ); + QUnit.start(); } ); } ); } ); -test( "jQuery.when - chaining", function() { +QUnit.test( "jQuery.when - chaining", function( assert ) { - expect( 4 ); + assert.expect( 4 ); var defer = jQuery.Deferred(); @@ -861,7 +861,7 @@ test( "jQuery.when - chaining", function() { return Promise.resolve( "std deferred" ); } - stop(); + QUnit.stop(); jQuery.when( jQuery.Deferred().resolve( 3 ).then( chain ), @@ -869,11 +869,11 @@ test( "jQuery.when - chaining", function() { jQuery.Deferred().resolve( 3 ).then( chainStandard ), jQuery.Deferred().reject( 5 ).then( null, chainStandard ) ).done( function( v1, v2, s1, s2 ) { - strictEqual( v1, "other deferred", "chaining in done handler" ); - strictEqual( v2, "other deferred", "chaining in fail handler" ); - strictEqual( s1, "std deferred", "chaining thenable in done handler" ); - strictEqual( s2, "std deferred", "chaining thenable in fail handler" ); - start(); + assert.strictEqual( v1, "other deferred", "chaining in done handler" ); + assert.strictEqual( v2, "other deferred", "chaining in fail handler" ); + assert.strictEqual( s1, "std deferred", "chaining thenable in done handler" ); + assert.strictEqual( s2, "std deferred", "chaining thenable in fail handler" ); + QUnit.start(); } ); defer.resolve( "other deferred" ); diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js index 9052c6acf..52c137dc3 100644 --- a/test/unit/deprecated.js +++ b/test/unit/deprecated.js @@ -1,2 +1,2 @@ -module( "deprecated", { teardown: moduleTeardown } ); +QUnit.module( "deprecated", { teardown: moduleTeardown } ); diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js index eadb06050..0b49b5c68 100644 --- a/test/unit/dimensions.js +++ b/test/unit/dimensions.js @@ -4,7 +4,7 @@ if ( !jQuery.fn.width ) { return; } -module( "dimensions", { teardown: moduleTeardown } ); +QUnit.module( "dimensions", { teardown: moduleTeardown } ); function pass( val ) { return val; @@ -28,120 +28,120 @@ function fn( val ) { Returns a function that returns the value */ -function testWidth( val ) { - expect( 9 ); +function testWidth( val, assert ) { + assert.expect( 9 ); var $div, blah; $div = jQuery( "#nothiddendiv" ); $div.width( val( 30 ) ); - equal( $div.width(), 30, "Test set to 30 correctly" ); + assert.equal( $div.width(), 30, "Test set to 30 correctly" ); $div.hide(); - equal( $div.width(), 30, "Test hidden div" ); + assert.equal( $div.width(), 30, "Test hidden div" ); $div.show(); $div.width( val( -1 ) ); // handle negative numbers by setting to 0 #11604 - equal( $div.width(), 0, "Test negative width normalized to 0" ); + assert.equal( $div.width(), 0, "Test negative width normalized to 0" ); $div.css( "padding", "20px" ); - equal( $div.width(), 0, "Test padding specified with pixels" ); + assert.equal( $div.width(), 0, "Test padding specified with pixels" ); $div.css( "border", "2px solid #fff" ); - equal( $div.width(), 0, "Test border specified with pixels" ); + assert.equal( $div.width(), 0, "Test border specified with pixels" ); $div.css( { "display": "", "border": "", "padding": "" } ); jQuery( "#nothiddendivchild" ).css( { "width": 20, "padding": "3px", "border": "2px solid #fff" } ); - equal( jQuery( "#nothiddendivchild" ).width(), 20, "Test child width with border and padding" ); + assert.equal( jQuery( "#nothiddendivchild" ).width(), 20, "Test child width with border and padding" ); jQuery( "#nothiddendiv, #nothiddendivchild" ).css( { "border": "", "padding": "", "width": "" } ); blah = jQuery( "blah" ); - equal( blah.width( val( 10 ) ), blah, "Make sure that setting a width on an empty set returns the set." ); - equal( blah.width(), null, "Make sure 'null' is returned on an empty set" ); + assert.equal( blah.width( val( 10 ) ), blah, "Make sure that setting a width on an empty set returns the set." ); + assert.equal( blah.width(), null, "Make sure 'null' is returned on an empty set" ); - equal( jQuery( window ).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." ); + assert.equal( jQuery( window ).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." ); QUnit.expectJqData( this, $div[ 0 ], "display" ); } -test( "width()", function() { - testWidth( pass ); +QUnit.test( "width()", function( assert ) { + testWidth( pass, assert ); } ); -test( "width(Function)", function() { - testWidth( fn ); +QUnit.test( "width(Function)", function( assert ) { + testWidth( fn, assert ); } ); -test( "width(Function(args))", function() { - expect( 2 ); +QUnit.test( "width(Function(args))", function( assert ) { + assert.expect( 2 ); var $div = jQuery( "#nothiddendiv" ); $div.width( 30 ).width( function( i, width ) { - equal( width, 30, "Make sure previous value is correct." ); + assert.equal( width, 30, "Make sure previous value is correct." ); return width + 1; } ); - equal( $div.width(), 31, "Make sure value was modified correctly." ); + assert.equal( $div.width(), 31, "Make sure value was modified correctly." ); } ); -function testHeight( val ) { - expect( 9 ); +function testHeight( val, assert ) { + assert.expect( 9 ); var $div, blah; $div = jQuery( "#nothiddendiv" ); $div.height( val( 30 ) ); - equal( $div.height(), 30, "Test set to 30 correctly" ); + assert.equal( $div.height(), 30, "Test set to 30 correctly" ); $div.hide(); - equal( $div.height(), 30, "Test hidden div" ); + assert.equal( $div.height(), 30, "Test hidden div" ); $div.show(); $div.height( val( -1 ) ); // handle negative numbers by setting to 0 #11604 - equal( $div.height(), 0, "Test negative height normalized to 0" ); + assert.equal( $div.height(), 0, "Test negative height normalized to 0" ); $div.css( "padding", "20px" ); - equal( $div.height(), 0, "Test padding specified with pixels" ); + assert.equal( $div.height(), 0, "Test padding specified with pixels" ); $div.css( "border", "2px solid #fff" ); - equal( $div.height(), 0, "Test border specified with pixels" ); + assert.equal( $div.height(), 0, "Test border specified with pixels" ); $div.css( { "display": "", "border": "", "padding": "", "height": "1px" } ); jQuery( "#nothiddendivchild" ).css( { "height": 20, "padding": "3px", "border": "2px solid #fff" } ); - equal( jQuery( "#nothiddendivchild" ).height(), 20, "Test child height with border and padding" ); + assert.equal( jQuery( "#nothiddendivchild" ).height(), 20, "Test child height with border and padding" ); jQuery( "#nothiddendiv, #nothiddendivchild" ).css( { "border": "", "padding": "", "height": "" } ); blah = jQuery( "blah" ); - equal( blah.height( val( 10 ) ), blah, "Make sure that setting a height on an empty set returns the set." ); - equal( blah.height(), null, "Make sure 'null' is returned on an empty set" ); + assert.equal( blah.height( val( 10 ) ), blah, "Make sure that setting a height on an empty set returns the set." ); + assert.equal( blah.height(), null, "Make sure 'null' is returned on an empty set" ); - equal( jQuery( window ).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." ); + assert.equal( jQuery( window ).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." ); QUnit.expectJqData( this, $div[ 0 ], "display" ); } -test( "height()", function() { - testHeight( pass ); +QUnit.test( "height()", function( assert ) { + testHeight( pass, assert ); } ); -test( "height(Function)", function() { - testHeight( fn ); +QUnit.test( "height(Function)", function( assert ) { + testHeight( fn, assert ); } ); -test( "height(Function(args))", function() { - expect( 2 ); +QUnit.test( "height(Function(args))", function( assert ) { + assert.expect( 2 ); var $div = jQuery( "#nothiddendiv" ); $div.height( 30 ).height( function( i, height ) { - equal( height, 30, "Make sure previous value is correct." ); + assert.equal( height, 30, "Make sure previous value is correct." ); return height + 1; } ); - equal( $div.height(), 31, "Make sure value was modified correctly." ); + assert.equal( $div.height(), 31, "Make sure value was modified correctly." ); } ); -test( "innerWidth()", function() { - expect( 6 ); +QUnit.test( "innerWidth()", function( assert ) { + assert.expect( 6 ); var $div, div, $win = jQuery( window ), $doc = jQuery( document ); - equal( jQuery( window ).innerWidth(), $win.width(), "Test on window" ); - equal( jQuery( document ).innerWidth(), $doc.width(), "Test on document" ); + assert.equal( jQuery( window ).innerWidth(), $win.width(), "Test on window" ); + assert.equal( jQuery( document ).innerWidth(), $doc.width(), "Test on document" ); $div = jQuery( "#nothiddendiv" ); $div.css( { @@ -150,11 +150,11 @@ test( "innerWidth()", function() { "width": 30 } ); - equal( $div.innerWidth(), 30, "Test with margin and border" ); + assert.equal( $div.innerWidth(), 30, "Test with margin and border" ); $div.css( "padding", "20px" ); - equal( $div.innerWidth(), 70, "Test with margin, border and padding" ); + assert.equal( $div.innerWidth(), 70, "Test with margin, border and padding" ); $div.hide(); - equal( $div.innerWidth(), 70, "Test hidden div" ); + assert.equal( $div.innerWidth(), 70, "Test hidden div" ); // reset styles $div.css( { "display": "", "border": "", "padding": "", "width": "", "height": "" } ); @@ -162,21 +162,21 @@ test( "innerWidth()", function() { div = jQuery( "<div>" ); // Temporarily require 0 for backwards compat - should be auto - equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." ); + assert.equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." ); div.remove(); QUnit.expectJqData( this, $div[ 0 ], "display" ); } ); -test( "innerHeight()", function() { - expect( 6 ); +QUnit.test( "innerHeight()", function( assert ) { + assert.expect( 6 ); var $div, div, $win = jQuery( window ), $doc = jQuery( document ); - equal( jQuery( window ).innerHeight(), $win.height(), "Test on window" ); - equal( jQuery( document ).innerHeight(), $doc.height(), "Test on document" ); + assert.equal( jQuery( window ).innerHeight(), $win.height(), "Test on window" ); + assert.equal( jQuery( document ).innerHeight(), $doc.height(), "Test on document" ); $div = jQuery( "#nothiddendiv" ); $div.css( { @@ -185,11 +185,11 @@ test( "innerHeight()", function() { "height": 30 } ); - equal( $div.innerHeight(), 30, "Test with margin and border" ); + assert.equal( $div.innerHeight(), 30, "Test with margin and border" ); $div.css( "padding", "20px" ); - equal( $div.innerHeight(), 70, "Test with margin, border and padding" ); + assert.equal( $div.innerHeight(), 70, "Test with margin, border and padding" ); $div.hide(); - equal( $div.innerHeight(), 70, "Test hidden div" ); + assert.equal( $div.innerHeight(), 70, "Test hidden div" ); // reset styles $div.css( { "display": "", "border": "", "padding": "", "width": "", "height": "" } ); @@ -197,38 +197,38 @@ test( "innerHeight()", function() { div = jQuery( "<div>" ); // Temporarily require 0 for backwards compat - should be auto - equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." ); + assert.equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." ); div.remove(); QUnit.expectJqData( this, $div[ 0 ], "display" ); } ); -test( "outerWidth()", function() { - expect( 11 ); +QUnit.test( "outerWidth()", function( assert ) { + assert.expect( 11 ); var $div, div, $win = jQuery( window ), $doc = jQuery( document ); - equal( jQuery( window ).outerWidth(), $win.width(), "Test on window without margin option" ); - equal( jQuery( window ).outerWidth( true ), $win.width(), "Test on window with margin option" ); - equal( jQuery( document ).outerWidth(), $doc.width(), "Test on document without margin option" ); - equal( jQuery( document ).outerWidth( true ), $doc.width(), "Test on document with margin option" ); + assert.equal( jQuery( window ).outerWidth(), $win.width(), "Test on window without margin option" ); + assert.equal( jQuery( window ).outerWidth( true ), $win.width(), "Test on window with margin option" ); + assert.equal( jQuery( document ).outerWidth(), $doc.width(), "Test on document without margin option" ); + assert.equal( jQuery( document ).outerWidth( true ), $doc.width(), "Test on document with margin option" ); $div = jQuery( "#nothiddendiv" ); $div.css( "width", 30 ); - equal( $div.outerWidth(), 30, "Test with only width set" ); + assert.equal( $div.outerWidth(), 30, "Test with only width set" ); $div.css( "padding", "20px" ); - equal( $div.outerWidth(), 70, "Test with padding" ); + assert.equal( $div.outerWidth(), 70, "Test with padding" ); $div.css( "border", "2px solid #fff" ); - equal( $div.outerWidth(), 74, "Test with padding and border" ); + assert.equal( $div.outerWidth(), 74, "Test with padding and border" ); $div.css( "margin", "10px" ); - equal( $div.outerWidth(), 74, "Test with padding, border and margin without margin option" ); + assert.equal( $div.outerWidth(), 74, "Test with padding, border and margin without margin option" ); $div.css( "position", "absolute" ); - equal( $div.outerWidth( true ), 94, "Test with padding, border and margin with margin option" ); + assert.equal( $div.outerWidth( true ), 94, "Test with padding, border and margin with margin option" ); $div.hide(); - equal( $div.outerWidth( true ), 94, "Test hidden div with padding, border and margin with margin option" ); + assert.equal( $div.outerWidth( true ), 94, "Test hidden div with padding, border and margin with margin option" ); // reset styles $div.css( { "position": "", "display": "", "border": "", "padding": "", "width": "", "height": "" } ); @@ -236,14 +236,14 @@ test( "outerWidth()", function() { div = jQuery( "<div>" ); // Temporarily require 0 for backwards compat - should be auto - equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." ); + assert.equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." ); div.remove(); QUnit.expectJqData( this, $div[ 0 ], "display" ); } ); -test( "child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function() { - expect( 16 ); +QUnit.test( "child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function( assert ) { + assert.expect( 16 ); // setup html var $divNormal = jQuery( "<div>" ).css( { "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" } ), @@ -253,38 +253,38 @@ test( "child of a hidden elem (or unconnected node) has accurate inner/outer/Wid $divNormal.appendTo( "body" ); // tests that child div of a hidden div works the same as a normal div - equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #9441" ); - equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #9441" ); - equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #9441" ); - equal( $divChild.outerWidth( true ), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #9300" ); + assert.equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #9441" ); + assert.equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #9441" ); + assert.equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #9441" ); + assert.equal( $divChild.outerWidth( true ), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #9300" ); // Support: IE 10-11, Edge // Child height is not always decimal - equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #9441" ); - equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #9441" ); - equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #9441" ); - equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #9300" ); + assert.equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #9441" ); + assert.equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #9441" ); + assert.equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #9441" ); + assert.equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #9300" ); // tests that child div of an unconnected div works the same as a normal div - equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #9441" ); - equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #9441" ); - equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #9441" ); - equal( $divUnconnected.outerWidth( true ), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #9300" ); + assert.equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #9441" ); + assert.equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #9441" ); + assert.equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #9441" ); + assert.equal( $divUnconnected.outerWidth( true ), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #9300" ); // Support: IE 10-11, Edge // Child height is not always decimal - equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #9441" ); - equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #9441" ); - equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #9441" ); - equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #9300" ); + assert.equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #9441" ); + assert.equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #9441" ); + assert.equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #9441" ); + assert.equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #9300" ); // teardown html $divHiddenParent.remove(); $divNormal.remove(); } ); -test( "getting dimensions shouldn't modify runtimeStyle see #9233", function() { - expect( 1 ); +QUnit.test( "getting dimensions shouldn't modify runtimeStyle see #9233", function( assert ) { + assert.expect( 1 ); var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ), div = $div.get( 0 ), @@ -298,16 +298,16 @@ test( "getting dimensions shouldn't modify runtimeStyle see #9233", function() { $div.outerWidth( true ); if ( runtimeStyle ) { - equal( div.runtimeStyle.left, "11em", "getting dimensions modifies runtimeStyle, see #9233" ); + assert.equal( div.runtimeStyle.left, "11em", "getting dimensions modifies runtimeStyle, see #9233" ); } else { - ok( true, "this browser doesn't support runtimeStyle, see #9233" ); + assert.ok( true, "this browser doesn't support runtimeStyle, see #9233" ); } $div.remove(); } ); -test( "table dimensions", function() { - expect( 2 ); +QUnit.test( "table dimensions", function( assert ) { + assert.expect( 2 ); var table = jQuery( "<table><colgroup><col/><col/></colgroup><tbody><tr><td></td><td>a</td></tr><tr><td></td><td>a</td></tr></tbody></table>" ).appendTo( "#qunit-fixture" ), tdElem = table.find( "td" ).first(), @@ -315,12 +315,12 @@ test( "table dimensions", function() { table.find( "td" ).css( { "margin": 0, "padding": 0 } ); - equal( tdElem.width(), tdElem.width(), "width() doesn't alter dimension values of empty cells, see #11293" ); - equal( colElem.width(), 300, "col elements have width(), see #12243" ); + assert.equal( tdElem.width(), tdElem.width(), "width() doesn't alter dimension values of empty cells, see #11293" ); + assert.equal( colElem.width(), 300, "col elements have width(), see #12243" ); } ); -test( "box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413", function() { - expect( 16 ); +QUnit.test( "box-sizing:border-box child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #10413", function( assert ) { + assert.expect( 16 ); // setup html var $divNormal = jQuery( "<div>" ).css( { "boxSizing": "border-box", "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" } ), @@ -330,61 +330,61 @@ test( "box-sizing:border-box child of a hidden elem (or unconnected node) has ac $divNormal.appendTo( "body" ); // tests that child div of a hidden div works the same as a normal div - equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #10413" ); - equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #10413" ); - equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #10413" ); - equal( $divChild.outerWidth( true ), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #10413" ); + assert.equal( $divChild.width(), $divNormal.width(), "child of a hidden element width() is wrong see #10413" ); + assert.equal( $divChild.innerWidth(), $divNormal.innerWidth(), "child of a hidden element innerWidth() is wrong see #10413" ); + assert.equal( $divChild.outerWidth(), $divNormal.outerWidth(), "child of a hidden element outerWidth() is wrong see #10413" ); + assert.equal( $divChild.outerWidth( true ), $divNormal.outerWidth( true ), "child of a hidden element outerWidth( true ) is wrong see #10413" ); // Support: IE 10-11, Edge // Child height is not always decimal - equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #10413" ); - equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #10413" ); - equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #10413" ); - equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #10413" ); + assert.equal( $divChild.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "child of a hidden element height() is wrong see #10413" ); + assert.equal( $divChild.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "child of a hidden element innerHeight() is wrong see #10413" ); + assert.equal( $divChild.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "child of a hidden element outerHeight() is wrong see #10413" ); + assert.equal( $divChild.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "child of a hidden element outerHeight( true ) is wrong see #10413" ); // tests that child div of an unconnected div works the same as a normal div - equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #10413" ); - equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #10413" ); - equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #10413" ); - equal( $divUnconnected.outerWidth( true ), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #10413" ); + assert.equal( $divUnconnected.width(), $divNormal.width(), "unconnected element width() is wrong see #10413" ); + assert.equal( $divUnconnected.innerWidth(), $divNormal.innerWidth(), "unconnected element innerWidth() is wrong see #10413" ); + assert.equal( $divUnconnected.outerWidth(), $divNormal.outerWidth(), "unconnected element outerWidth() is wrong see #10413" ); + assert.equal( $divUnconnected.outerWidth( true ), $divNormal.outerWidth( true ), "unconnected element outerWidth( true ) is wrong see #10413" ); // Support: IE 10-11, Edge // Child height is not always decimal - equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #10413" ); - equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #10413" ); - equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #10413" ); - equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #10413" ); + assert.equal( $divUnconnected.height().toFixed( 3 ), $divNormal.height().toFixed( 3 ), "unconnected element height() is wrong see #10413" ); + assert.equal( $divUnconnected.innerHeight().toFixed( 3 ), $divNormal.innerHeight().toFixed( 3 ), "unconnected element innerHeight() is wrong see #10413" ); + assert.equal( $divUnconnected.outerHeight().toFixed( 3 ), $divNormal.outerHeight().toFixed( 3 ), "unconnected element outerHeight() is wrong see #10413" ); + assert.equal( $divUnconnected.outerHeight( true ).toFixed( 3 ), $divNormal.outerHeight( true ).toFixed( 3 ), "unconnected element outerHeight( true ) is wrong see #10413" ); // teardown html $divHiddenParent.remove(); $divNormal.remove(); } ); -test( "outerHeight()", function() { - expect( 11 ); +QUnit.test( "outerHeight()", function( assert ) { + assert.expect( 11 ); var $div, div, $win = jQuery( window ), $doc = jQuery( document ); - equal( jQuery( window ).outerHeight(), $win.height(), "Test on window without margin option" ); - equal( jQuery( window ).outerHeight( true ), $win.height(), "Test on window with margin option" ); - equal( jQuery( document ).outerHeight(), $doc.height(), "Test on document without margin option" ); - equal( jQuery( document ).outerHeight( true ), $doc.height(), "Test on document with margin option" ); + assert.equal( jQuery( window ).outerHeight(), $win.height(), "Test on window without margin option" ); + assert.equal( jQuery( window ).outerHeight( true ), $win.height(), "Test on window with margin option" ); + assert.equal( jQuery( document ).outerHeight(), $doc.height(), "Test on document without margin option" ); + assert.equal( jQuery( document ).outerHeight( true ), $doc.height(), "Test on document with margin option" ); $div = jQuery( "#nothiddendiv" ); $div.css( "height", 30 ); - equal( $div.outerHeight(), 30, "Test with only width set" ); + assert.equal( $div.outerHeight(), 30, "Test with only width set" ); $div.css( "padding", "20px" ); - equal( $div.outerHeight(), 70, "Test with padding" ); + assert.equal( $div.outerHeight(), 70, "Test with padding" ); $div.css( "border", "2px solid #fff" ); - equal( $div.outerHeight(), 74, "Test with padding and border" ); + assert.equal( $div.outerHeight(), 74, "Test with padding and border" ); $div.css( "margin", "10px" ); - equal( $div.outerHeight(), 74, "Test with padding, border and margin without margin option" ); - equal( $div.outerHeight( true ), 94, "Test with padding, border and margin with margin option" ); + assert.equal( $div.outerHeight(), 74, "Test with padding, border and margin without margin option" ); + assert.equal( $div.outerHeight( true ), 94, "Test with padding, border and margin with margin option" ); $div.hide(); - equal( $div.outerHeight( true ), 94, "Test hidden div with padding, border and margin with margin option" ); + assert.equal( $div.outerHeight( true ), 94, "Test hidden div with padding, border and margin with margin option" ); // reset styles $div.css( { "display": "", "border": "", "padding": "", "width": "", "height": "" } ); @@ -392,95 +392,103 @@ test( "outerHeight()", function() { div = jQuery( "<div>" ); // Temporarily require 0 for backwards compat - should be auto - equal( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." ); + assert.equal( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." ); div.remove(); QUnit.expectJqData( this, $div[ 0 ], "display" ); } ); -test( "passing undefined is a setter #5571", function() { - expect( 4 ); - equal( jQuery( "#nothiddendiv" ).height( 30 ).height( undefined ).height(), 30, ".height(undefined) is chainable (#5571)" ); - equal( jQuery( "#nothiddendiv" ).height( 30 ).innerHeight( undefined ).height(), 30, ".innerHeight(undefined) is chainable (#5571)" ); - equal( jQuery( "#nothiddendiv" ).height( 30 ).outerHeight( undefined ).height(), 30, ".outerHeight(undefined) is chainable (#5571)" ); - equal( jQuery( "#nothiddendiv" ).width( 30 ).width( undefined ).width(), 30, ".width(undefined) is chainable (#5571)" ); +QUnit.test( "passing undefined is a setter #5571", function( assert ) { + assert.expect( 4 ); + assert.equal( jQuery( "#nothiddendiv" ).height( 30 ).height( undefined ).height(), 30, ".height(undefined) is chainable (#5571)" ); + assert.equal( jQuery( "#nothiddendiv" ).height( 30 ).innerHeight( undefined ).height(), 30, ".innerHeight(undefined) is chainable (#5571)" ); + assert.equal( jQuery( "#nothiddendiv" ).height( 30 ).outerHeight( undefined ).height(), 30, ".outerHeight(undefined) is chainable (#5571)" ); + assert.equal( jQuery( "#nothiddendiv" ).width( 30 ).width( undefined ).width(), 30, ".width(undefined) is chainable (#5571)" ); } ); -test( "getters on non elements should return null", function() { - expect( 8 ); +QUnit.test( "getters on non elements should return null", function( assert ) { + assert.expect( 8 ); var nonElem = jQuery( "notAnElement" ); - strictEqual( nonElem.width(), null, ".width() is not null (#12283)" ); - strictEqual( nonElem.innerWidth(), null, ".innerWidth() is not null (#12283)" ); - strictEqual( nonElem.outerWidth(), null, ".outerWidth() is not null (#12283)" ); - strictEqual( nonElem.outerWidth( true ), null, ".outerWidth(true) is not null (#12283)" ); + assert.strictEqual( nonElem.width(), null, ".width() is not null (#12283)" ); + assert.strictEqual( nonElem.innerWidth(), null, ".innerWidth() is not null (#12283)" ); + assert.strictEqual( nonElem.outerWidth(), null, ".outerWidth() is not null (#12283)" ); + assert.strictEqual( nonElem.outerWidth( true ), null, ".outerWidth(true) is not null (#12283)" ); - strictEqual( nonElem.height(), null, ".height() is not null (#12283)" ); - strictEqual( nonElem.innerHeight(), null, ".innerHeight() is not null (#12283)" ); - strictEqual( nonElem.outerHeight(), null, ".outerHeight() is not null (#12283)" ); - strictEqual( nonElem.outerHeight( true ), null, ".outerHeight(true) is not null (#12283)" ); + assert.strictEqual( nonElem.height(), null, ".height() is not null (#12283)" ); + assert.strictEqual( nonElem.innerHeight(), null, ".innerHeight() is not null (#12283)" ); + assert.strictEqual( nonElem.outerHeight(), null, ".outerHeight() is not null (#12283)" ); + assert.strictEqual( nonElem.outerHeight( true ), null, ".outerHeight(true) is not null (#12283)" ); } ); -test( "setters with and without box-sizing:border-box", function() { - expect( 20 ); +QUnit.test( "setters with and without box-sizing:border-box", function( assert ) { + assert.expect( 20 ); // Support: Android 2.3 (-webkit-box-sizing). var el_bb = jQuery( "<div style='width:114px;height:114px;margin:5px;padding:3px;border:4px solid white;-webkit-box-sizing:border-box;box-sizing:border-box;'>test</div>" ).appendTo( "#qunit-fixture" ), el = jQuery( "<div style='width:100px;height:100px;margin:5px;padding:3px;border:4px solid white;'>test</div>" ).appendTo( "#qunit-fixture" ), expected = 100; - equal( el_bb.width( 101 ).width(), expected + 1, "test border-box width(int) by roundtripping" ); - equal( el_bb.innerWidth( 108 ).width(), expected + 2, "test border-box innerWidth(int) by roundtripping" ); - equal( el_bb.outerWidth( 117 ).width(), expected + 3, "test border-box outerWidth(int) by roundtripping" ); - equal( el_bb.outerWidth( 118, false ).width(), expected + 4, "test border-box outerWidth(int, false) by roundtripping" ); - equal( el_bb.outerWidth( 129, true ).width(), expected + 5, "test border-box innerWidth(int, true) by roundtripping" ); - - equal( el_bb.height( 101 ).height(), expected + 1, "test border-box height(int) by roundtripping" ); - equal( el_bb.innerHeight( 108 ).height(), expected + 2, "test border-box innerHeight(int) by roundtripping" ); - equal( el_bb.outerHeight( 117 ).height(), expected + 3, "test border-box outerHeight(int) by roundtripping" ); - equal( el_bb.outerHeight( 118, false ).height(), expected + 4, "test border-box outerHeight(int, false) by roundtripping" ); - equal( el_bb.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" ); - - equal( el.width( 101 ).width(), expected + 1, "test border-box width(int) by roundtripping" ); - equal( el.innerWidth( 108 ).width(), expected + 2, "test border-box innerWidth(int) by roundtripping" ); - equal( el.outerWidth( 117 ).width(), expected + 3, "test border-box outerWidth(int) by roundtripping" ); - equal( el.outerWidth( 118, false ).width(), expected + 4, "test border-box outerWidth(int, false) by roundtripping" ); - equal( el.outerWidth( 129, true ).width(), expected + 5, "test border-box innerWidth(int, true) by roundtripping" ); - - equal( el.height( 101 ).height(), expected + 1, "test border-box height(int) by roundtripping" ); - equal( el.innerHeight( 108 ).height(), expected + 2, "test border-box innerHeight(int) by roundtripping" ); - equal( el.outerHeight( 117 ).height(), expected + 3, "test border-box outerHeight(int) by roundtripping" ); - equal( el.outerHeight( 118, false ).height(), expected + 4, "test border-box outerHeight(int, false) by roundtripping" ); - equal( el.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" ); + assert.equal( el_bb.width( 101 ).width(), expected + 1, "test border-box width(int) by roundtripping" ); + assert.equal( el_bb.innerWidth( 108 ).width(), expected + 2, "test border-box innerWidth(int) by roundtripping" ); + assert.equal( el_bb.outerWidth( 117 ).width(), expected + 3, "test border-box outerWidth(int) by roundtripping" ); + assert.equal( el_bb.outerWidth( 118, false ).width(), expected + 4, "test border-box outerWidth(int, false) by roundtripping" ); + assert.equal( el_bb.outerWidth( 129, true ).width(), expected + 5, "test border-box innerWidth(int, true) by roundtripping" ); + + assert.equal( el_bb.height( 101 ).height(), expected + 1, "test border-box height(int) by roundtripping" ); + assert.equal( el_bb.innerHeight( 108 ).height(), expected + 2, "test border-box innerHeight(int) by roundtripping" ); + assert.equal( el_bb.outerHeight( 117 ).height(), expected + 3, "test border-box outerHeight(int) by roundtripping" ); + assert.equal( el_bb.outerHeight( 118, false ).height(), expected + 4, "test border-box outerHeight(int, false) by roundtripping" ); + assert.equal( el_bb.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" ); + + assert.equal( el.width( 101 ).width(), expected + 1, "test border-box width(int) by roundtripping" ); + assert.equal( el.innerWidth( 108 ).width(), expected + 2, "test border-box innerWidth(int) by roundtripping" ); + assert.equal( el.outerWidth( 117 ).width(), expected + 3, "test border-box outerWidth(int) by roundtripping" ); + assert.equal( el.outerWidth( 118, false ).width(), expected + 4, "test border-box outerWidth(int, false) by roundtripping" ); + assert.equal( el.outerWidth( 129, true ).width(), expected + 5, "test border-box innerWidth(int, true) by roundtripping" ); + + assert.equal( el.height( 101 ).height(), expected + 1, "test border-box height(int) by roundtripping" ); + assert.equal( el.innerHeight( 108 ).height(), expected + 2, "test border-box innerHeight(int) by roundtripping" ); + assert.equal( el.outerHeight( 117 ).height(), expected + 3, "test border-box outerHeight(int) by roundtripping" ); + assert.equal( el.outerHeight( 118, false ).height(), expected + 4, "test border-box outerHeight(int, false) by roundtripping" ); + assert.equal( el.outerHeight( 129, true ).height(), expected + 5, "test border-box innerHeight(int, true) by roundtripping" ); } ); -testIframe( "dimensions/documentSmall", "window vs. small document", function( jQuery, window, document ) { +testIframe( + "dimensions/documentSmall", + "window vs. small document", + function( jQuery, window, document, assert ) { - // this test is practically tautological, but there is a bug in IE8 - // with no simple workaround, so this test exposes the bug and works around it - if ( document.body.offsetWidth >= document.documentElement.offsetWidth ) { - expect( 2 ); + // this test is practically tautological, but there is a bug in IE8 + // with no simple workaround, so this test exposes the bug and works around it + if ( document.body.offsetWidth >= document.documentElement.offsetWidth ) { + assert.expect( 2 ); - equal( jQuery( document ).height(), jQuery( window ).height(), "document height matches window height" ); - equal( jQuery( document ).width(), jQuery( window ).width(), "document width matches window width" ); - } else { + assert.equal( jQuery( document ).height(), jQuery( window ).height(), "document height matches window height" ); + assert.equal( jQuery( document ).width(), jQuery( window ).width(), "document width matches window width" ); + } else { - // all tests should have at least one assertion - expect( 1 ); - ok( true, "skipping test (conditions not satisfied)" ); + // all tests should have at least one assertion + assert.expect( 1 ); + assert.ok( true, "skipping test (conditions not satisfied)" ); + } } -} ); +); -testIframe( "dimensions/documentLarge", "window vs. large document", function( jQuery, window, document ) { - expect( 2 ); +testIframe( + "dimensions/documentLarge", + "window vs. large document", + function( jQuery, window, document, assert ) { + assert.expect( 2 ); - ok( jQuery( document ).height() > jQuery( window ).height(), "document height is larger than window height" ); - ok( jQuery( document ).width() > jQuery( window ).width(), "document width is larger than window width" ); -} ); + assert.ok( jQuery( document ).height() > jQuery( window ).height(), "document height is larger than window height" ); + assert.ok( jQuery( document ).width() > jQuery( window ).width(), "document width is larger than window width" ); + } +); -test( "allow modification of coordinates argument (gh-1848)", function() { - expect( 1 ); +QUnit.test( "allow modification of coordinates argument (gh-1848)", function( assert ) { + assert.expect( 1 ); var offsetTop, element = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ); @@ -492,7 +500,7 @@ test( "allow modification of coordinates argument (gh-1848)", function() { } ); offsetTop = element.offset().top; - ok( Math.abs( offsetTop - 100 ) < 0.02, + assert.ok( Math.abs( offsetTop - 100 ) < 0.02, "coordinates are modified (got offset.top: " + offsetTop + ")" ); } ); diff --git a/test/unit/effects.js b/test/unit/effects.js index f4bd9c145..31822274c 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -7,7 +7,7 @@ if ( !jQuery.fx ) { var oldRaf = window.requestAnimationFrame; -module( "effects", { +QUnit.module( "effects", { setup: function() { window.requestAnimationFrame = null; this.sandbox = sinon.sandbox.create(); @@ -25,36 +25,36 @@ module( "effects", { } } ); -test( "sanity check", function() { - expect( 1 ); - equal( jQuery( "#dl:visible, #qunit-fixture:visible, #foo:visible" ).length, 3, "QUnit state is correct for testing effects" ); +QUnit.test( "sanity check", function( assert ) { + assert.expect( 1 ); + assert.equal( jQuery( "#dl:visible, #qunit-fixture:visible, #foo:visible" ).length, 3, "QUnit state is correct for testing effects" ); } ); -test( "show() basic", function() { - expect( 1 ); +QUnit.test( "show() basic", function( assert ) { + assert.expect( 1 ); var div = jQuery( "<div>" ).hide().appendTo( "#qunit-fixture" ).show(); - equal( div.css( "display" ), "block", "Make sure pre-hidden divs show" ); + assert.equal( div.css( "display" ), "block", "Make sure pre-hidden divs show" ); // Clean up the detached node div.remove(); } ); -test( "show()", function() { - expect( 27 ); +QUnit.test( "show()", function( assert ) { + assert.expect( 27 ); var div, speeds, test, displaysActual, displaysExpected, hiddendiv = jQuery( "div.hidden" ); - equal( jQuery.css( hiddendiv[ 0 ], "display" ), "none", "hiddendiv is display: none" ); + assert.equal( jQuery.css( hiddendiv[ 0 ], "display" ), "none", "hiddendiv is display: none" ); hiddendiv.css( "display", "block" ); - equal( jQuery.css( hiddendiv[ 0 ], "display" ), "block", "hiddendiv is display: block" ); + assert.equal( jQuery.css( hiddendiv[ 0 ], "display" ), "block", "hiddendiv is display: block" ); hiddendiv.show(); - equal( jQuery.css( hiddendiv[ 0 ], "display" ), "block", "hiddendiv is display: block" ); + assert.equal( jQuery.css( hiddendiv[ 0 ], "display" ), "block", "hiddendiv is display: block" ); hiddendiv.css( "display", "" ); @@ -63,7 +63,7 @@ test( "show()", function() { div = jQuery( "#fx-queue div" ).slice( 0, 4 ); div.show().each( function() { - notEqual( this.style.display, "none", "don't change any <div> with display block" ); + assert.notEqual( this.style.display, "none", "don't change any <div> with display block" ); } ); speeds = { @@ -79,7 +79,7 @@ test( "show()", function() { pass = false; } } ); - ok( pass, "Show with " + name ); + assert.ok( pass, "Show with " + name ); } ); jQuery.each( speeds, function( name, speed ) { @@ -87,7 +87,7 @@ test( "show()", function() { div.hide().show( speed, function() { pass = false; } ); - ok( pass, "Show with " + name + " does not call animate callback" ); + assert.ok( pass, "Show with " + name + " does not call animate callback" ); } ); // Tolerate data from show()/hide() @@ -122,7 +122,7 @@ test( "show()", function() { jQuery.each( test, function( selector, expected ) { var elem = jQuery( selector, "#show-tests" ).show(); - equal( elem.css( "display" ), expected, "Show using correct display type for " + selector ); + assert.equal( elem.css( "display" ), expected, "Show using correct display type for " + selector ); } ); jQuery( "#show-tests" ).remove(); @@ -132,8 +132,8 @@ test( "show()", function() { jQuery( "<div>test</div> text <span>test</span>" ).hide().remove(); } ); -test( "show(Number) - other displays", function() { - expect( 30 ); +QUnit.test( "show(Number) - other displays", function( assert ) { + assert.expect( 30 ); jQuery( "<div id='show-tests'>" + @@ -174,7 +174,7 @@ test( "show(Number) - other displays", function() { this.clock.tick( 50 ); jQuery.each( test, function( selector, expected ) { jQuery( selector, "#show-tests" ).each( function() { - equal( + assert.equal( jQuery( this ).css( "display" ), expected === "inline" ? "inline-block" : expected, "Correct display type during animation for " + selector @@ -184,7 +184,7 @@ test( "show(Number) - other displays", function() { this.clock.tick( 50 ); jQuery.each( test, function( selector, expected ) { jQuery( selector, "#show-tests" ).each( function() { - equal( jQuery( this ).css( "display" ), expected, + assert.equal( jQuery( this ).css( "display" ), expected, "Correct display type after animation for " + selector ); } ); } ); @@ -193,8 +193,8 @@ test( "show(Number) - other displays", function() { } ); // Supports #7397 -test( "Persist correct display value", function() { - expect( 3 ); +QUnit.test( "Persist correct display value", function( assert ) { + assert.expect( 3 ); jQuery( "<div id='show-tests'><span style='position:absolute;'>foo</span></div>" ) .appendTo( "#qunit-fixture" ).find( "*" ).css( "display", "none" ); @@ -211,11 +211,11 @@ test( "Persist correct display value", function() { $span.hide(); $span.fadeIn( 100, function() { - equal( $span.css( "display" ), display, "Expecting display: " + display ); + assert.equal( $span.css( "display" ), display, "Expecting display: " + display ); $span.fadeOut( 100, function() { - equal( $span.css( "display" ), displayNone, "Expecting display: " + displayNone ); + assert.equal( $span.css( "display" ), displayNone, "Expecting display: " + displayNone ); $span.fadeIn( 100, function() { - equal( $span.css( "display" ), display, "Expecting display: " + display ); + assert.equal( $span.css( "display" ), display, "Expecting display: " + display ); } ); } ); } ); @@ -225,16 +225,16 @@ test( "Persist correct display value", function() { QUnit.expectJqData( this, $span, "display" ); } ); -test( "animate(Hash, Object, Function)", function() { - expect( 1 ); +QUnit.test( "animate(Hash, Object, Function)", function( assert ) { + assert.expect( 1 ); var hash = { opacity: "show" }, hashCopy = jQuery.extend( {}, hash ); jQuery( "#foo" ).animate( hash, 0, function() { - equal( hash.opacity, hashCopy.opacity, "Check if animate changed the hash parameter" ); + assert.equal( hash.opacity, hashCopy.opacity, "Check if animate changed the hash parameter" ); } ); } ); -test( "animate relative values", function() { +QUnit.test( "animate relative values", function( assert ) { var value = 40, clock = this.clock, @@ -244,7 +244,7 @@ test( "animate relative values", function() { .css( { position: "absolute", height: "50em", width: "50em" } ), animations = bases.length * adjustments.length; - expect( 2 * animations ); + assert.expect( 2 * animations ); jQuery.each( bases, function( _, baseUnit ) { jQuery.each( adjustments, function( _, adjustUnit ) { @@ -261,9 +261,9 @@ test( "animate relative values", function() { adjustScale = elem[ 0 ].offsetWidth / value; elem.css( "width", base ).animate( adjust, 100, function() { - equal( this.offsetHeight, value * baseScale + 2 * adjustScale, + assert.equal( this.offsetHeight, value * baseScale + 2 * adjustScale, baseUnit + "+=" + adjustUnit ); - equal( this.offsetWidth, value * baseScale - 2 * adjustScale, + assert.equal( this.offsetWidth, value * baseScale - 2 * adjustScale, baseUnit + "-=" + adjustUnit ); } ); @@ -273,56 +273,56 @@ test( "animate relative values", function() { } ); } ); -test( "animate negative height", function() { - expect( 1 ); +QUnit.test( "animate negative height", function( assert ) { + assert.expect( 1 ); jQuery( "#foo" ).animate( { height: -100 }, 100, function() { - equal( this.offsetHeight, 0, "Verify height." ); + assert.equal( this.offsetHeight, 0, "Verify height." ); } ); this.clock.tick( 100 ); } ); -test( "animate negative margin", function() { - expect( 1 ); +QUnit.test( "animate negative margin", function( assert ) { + assert.expect( 1 ); jQuery( "#foo" ).animate( { "marginTop": -100 }, 100, function() { - equal( jQuery( this ).css( "marginTop" ), "-100px", "Verify margin." ); + assert.equal( jQuery( this ).css( "marginTop" ), "-100px", "Verify margin." ); } ); this.clock.tick( 100 ); } ); -test( "animate negative margin with px", function() { - expect( 1 ); +QUnit.test( "animate negative margin with px", function( assert ) { + assert.expect( 1 ); jQuery( "#foo" ).animate( { marginTop: "-100px" }, 100, function() { - equal( jQuery( this ).css( "marginTop" ), "-100px", "Verify margin." ); + assert.equal( jQuery( this ).css( "marginTop" ), "-100px", "Verify margin." ); } ); this.clock.tick( 100 ); } ); -test( "animate negative padding", function() { - expect( 1 ); +QUnit.test( "animate negative padding", function( assert ) { + assert.expect( 1 ); jQuery( "#foo" ).animate( { "paddingBottom": -100 }, 100, function() { - equal( jQuery( this ).css( "paddingBottom" ), "0px", "Verify paddingBottom." ); + assert.equal( jQuery( this ).css( "paddingBottom" ), "0px", "Verify paddingBottom." ); } ); this.clock.tick( 100 ); } ); -test( "animate block as inline width/height", function() { - expect( 3 ); +QUnit.test( "animate block as inline width/height", function( assert ) { + assert.expect( 3 ); var span = jQuery( "<span>" ).css( "display", "inline-block" ).appendTo( "body" ); span.remove(); jQuery( "#foo" ).css( { display: "inline", width: "", height: "" } ).animate( { width: 42, height: 42 }, 100, function() { - equal( jQuery( this ).css( "display" ), "inline-block", "inline-block was set on non-floated inline element when animating width/height" ); - equal( this.offsetWidth, 42, "width was animated" ); - equal( this.offsetHeight, 42, "height was animated" ); + assert.equal( jQuery( this ).css( "display" ), "inline-block", "inline-block was set on non-floated inline element when animating width/height" ); + assert.equal( this.offsetWidth, 42, "width was animated" ); + assert.equal( this.offsetHeight, 42, "height was animated" ); } ); this.clock.tick( 100 ); } ); -test( "animate native inline width/height", function() { - expect( 3 ); +QUnit.test( "animate native inline width/height", function( assert ) { + assert.expect( 3 ); var span = jQuery( "<span>" ).css( "display", "inline-block" ).appendTo( "body" ); @@ -332,16 +332,16 @@ test( "animate native inline width/height", function() { .append( "<span>text</span>" ) .children( "span" ) .animate( { width: 42, height: 42 }, 100, function() { - equal( jQuery( this ).css( "display" ), "inline-block", "inline-block was set on non-floated inline element when animating width/height" ); - equal( this.offsetWidth, 42, "width was animated" ); - equal( this.offsetHeight, 42, "height was animated" ); + assert.equal( jQuery( this ).css( "display" ), "inline-block", "inline-block was set on non-floated inline element when animating width/height" ); + assert.equal( this.offsetWidth, 42, "width was animated" ); + assert.equal( this.offsetHeight, 42, "height was animated" ); } ); this.clock.tick( 100 ); } ); -test( "animate block width/height", function() { - expect( 3 ); +QUnit.test( "animate block width/height", function( assert ) { + assert.expect( 3 ); jQuery( "<div>" ).appendTo( "#qunit-fixture" ).css( { display: "block", @@ -355,44 +355,44 @@ test( "animate block width/height", function() { duration: 100, step: function() { if ( jQuery( this ).width() > 42 ) { - ok( false, "width was incorrectly augmented during animation" ); + assert.ok( false, "width was incorrectly augmented during animation" ); } }, complete: function() { - equal( jQuery( this ).css( "display" ), "block", "inline-block was not set on block element when animating width/height" ); - equal( jQuery( this ).width(), 42, "width was animated" ); - equal( jQuery( this ).height(), 42, "height was animated" ); + assert.equal( jQuery( this ).css( "display" ), "block", "inline-block was not set on block element when animating width/height" ); + assert.equal( jQuery( this ).width(), 42, "width was animated" ); + assert.equal( jQuery( this ).height(), 42, "height was animated" ); } } ); this.clock.tick( 100 ); } ); -test( "animate table width/height", function() { - expect( 1 ); +QUnit.test( "animate table width/height", function( assert ) { + assert.expect( 1 ); jQuery( "#table" ).animate( { width: 42, height: 42 }, 100, function() { - equal( jQuery( this ).css( "display" ), "table", "display mode is correct" ); + assert.equal( jQuery( this ).css( "display" ), "table", "display mode is correct" ); } ); this.clock.tick( 100 ); } ); -test( "animate table-row width/height", function() { - expect( 3 ); +QUnit.test( "animate table-row width/height", function( assert ) { + assert.expect( 3 ); var tr = jQuery( "#table" ) .attr( { "cellspacing": 0, "cellpadding": 0, "border": 0 } ) .html( "<tr style='height:42px;'><td style='padding:0;'><div style='width:20px;height:20px;'></div></td></tr>" ) .find( "tr" ); tr.animate( { width: 10, height: 10 }, 100, function() { - equal( jQuery( this ).css( "display" ), "table-row", "display mode is correct" ); - equal( this.offsetWidth, 20, "width animated to shrink wrap point" ); - equal( this.offsetHeight, 20, "height animated to shrink wrap point" ); + assert.equal( jQuery( this ).css( "display" ), "table-row", "display mode is correct" ); + assert.equal( this.offsetWidth, 20, "width animated to shrink wrap point" ); + assert.equal( this.offsetHeight, 20, "height animated to shrink wrap point" ); } ); this.clock.tick( 100 ); } ); -test( "animate table-cell width/height", function() { - expect( 3 ); +QUnit.test( "animate table-cell width/height", function( assert ) { + assert.expect( 3 ); var td = jQuery( "#table" ) .attr( { "cellspacing": 0, "cellpadding": 0, "border": 0 } ) @@ -400,42 +400,42 @@ test( "animate table-cell width/height", function() { .find( "td" ); td.animate( { width: 10, height: 10 }, 100, function() { - equal( jQuery( this ).css( "display" ), "table-cell", "display mode is correct" ); - equal( this.offsetWidth, 20, "width animated to shrink wrap point" ); - equal( this.offsetHeight, 20, "height animated to shrink wrap point" ); + assert.equal( jQuery( this ).css( "display" ), "table-cell", "display mode is correct" ); + assert.equal( this.offsetWidth, 20, "width animated to shrink wrap point" ); + assert.equal( this.offsetHeight, 20, "height animated to shrink wrap point" ); } ); this.clock.tick( 100 ); } ); -test( "animate percentage(%) on width/height", function() { - expect( 2 ); +QUnit.test( "animate percentage(%) on width/height", function( assert ) { + assert.expect( 2 ); var $div = jQuery( "<div style='position:absolute;top:-999px;left:-999px;width:60px;height:60px;'><div style='width:50%;height:50%;'></div></div>" ) .appendTo( "#qunit-fixture" ).children( "div" ); $div.animate( { width: "25%", height: "25%" }, 13, function() { var $this = jQuery( this ); - equal( $this.css( "width" ), "15px", "Width was animated to 15px rather than 25px" ); - equal( $this.css( "height" ), "15px", "Height was animated to 15px rather than 25px" ); + assert.equal( $this.css( "width" ), "15px", "Width was animated to 15px rather than 25px" ); + assert.equal( $this.css( "height" ), "15px", "Height was animated to 15px rather than 25px" ); } ); this.clock.tick( 20 ); } ); -test( "animate resets overflow-x and overflow-y when finished", function() { - expect( 2 ); +QUnit.test( "animate resets overflow-x and overflow-y when finished", function( assert ) { + assert.expect( 2 ); jQuery( "#foo" ) .css( { display: "block", width: 20, height: 20, overflowX: "visible", overflowY: "auto" } ) .animate( { width: 42, height: 42 }, 100, function() { - equal( this.style.overflowX, "visible", "overflow-x is visible" ); - equal( this.style.overflowY, "auto", "overflow-y is auto" ); + assert.equal( this.style.overflowX, "visible", "overflow-x is visible" ); + assert.equal( this.style.overflowY, "auto", "overflow-y is auto" ); } ); this.clock.tick( 100 ); } ); /* // This test ends up being flaky depending upon the CPU load -test("animate option (queue === false)", function () { - expect(1); - stop(); +QUnit.test("animate option (queue === false)", function( assert ) { + assert.expect(1); + QUnit.stop(); var order = []; @@ -443,8 +443,8 @@ test("animate option (queue === false)", function () { $foo.animate({width:"100px"}, 3000, function () { // should finish after unqueued animation so second order.push(2); - deepEqual( order, [ 1, 2 ], "Animations finished in the correct order" ); - start(); + assert.deepEqual( order, [ 1, 2 ], "Animations finished in the correct order" ); + QUnit.start(); }); $foo.animate({fontSize:"2em"}, {queue:false, duration:10, complete:function () { // short duration and out of queue so should finish first @@ -453,8 +453,8 @@ test("animate option (queue === false)", function () { }); */ -test( "animate option { queue: false }", function() { - expect( 2 ); +QUnit.test( "animate option { queue: false }", function( assert ) { + assert.expect( 2 ); var foo = jQuery( "#foo" ); foo.animate( { @@ -463,16 +463,16 @@ test( "animate option { queue: false }", function() { queue: false, duration: 10, complete: function() { - ok( true, "Animation Completed" ); + assert.ok( true, "Animation Completed" ); } } ); this.clock.tick( 10 ); - equal( foo.queue().length, 0, "Queue is empty" ); + assert.equal( foo.queue().length, 0, "Queue is empty" ); } ); -test( "animate option { queue: true }", function() { - expect( 2 ); +QUnit.test( "animate option { queue: true }", function( assert ) { + assert.expect( 2 ); var foo = jQuery( "#foo" ); foo.animate( { @@ -481,18 +481,18 @@ test( "animate option { queue: true }", function() { queue: true, duration: 10, complete: function() { - ok( true, "Animation Completed" ); + assert.ok( true, "Animation Completed" ); } } ); - notEqual( foo.queue().length, 0, "Default queue is not empty" ); + assert.notEqual( foo.queue().length, 0, "Default queue is not empty" ); //clear out existing timers before next test this.clock.tick( 10 ); } ); -test( "animate option { queue: 'name' }", function() { - expect( 5 ); +QUnit.test( "animate option { queue: 'name' }", function( assert ) { + assert.expect( 5 ); var foo = jQuery( "#foo" ), origWidth = parseFloat( foo.css( "width" ) ), order = []; @@ -504,27 +504,27 @@ test( "animate option { queue: 'name' }", function() { // second callback function order.push( 2 ); - equal( parseFloat( foo.css( "width" ) ), origWidth + 100, "Animation ended" ); - equal( foo.queue( "name" ).length, 1, "Queue length of 'name' queue" ); + assert.equal( parseFloat( foo.css( "width" ) ), origWidth + 100, "Animation ended" ); + assert.equal( foo.queue( "name" ).length, 1, "Queue length of 'name' queue" ); } } ).queue( "name", function() { // last callback function - deepEqual( order, [ 1, 2 ], "Callbacks in expected order" ); + assert.deepEqual( order, [ 1, 2 ], "Callbacks in expected order" ); } ); // this is the first callback function that should be called order.push( 1 ); - equal( parseFloat( foo.css( "width" ) ), origWidth, "Animation does not start on its own." ); - equal( foo.queue( "name" ).length, 2, "Queue length of 'name' queue" ); + assert.equal( parseFloat( foo.css( "width" ) ), origWidth, "Animation does not start on its own." ); + assert.equal( foo.queue( "name" ).length, 2, "Queue length of 'name' queue" ); foo.dequeue( "name" ); this.clock.tick( 10 ); } ); -test( "animate with no properties", function() { - expect( 2 ); +QUnit.test( "animate with no properties", function( assert ) { + assert.expect( 2 ); var foo, divs = jQuery( "div" ), @@ -534,74 +534,74 @@ test( "animate with no properties", function() { count++; } ); - equal( divs.length, count, "Make sure that callback is called for each element in the set." ); + assert.equal( divs.length, count, "Make sure that callback is called for each element in the set." ); foo = jQuery( "#foo" ); foo.animate( {} ); foo.animate( { top: 10 }, 100, function() { - ok( true, "Animation was properly dequeued." ); + assert.ok( true, "Animation was properly dequeued." ); } ); this.clock.tick( 100 ); } ); -test( "animate duration 0", function() { - expect( 11 ); +QUnit.test( "animate duration 0", function( assert ) { + assert.expect( 11 ); var $elem, $elems = jQuery( [ { a:0 },{ a:0 } ] ), counter = 0; - equal( jQuery.timers.length, 0, "Make sure no animation was running from another test" ); + assert.equal( jQuery.timers.length, 0, "Make sure no animation was running from another test" ); $elems.eq( 0 ).animate( { a:1 }, 0, function() { - ok( true, "Animate a simple property." ); + assert.ok( true, "Animate a simple property." ); counter++; } ); // Failed until [6115] - equal( jQuery.timers.length, 0, "Make sure synchronic animations are not left on jQuery.timers" ); + assert.equal( jQuery.timers.length, 0, "Make sure synchronic animations are not left on jQuery.timers" ); - equal( counter, 1, "One synchronic animations" ); + assert.equal( counter, 1, "One synchronic animations" ); $elems.animate( { a:2 }, 0, function() { - ok( true, "Animate a second simple property." ); + assert.ok( true, "Animate a second simple property." ); counter++; } ); - equal( counter, 3, "Multiple synchronic animations" ); + assert.equal( counter, 3, "Multiple synchronic animations" ); $elems.eq( 0 ).animate( { a:3 }, 0, function() { - ok( true, "Animate a third simple property." ); + assert.ok( true, "Animate a third simple property." ); counter++; } ); $elems.eq( 1 ).animate( { a:3 }, 200, function() { counter++; // Failed until [6115] - equal( counter, 5, "One synchronic and one asynchronic" ); + assert.equal( counter, 5, "One synchronic and one asynchronic" ); } ); this.clock.tick( 200 ); $elem = jQuery( "<div />" ); $elem.show( 0, function() { - ok( true, "Show callback with no duration" ); + assert.ok( true, "Show callback with no duration" ); } ); $elem.hide( 0, function() { - ok( true, "Hide callback with no duration" ); + assert.ok( true, "Hide callback with no duration" ); } ); // manually clean up detached elements $elem.remove(); } ); -test( "animate hyphenated properties", function() { - expect( 1 ); +QUnit.test( "animate hyphenated properties", function( assert ) { + assert.expect( 1 ); jQuery( "#foo" ) .css( "font-size", 10 ) .animate( { "font-size": 20 }, 200, function() { - equal( this.style.fontSize, "20px", "The font-size property was animated." ); + assert.equal( this.style.fontSize, "20px", "The font-size property was animated." ); } ); // FIXME why is this double only when run with other tests @@ -609,19 +609,19 @@ test( "animate hyphenated properties", function() { } ); -test( "animate non-element", function() { - expect( 1 ); +QUnit.test( "animate non-element", function( assert ) { + assert.expect( 1 ); var obj = { test: 0 }; jQuery( obj ).animate( { test: 200 }, 200, function() { - equal( obj.test, 200, "The custom property should be modified." ); + assert.equal( obj.test, 200, "The custom property should be modified." ); } ); this.clock.tick( 200 ); } ); -test( "stop()", function() { - expect( 4 ); +QUnit.test( "stop()", function( assert ) { + assert.expect( 4 ); var $one, $two, $foo = jQuery( "#foo" ), @@ -633,17 +633,17 @@ test( "stop()", function() { this.clock.tick( 100 ); nw = $foo.css( "width" ); - notEqual( parseFloat( nw ), w, "An animation occurred " + nw + " " + w + "px" ); + assert.notEqual( parseFloat( nw ), w, "An animation occurred " + nw + " " + w + "px" ); $foo.stop(); nw = $foo.css( "width" ); - notEqual( parseFloat( nw ), w, "Stop didn't reset the animation " + nw + " " + w + "px" ); + assert.notEqual( parseFloat( nw ), w, "Stop didn't reset the animation " + nw + " " + w + "px" ); this.clock.tick( 100 ); $foo.removeData(); $foo.removeData( undefined, true ); - equal( nw, $foo.css( "width" ), "The animation didn't continue" ); + assert.equal( nw, $foo.css( "width" ), "The animation didn't continue" ); $one = jQuery( "#fadein" ); $two = jQuery( "#show" ); @@ -652,7 +652,7 @@ test( "stop()", function() { } ); this.clock.tick( 100 ); $two.fadeTo( 100, 0, function() { - equal( $two.css( "opacity" ), "0", "Stop does not interfere with animations on other elements (#6641)" ); + assert.equal( $two.css( "opacity" ), "0", "Stop does not interfere with animations on other elements (#6641)" ); // Reset styles $one.add( $two ).css( "opacity", "" ); @@ -660,8 +660,8 @@ test( "stop()", function() { this.clock.tick( 100 ); } ); -test( "stop() - several in queue", function() { - expect( 5 ); +QUnit.test( "stop() - several in queue", function( assert ) { + assert.expect( 5 ); var nw, $foo = jQuery( "#foo" ); @@ -675,23 +675,23 @@ test( "stop() - several in queue", function() { this.clock.tick( 1 ); jQuery.fx.tick(); - equal( $foo.queue().length, 3, "3 in the queue" ); + assert.equal( $foo.queue().length, 3, "3 in the queue" ); nw = $foo.css( "width" ); - notEqual( parseFloat( nw ), 1, "An animation occurred " + nw ); + assert.notEqual( parseFloat( nw ), 1, "An animation occurred " + nw ); $foo.stop(); - equal( $foo.queue().length, 2, "2 in the queue" ); + assert.equal( $foo.queue().length, 2, "2 in the queue" ); nw = $foo.css( "width" ); - notEqual( parseFloat( nw ), 1, "Stop didn't reset the animation " + nw ); + assert.notEqual( parseFloat( nw ), 1, "Stop didn't reset the animation " + nw ); $foo.stop( true ); - equal( $foo.queue().length, 0, "0 in the queue" ); + assert.equal( $foo.queue().length, 0, "0 in the queue" ); } ); -test( "stop(clearQueue)", function() { - expect( 4 ); +QUnit.test( "stop(clearQueue)", function( assert ) { + assert.expect( 4 ); var $foo = jQuery( "#foo" ), w = 0, @@ -703,19 +703,19 @@ test( "stop(clearQueue)", function() { $foo.animate( { "width": "show" }, 1000 ); this.clock.tick( 100 ); nw = $foo.css( "width" ); - ok( parseFloat( nw ) !== w, "An animation occurred " + nw + " " + w + "px" ); + assert.ok( parseFloat( nw ) !== w, "An animation occurred " + nw + " " + w + "px" ); $foo.stop( true ); nw = $foo.css( "width" ); - ok( parseFloat( nw ) !== w, "Stop didn't reset the animation " + nw + " " + w + "px" ); + assert.ok( parseFloat( nw ) !== w, "Stop didn't reset the animation " + nw + " " + w + "px" ); - equal( $foo.queue().length, 0, "The animation queue was cleared" ); + assert.equal( $foo.queue().length, 0, "The animation queue was cleared" ); this.clock.tick( 100 ); - equal( nw, $foo.css( "width" ), "The animation didn't continue" ); + assert.equal( nw, $foo.css( "width" ), "The animation didn't continue" ); } ); -test( "stop(clearQueue, gotoEnd)", function() { - expect( 1 ); +QUnit.test( "stop(clearQueue, gotoEnd)", function( assert ) { + assert.expect( 1 ); var $foo = jQuery( "#foo" ), w = 0, @@ -728,7 +728,7 @@ test( "stop(clearQueue, gotoEnd)", function() { $foo.animate( { width: "hide" }, 1000 ); this.clock.tick( 100 ); nw = $foo.css( "width" ); - ok( parseFloat( nw ) !== w, "An animation occurred " + nw + " " + w + "px" ); + assert.ok( parseFloat( nw ) !== w, "An animation occurred " + nw + " " + w + "px" ); $foo.stop( false, true ); nw = $foo.css( "width" ); @@ -743,8 +743,8 @@ test( "stop(clearQueue, gotoEnd)", function() { $foo.stop( true ); } ); -test( "stop( queue, ..., ... ) - Stop single queues", function() { - expect( 3 ); +QUnit.test( "stop( queue, ..., ... ) - Stop single queues", function( assert ) { + assert.expect( 3 ); var saved, foo = jQuery( "#foo" ).css( { width: 200, height: 200 } ); @@ -753,8 +753,8 @@ test( "stop( queue, ..., ... ) - Stop single queues", function() { }, { duration: 500, complete: function() { - equal( parseFloat( foo.css( "width" ) ), 400, "Animation completed for standard queue" ); - equal( parseFloat( foo.css( "height" ) ), saved, "Height was not changed after the second stop" ); + assert.equal( parseFloat( foo.css( "width" ) ), 400, "Animation completed for standard queue" ); + assert.equal( parseFloat( foo.css( "height" ) ), saved, "Height was not changed after the second stop" ); } } ); @@ -765,7 +765,7 @@ test( "stop( queue, ..., ... ) - Stop single queues", function() { queue: "height" } ).dequeue( "height" ).stop( "height", false, true ); - equal( parseFloat( foo.css( "height" ) ), 400, "Height was stopped with gotoEnd" ); + assert.equal( parseFloat( foo.css( "height" ) ), 400, "Height was stopped with gotoEnd" ); foo.animate( { height: 200 @@ -777,25 +777,25 @@ test( "stop( queue, ..., ... ) - Stop single queues", function() { this.clock.tick( 500 ); } ); -test( "toggle()", function() { - expect( 6 ); +QUnit.test( "toggle()", function( assert ) { + assert.expect( 6 ); var x = jQuery( "#foo" ); - ok( x.is( ":visible" ), "is visible" ); + assert.ok( x.is( ":visible" ), "is visible" ); x.toggle(); - ok( x.is( ":hidden" ), "is hidden" ); + assert.ok( x.is( ":hidden" ), "is hidden" ); x.toggle(); - ok( x.is( ":visible" ), "is visible again" ); + assert.ok( x.is( ":visible" ), "is visible again" ); x.toggle( true ); - ok( x.is( ":visible" ), "is visible" ); + assert.ok( x.is( ":visible" ), "is visible" ); x.toggle( false ); - ok( x.is( ":hidden" ), "is hidden" ); + assert.ok( x.is( ":hidden" ), "is hidden" ); x.toggle( true ); - ok( x.is( ":visible" ), "is visible again" ); + assert.ok( x.is( ":visible" ), "is visible again" ); } ); -test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function() { - expect( 7 ); +QUnit.test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function( assert ) { + assert.expect( 7 ); var div = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" ).css( { color: "#ABC", @@ -804,13 +804,13 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function() { marginBottom: "-11000px" } )[ 0 ]; - equal( + assert.equal( ( new jQuery.fx( div, {}, "color" ) ).cur(), jQuery.css( div, "color" ), "Return the same value as jQuery.css for complex properties (bug #7912)" ); - strictEqual( + assert.strictEqual( ( new jQuery.fx( div, {}, "borderLeftWidth" ) ).cur(), 5, "Return simple values parsed as Float" @@ -822,12 +822,12 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function() { // value as it is being newed jQuery.cssHooks.backgroundPosition = { get: function() { - ok( true, "hook used" ); + assert.ok( true, "hook used" ); return ""; } }; - strictEqual( + assert.strictEqual( ( new jQuery.fx( div, {}, "backgroundPosition" ) ).cur(), 0, "Return 0 when jQuery.css returns an empty string" @@ -835,13 +835,13 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function() { delete jQuery.cssHooks.backgroundPosition; - strictEqual( + assert.strictEqual( ( new jQuery.fx( div, {}, "left" ) ).cur(), 0, "Return 0 when jQuery.css returns 'auto'" ); - equal( + assert.equal( ( new jQuery.fx( div, {}, "marginBottom" ) ).cur(), -11000, "support negative values < -10000 (bug #7193)" @@ -850,8 +850,8 @@ test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function() { jQuery( div ).remove(); } ); -test( "Overflow and Display", function() { - expect( 4 ); +QUnit.test( "Overflow and Display", function( assert ) { + assert.expect( 4 ); var testClass = jQuery.makeTest( "Overflow and Display" ) @@ -859,8 +859,8 @@ test( "Overflow and Display", function() { testStyle = jQuery.makeTest( "Overflow and Display (inline style)" ) .css( { overflow: "visible", display: "inline" } ), done = function() { - equal( jQuery.css( this, "overflow" ), "visible", "Overflow should be 'visible'" ); - equal( jQuery.css( this, "display" ), "inline", "Display should be 'inline'" ); + assert.equal( jQuery.css( this, "overflow" ), "visible", "Overflow should be 'visible'" ); + assert.equal( jQuery.css( this, "display" ), "inline", "Display should be 'inline'" ); }; testClass.add( testStyle ) @@ -929,7 +929,7 @@ jQuery.each( { return 0; } }, function( tn, t ) { - test( fn + " to " + tn, function() { + QUnit.test( fn + " to " + tn, function( assert ) { var num, anim, elem = jQuery.makeTest( fn + " to " + tn ), t_w = t( elem, "width" ), @@ -956,7 +956,7 @@ jQuery.each( { if ( t_w.constructor === Number ) { num += 2; } if ( t_h.constructor === Number ) { num += 2; } - expect( num ); + assert.expect( num ); anim = { width: t_w, height: t_h, opacity: t_o }; @@ -967,16 +967,16 @@ jQuery.each( { elem = $elem[ 0 ]; if ( t_w === "show" ) { - equal( $elem.css( "display" ), "block", + assert.equal( $elem.css( "display" ), "block", "Showing, display should block: " + elem.style.display ); } if ( t_w === "hide" || t_w === "show" ) { - ok( f_w === "" ? elem.style.width === f_w : elem.style.width.indexOf( f_w ) === 0, "Width must be reset to " + f_w + ": " + elem.style.width ); + assert.ok( f_w === "" ? elem.style.width === f_w : elem.style.width.indexOf( f_w ) === 0, "Width must be reset to " + f_w + ": " + elem.style.width ); } if ( t_h === "hide" || t_h === "show" ) { - ok( f_h === "" ? elem.style.height === f_h : elem.style.height.indexOf( f_h ) === 0, "Height must be reset to " + f_h + ": " + elem.style.height ); + assert.ok( f_h === "" ? elem.style.height === f_h : elem.style.height.indexOf( f_h ) === 0, "Height must be reset to " + f_h + ": " + elem.style.height ); } cur_o = jQuery.style( elem, "opacity" ); @@ -997,33 +997,33 @@ jQuery.each( { } if ( t_o === "hide" || t_o === "show" ) { - equal( cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o ); + assert.equal( cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o ); } if ( t_w === "hide" ) { - equal( elem.style.display, "none", "Hiding, display should be none: " + elem.style.display ); + assert.equal( elem.style.display, "none", "Hiding, display should be none: " + elem.style.display ); } if ( t_o.constructor === Number ) { - equal( cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o ); + assert.equal( cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o ); - ok( jQuery.css( elem, "opacity" ) !== "" || cur_o === t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o ); + assert.ok( jQuery.css( elem, "opacity" ) !== "" || cur_o === t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o ); } if ( t_w.constructor === Number ) { - equal( elem.style.width, t_w + "px", "Final width should be " + t_w + ": " + elem.style.width ); + assert.equal( elem.style.width, t_w + "px", "Final width should be " + t_w + ": " + elem.style.width ); cur_w = jQuery.css( elem, "width" ); - ok( elem.style.width !== "" || cur_w === t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w ); + assert.ok( elem.style.width !== "" || cur_w === t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w ); } if ( t_h.constructor === Number ) { - equal( elem.style.height, t_h + "px", "Final height should be " + t_h + ": " + elem.style.height ); + assert.equal( elem.style.height, t_h + "px", "Final height should be " + t_h + ": " + elem.style.height ); cur_h = jQuery.css( elem, "height" ); - ok( elem.style.height !== "" || cur_h === t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_h ); + assert.ok( elem.style.height !== "" || cur_h === t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_h ); } if ( t_h === "show" ) { @@ -1031,9 +1031,9 @@ jQuery.each( { jQuery( elem ).append( "<br/>Some more text<br/>and some more..." ); if ( /Auto/.test( fn ) ) { - notEqual( jQuery.css( elem, "height" ), old_h, "Make sure height is auto." ); + assert.notEqual( jQuery.css( elem, "height" ), old_h, "Make sure height is auto." ); } else { - equal( jQuery.css( elem, "height" ), old_h, "Make sure height is not auto." ); + assert.equal( jQuery.css( elem, "height" ), old_h, "Make sure height is not auto." ); } } @@ -1046,19 +1046,19 @@ jQuery.each( { } ); } ); -test( "Effects chaining", function() { +QUnit.test( "Effects chaining", function( assert ) { var remaining = 16, props = [ "opacity", "height", "width", "display", "overflow" ], setup = function( name, selector ) { var $el = jQuery( selector ); return $el.data( getProps( $el[ 0 ] ) ).data( "name", name ); }, - assert = function() { + check = function() { var data = jQuery.data( this ), name = data.name; delete data.name; - deepEqual( getProps( this ), data, name ); + assert.deepEqual( getProps( this ), data, name ); jQuery.removeData( this ); }, @@ -1070,24 +1070,24 @@ test( "Effects chaining", function() { return obj; }; - expect( remaining ); - - setup( ".fadeOut().fadeIn()", "#fadein div" ).fadeOut( "fast" ).fadeIn( "fast", assert ); - setup( ".fadeIn().fadeOut()", "#fadeout div" ).fadeIn( "fast" ).fadeOut( "fast", assert ); - setup( ".hide().show()", "#show div" ).hide( "fast" ).show( "fast", assert ); - setup( ".show().hide()", "#hide div" ).show( "fast" ).hide( "fast", assert ); - setup( ".show().hide(easing)", "#easehide div" ).show( "fast" ).hide( "fast", "linear", assert ); - setup( ".toggle().toggle() - in", "#togglein div" ).toggle( "fast" ).toggle( "fast", assert ); - setup( ".toggle().toggle() - out", "#toggleout div" ).toggle( "fast" ).toggle( "fast", assert ); - setup( ".toggle().toggle(easing) - out", "#easetoggleout div" ).toggle( "fast" ).toggle( "fast", "linear", assert ); - setup( ".slideDown().slideUp()", "#slidedown div" ).slideDown( "fast" ).slideUp( "fast", assert ); - setup( ".slideUp().slideDown()", "#slideup div" ).slideUp( "fast" ).slideDown( "fast", assert ); - setup( ".slideUp().slideDown(easing)", "#easeslideup div" ).slideUp( "fast" ).slideDown( "fast", "linear", assert ); - setup( ".slideToggle().slideToggle() - in", "#slidetogglein div" ).slideToggle( "fast" ).slideToggle( "fast", assert ); - setup( ".slideToggle().slideToggle() - out", "#slidetoggleout div" ).slideToggle( "fast" ).slideToggle( "fast", assert ); - setup( ".fadeToggle().fadeToggle() - in", "#fadetogglein div" ).fadeToggle( "fast" ).fadeToggle( "fast", assert ); - setup( ".fadeToggle().fadeToggle() - out", "#fadetoggleout div" ).fadeToggle( "fast" ).fadeToggle( "fast", assert ); - setup( ".fadeTo(0.5).fadeTo(1.0, easing)", "#fadeto div" ).fadeTo( "fast", 0.5 ).fadeTo( "fast", 1.0, "linear", assert ); + assert.expect( remaining ); + + setup( ".fadeOut().fadeIn()", "#fadein div" ).fadeOut( "fast" ).fadeIn( "fast", check ); + setup( ".fadeIn().fadeOut()", "#fadeout div" ).fadeIn( "fast" ).fadeOut( "fast", check ); + setup( ".hide().show()", "#show div" ).hide( "fast" ).show( "fast", check ); + setup( ".show().hide()", "#hide div" ).show( "fast" ).hide( "fast", check ); + setup( ".show().hide(easing)", "#easehide div" ).show( "fast" ).hide( "fast", "linear", check ); + setup( ".toggle().toggle() - in", "#togglein div" ).toggle( "fast" ).toggle( "fast", check ); + setup( ".toggle().toggle() - out", "#toggleout div" ).toggle( "fast" ).toggle( "fast", check ); + setup( ".toggle().toggle(easing) - out", "#easetoggleout div" ).toggle( "fast" ).toggle( "fast", "linear", check ); + setup( ".slideDown().slideUp()", "#slidedown div" ).slideDown( "fast" ).slideUp( "fast", check ); + setup( ".slideUp().slideDown()", "#slideup div" ).slideUp( "fast" ).slideDown( "fast", check ); + setup( ".slideUp().slideDown(easing)", "#easeslideup div" ).slideUp( "fast" ).slideDown( "fast", "linear", check ); + setup( ".slideToggle().slideToggle() - in", "#slidetogglein div" ).slideToggle( "fast" ).slideToggle( "fast", check ); + setup( ".slideToggle().slideToggle() - out", "#slidetoggleout div" ).slideToggle( "fast" ).slideToggle( "fast", check ); + setup( ".fadeToggle().fadeToggle() - in", "#fadetogglein div" ).fadeToggle( "fast" ).fadeToggle( "fast", check ); + setup( ".fadeToggle().fadeToggle() - out", "#fadetoggleout div" ).fadeToggle( "fast" ).fadeToggle( "fast", check ); + setup( ".fadeTo(0.5).fadeTo(1.0, easing)", "#fadeto div" ).fadeTo( "fast", 0.5 ).fadeTo( "fast", 1.0, "linear", check ); this.clock.tick( 400 ); } ); @@ -1106,21 +1106,21 @@ jQuery.makeTest = function( text ) { jQuery.makeTest.id = 1; -test( "jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function() { - expect( 4 ); +QUnit.test( "jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function( assert ) { + assert.expect( 4 ); var $checkedtest = jQuery( "#checkedtest" ); $checkedtest.hide().show( "fast", function() { - ok( jQuery( "input[type='radio']", $checkedtest ).first().attr( "checked" ), "Check first radio still checked." ); - ok( !jQuery( "input[type='radio']", $checkedtest ).last().attr( "checked" ), "Check last radio still NOT checked." ); - ok( jQuery( "input[type='checkbox']", $checkedtest ).first().attr( "checked" ), "Check first checkbox still checked." ); - ok( !jQuery( "input[type='checkbox']", $checkedtest ).last().attr( "checked" ), "Check last checkbox still NOT checked." ); + assert.ok( jQuery( "input[type='radio']", $checkedtest ).first().attr( "checked" ), "Check first radio still checked." ); + assert.ok( !jQuery( "input[type='radio']", $checkedtest ).last().attr( "checked" ), "Check last radio still NOT checked." ); + assert.ok( jQuery( "input[type='checkbox']", $checkedtest ).first().attr( "checked" ), "Check first checkbox still checked." ); + assert.ok( !jQuery( "input[type='checkbox']", $checkedtest ).last().attr( "checked" ), "Check last checkbox still NOT checked." ); } ); this.clock.tick( 200 ); } ); -test( "interrupt toggle", function() { - expect( 24 ); +QUnit.test( "interrupt toggle", function( assert ) { + assert.expect( 24 ); var env = this, longDuration = 2000, @@ -1148,7 +1148,7 @@ test( "interrupt toggle", function() { $methodElems[ method ]( longDuration ); setTimeout( function() { $methodElems.stop().each( function() { - notEqual( jQuery( this ).css( prop ), jQuery.data( this, "startVal" ), ".stop() before completion of hiding ." + method + "() - #" + this.id ); + assert.notEqual( jQuery( this ).css( prop ), jQuery.data( this, "startVal" ), ".stop() before completion of hiding ." + method + "() - #" + this.id ); } ); // Restore @@ -1159,17 +1159,17 @@ test( "interrupt toggle", function() { $elem.removeData( "startVal" ); - equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id ); + assert.equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id ); // Interrupt a showing toggle $elem.hide()[ method ]( longDuration ); setTimeout( function() { $elem.stop(); - notEqual( $elem.css( prop ), startVal, ".stop() before completion of showing ." + method + "() - #" + id ); + assert.notEqual( $elem.css( prop ), startVal, ".stop() before completion of showing ." + method + "() - #" + id ); // Restore $elem[ method ]( shortDuration, function() { - equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id ); + assert.equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id ); finish(); } ); }, shortDuration ); @@ -1181,9 +1181,9 @@ test( "interrupt toggle", function() { // FIXME untangle the set timeouts } ); -test( "animate with per-property easing", function() { +QUnit.test( "animate with per-property easing", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var data = { a: 0, b: 0, c: 0 }, test1Called = false, @@ -1211,18 +1211,18 @@ test( "animate with per-property easing", function() { }; jQuery( data ).animate( props, 400, "_defaultTest", function() { - ok( test1Called, "Easing function (_test1) called" ); - ok( test2Called, "Easing function (_test2) called" ); - ok( defaultTestCalled, "Easing function (_default) called" ); - equal( props.a[ 1 ], "_test1", "animate does not change original props (per-property easing would be lost)" ); - equal( props.b[ 1 ], "_test2", "animate does not change original props (per-property easing would be lost)" ); + assert.ok( test1Called, "Easing function (_test1) called" ); + assert.ok( test2Called, "Easing function (_test2) called" ); + assert.ok( defaultTestCalled, "Easing function (_default) called" ); + assert.equal( props.a[ 1 ], "_test1", "animate does not change original props (per-property easing would be lost)" ); + assert.equal( props.b[ 1 ], "_test2", "animate does not change original props (per-property easing would be lost)" ); } ); this.clock.tick( 400 ); } ); -test( "animate with CSS shorthand properties", function() { - expect( 11 ); +QUnit.test( "animate with CSS shorthand properties", function( assert ) { + assert.expect( 11 ); var easeAnimation_count = 0, easeProperty_count = 0, @@ -1245,20 +1245,20 @@ test( "animate with CSS shorthand properties", function() { jQuery( "#foo" ) .animate( propsBasic, 200, "animationScope", function() { - equal( this.style.paddingTop, "10px", "padding-top was animated" ); - equal( this.style.paddingLeft, "20px", "padding-left was animated" ); - equal( this.style.paddingRight, "20px", "padding-right was animated" ); - equal( this.style.paddingBottom, "30px", "padding-bottom was animated" ); - equal( easeAnimation_count, 4, "per-animation default easing called for each property" ); + assert.equal( this.style.paddingTop, "10px", "padding-top was animated" ); + assert.equal( this.style.paddingLeft, "20px", "padding-left was animated" ); + assert.equal( this.style.paddingRight, "20px", "padding-right was animated" ); + assert.equal( this.style.paddingBottom, "30px", "padding-bottom was animated" ); + assert.equal( easeAnimation_count, 4, "per-animation default easing called for each property" ); easeAnimation_count = 0; } ) .animate( propsSpecial, 200, "animationScope", function() { - equal( this.style.paddingTop, "1px", "padding-top was animated again" ); - equal( this.style.paddingLeft, "2px", "padding-left was animated again" ); - equal( this.style.paddingRight, "2px", "padding-right was animated again" ); - equal( this.style.paddingBottom, "3px", "padding-bottom was animated again" ); - equal( easeAnimation_count, 0, "per-animation default easing not called" ); - equal( easeProperty_count, 4, "special easing called for each property" ); + assert.equal( this.style.paddingTop, "1px", "padding-top was animated again" ); + assert.equal( this.style.paddingLeft, "2px", "padding-left was animated again" ); + assert.equal( this.style.paddingRight, "2px", "padding-right was animated again" ); + assert.equal( this.style.paddingBottom, "3px", "padding-bottom was animated again" ); + assert.equal( easeAnimation_count, 0, "per-animation default easing not called" ); + assert.equal( easeProperty_count, 4, "special easing called for each property" ); jQuery( this ).css( "padding", "0" ); delete jQuery.easing.animationScope; @@ -1267,43 +1267,43 @@ test( "animate with CSS shorthand properties", function() { this.clock.tick( 400 ); } ); -test( "hide hidden elements, with animation (bug #7141)", function() { - expect( 3 ); +QUnit.test( "hide hidden elements, with animation (bug #7141)", function( assert ) { + assert.expect( 3 ); var div = jQuery( "<div style='display:none'></div>" ).appendTo( "#qunit-fixture" ); - equal( div.css( "display" ), "none", "Element is hidden by default" ); + assert.equal( div.css( "display" ), "none", "Element is hidden by default" ); div.hide( 1, function() { - ok( !jQuery._data( div, "display" ), "display data is undefined after hiding an already-hidden element" ); + assert.ok( !jQuery._data( div, "display" ), "display data is undefined after hiding an already-hidden element" ); div.show( 1, function() { - equal( div.css( "display" ), "block", "Show a double-hidden element" ); + assert.equal( div.css( "display" ), "block", "Show a double-hidden element" ); } ); } ); this.clock.tick( 10 ); } ); -test( "animate unit-less properties (#4966)", function() { - expect( 2 ); +QUnit.test( "animate unit-less properties (#4966)", function( assert ) { + assert.expect( 2 ); var div = jQuery( "<div style='z-index: 0; position: absolute;'></div>" ).appendTo( "#qunit-fixture" ); - equal( div.css( "z-index" ), "0", "z-index is 0" ); + assert.equal( div.css( "z-index" ), "0", "z-index is 0" ); div.animate( { zIndex: 2 }, function() { - equal( div.css( "z-index" ), "2", "z-index is 2" ); + assert.equal( div.css( "z-index" ), "2", "z-index is 2" ); } ); this.clock.tick( 400 ); } ); -test( "animate properties missing px w/ opacity as last (#9074)", function() { - expect( 2 ); +QUnit.test( "animate properties missing px w/ opacity as last (#9074)", function( assert ) { + assert.expect( 2 ); - expect( 6 ); + assert.expect( 6 ); var ml, l, div = jQuery( "<div style='position: absolute; margin-left: 0; left: 0px;'></div>" ) .appendTo( "#qunit-fixture" ); function cssInt( prop ) { return parseInt( div.css( prop ), 10 ); } - equal( cssInt( "marginLeft" ), 0, "Margin left is 0" ); - equal( cssInt( "left" ), 0, "Left is 0" ); + assert.equal( cssInt( "marginLeft" ), 0, "Margin left is 0" ); + assert.equal( cssInt( "left" ), 0, "Left is 0" ); div.animate( { left: 200, marginLeft: 200, @@ -1314,15 +1314,15 @@ test( "animate properties missing px w/ opacity as last (#9074)", function() { ml = cssInt( "marginLeft" ); l = cssInt( "left" ); - notEqual( ml, 0, "Margin left is not 0 after partial animate" ); - notEqual( ml, 200, "Margin left is not 200 after partial animate" ); - notEqual( l, 0, "Left is not 0 after partial animate" ); - notEqual( l, 200, "Left is not 200 after partial animate" ); + assert.notEqual( ml, 0, "Margin left is not 0 after partial animate" ); + assert.notEqual( ml, 200, "Margin left is not 200 after partial animate" ); + assert.notEqual( l, 0, "Left is not 0 after partial animate" ); + assert.notEqual( l, 200, "Left is not 200 after partial animate" ); div.stop().remove(); } ); -test( "callbacks should fire in correct order (#9100)", function() { - expect( 1 ); +QUnit.test( "callbacks should fire in correct order (#9100)", function( assert ) { + assert.expect( 1 ); var a = 1, cb = 0; @@ -1335,14 +1335,14 @@ test( "callbacks should fire in correct order (#9100)", function() { a *= jQuery( this ).data( "operation" ) === "*2" ? 2 : a; cb++; if ( cb === 2 ) { - equal( a, 4, "test value has been *2 and _then_ ^2" ); + assert.equal( a, 4, "test value has been *2 and _then_ ^2" ); } } ); this.clock.tick( 20 ); } ); -test( "callbacks that throw exceptions will be removed (#5684)", function() { - expect( 2 ); +QUnit.test( "callbacks that throw exceptions will be removed (#5684)", function( assert ) { + assert.expect( 2 ); var foo = jQuery( "#foo" ); @@ -1360,30 +1360,30 @@ test( "callbacks that throw exceptions will be removed (#5684)", function() { jQuery.fx.stop(); this.clock.tick( 1 ); - throws( jQuery.fx.tick, TestException, "Exception was thrown" ); + assert.throws( jQuery.fx.tick, TestException, "Exception was thrown" ); // the second call shouldn't jQuery.fx.tick(); - ok( true, "Test completed without throwing a second exception" ); + assert.ok( true, "Test completed without throwing a second exception" ); } ); -test( "animate will scale margin properties individually", function() { - expect( 2 ); +QUnit.test( "animate will scale margin properties individually", function( assert ) { + assert.expect( 2 ); var foo = jQuery( "#foo" ).css( { "margin": 0, "marginLeft": 100 } ); - ok( foo.css( "marginLeft" ) !== foo.css( "marginRight" ), "Sanity Check" ); + assert.ok( foo.css( "marginLeft" ) !== foo.css( "marginRight" ), "Sanity Check" ); foo.animate( { "margin": 200 } ).stop(); - ok( foo.css( "marginLeft" ) !== foo.css( "marginRight" ), "The margin properties are different" ); + assert.ok( foo.css( "marginLeft" ) !== foo.css( "marginRight" ), "The margin properties are different" ); // clean up for next test foo.css( { @@ -1394,8 +1394,8 @@ test( "animate will scale margin properties individually", function() { } ); } ); -test( "Do not append px to 'fill-opacity' #9548", function() { - expect( 1 ); +QUnit.test( "Do not append px to 'fill-opacity' #9548", function( assert ) { + assert.expect( 1 ); var $div = jQuery( "<div>" ).appendTo( "#qunit-fixture" ); @@ -1403,16 +1403,16 @@ test( "Do not append px to 'fill-opacity' #9548", function() { // Support: Android 2.3 (no support for fill-opacity) if ( jQuery( this ).css( "fill-opacity" ) ) { - equal( jQuery( this ).css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" ); + assert.equal( jQuery( this ).css( "fill-opacity" ), 1, "Do not append px to 'fill-opacity'" ); } else { - ok( true, "No support for fill-opacity CSS property" ); + assert.ok( true, "No support for fill-opacity CSS property" ); } $div.remove(); } ); } ); -test( "line-height animates correctly (#13855)", function() { - expect( 12 ); +QUnit.test( "line-height animates correctly (#13855)", function( assert ) { + assert.expect( 12 ); var t0, clock = this.clock, @@ -1443,9 +1443,9 @@ test( "line-height animates correctly (#13855)", function() { initial = initialHeight[ i ], height = jQuery( this ).height(), lower = initial * ( 1 - progress ) / tolerance; - ok( height < initial, "hide " + label + ": upper bound; " + + assert.ok( height < initial, "hide " + label + ": upper bound; " + height + " < " + initial + " @ " + ( progress * 100 ) + "%" ); - ok( height > lower, "hide " + label + ": lower bound; " + + assert.ok( height > lower, "hide " + label + ": lower bound; " + height + " > " + lower + " @ " + ( progress * 100 ) + "%" ); } ); @@ -1461,7 +1461,7 @@ test( "line-height animates correctly (#13855)", function() { initial = initialHeight[ i ], height = jQuery( this ).height(), upper = initial * progress * tolerance; - ok( height < upper, "show " + label + ": upper bound; " + + assert.ok( height < upper, "show " + label + ": upper bound; " + height + " < " + upper + " @ " + ( progress * 100 ) + "%" ); } ); @@ -1475,8 +1475,8 @@ clock.tick( 50 ); } ); // Start 1.8 Animation tests -test( "jQuery.Animation( object, props, opts )", function() { - expect( 4 ); +QUnit.test( "jQuery.Animation( object, props, opts )", function( assert ) { + assert.expect( 4 ); var animation, testObject = { @@ -1493,17 +1493,17 @@ test( "jQuery.Animation( object, props, opts )", function() { animation = jQuery.Animation( testObject, testDest, { "duration": 1 } ); animation.done( function() { for ( var prop in testDest ) { - equal( testObject[ prop ], testDest[ prop ], "Animated: " + prop ); + assert.equal( testObject[ prop ], testDest[ prop ], "Animated: " + prop ); } animation.done( function() { - deepEqual( testObject, testDest, "No unexpected properties" ); + assert.deepEqual( testObject, testDest, "No unexpected properties" ); } ); } ); this.clock.tick( 10 ); } ); -test( "Animate Option: step: function( percent, tween )", function() { - expect( 1 ); +QUnit.test( "Animate Option: step: function( percent, tween )", function( assert ) { + assert.expect( 1 ); var counter = {}; jQuery( "#foo" ).animate( { @@ -1520,7 +1520,7 @@ test( "Animate Option: step: function( percent, tween )", function() { calls[ value === 0 ? 0 : 1 ] = value; } } ).queue( function( next ) { - deepEqual( counter, { + assert.deepEqual( counter, { prop1: [ 0, 1 ], prop2: [ 0, 2 ], prop3: [ 0, 3 ] @@ -1530,41 +1530,41 @@ test( "Animate Option: step: function( percent, tween )", function() { this.clock.tick( 10 ); } ); -test( "Animate callbacks have correct context", function() { - expect( 2 ); +QUnit.test( "Animate callbacks have correct context", function( assert ) { + assert.expect( 2 ); var foo = jQuery( "#foo" ); foo.animate( { height: 10 }, 10, function() { - equal( foo[ 0 ], this, "Complete callback after stop(true) `this` is element" ); + assert.equal( foo[ 0 ], this, "Complete callback after stop(true) `this` is element" ); } ).stop( true, true ); foo.animate( { height: 100 }, 10, function() { - equal( foo[ 0 ], this, "Complete callback `this` is element" ); + assert.equal( foo[ 0 ], this, "Complete callback `this` is element" ); } ); this.clock.tick( 10 ); } ); -test( "User supplied callback called after show when fx off (#8892)", function() { - expect( 2 ); +QUnit.test( "User supplied callback called after show when fx off (#8892)", function( assert ) { + assert.expect( 2 ); var foo = jQuery( "#foo" ); jQuery.fx.off = true; foo.hide(); foo.fadeIn( 500, function() { - ok( jQuery( this ).is( ":visible" ), "Element is visible in callback" ); + assert.ok( jQuery( this ).is( ":visible" ), "Element is visible in callback" ); foo.fadeOut( 500, function() { - ok( jQuery( this ).is( ":hidden" ), "Element is hidden in callback" ); + assert.ok( jQuery( this ).is( ":hidden" ), "Element is hidden in callback" ); jQuery.fx.off = false; } ); } ); this.clock.tick( 1000 ); } ); -test( "animate should set display for disconnected nodes", function() { - expect( 20 ); +QUnit.test( "animate should set display for disconnected nodes", function( assert ) { + assert.expect( 20 ); var methods = { toggle: [ 1 ], @@ -1583,47 +1583,47 @@ test( "animate should set display for disconnected nodes", function() { underFragmentDisplay = $divTest.css( "display" ), clock = this.clock; - strictEqual( $divEmpty[ 0 ].parentNode, null, "Setup: element with null parentNode" ); - strictEqual( ( $divTest[ 0 ].parentNode || {} ).nodeType, 11, "Setup: element under fragment" ); + assert.strictEqual( $divEmpty[ 0 ].parentNode, null, "Setup: element with null parentNode" ); + assert.strictEqual( ( $divTest[ 0 ].parentNode || {} ).nodeType, 11, "Setup: element under fragment" ); - strictEqual( $divEmpty.show()[ 0 ].style.display, "", + assert.strictEqual( $divEmpty.show()[ 0 ].style.display, "", "set display with show() for element with null parentNode" ); - strictEqual( $divTest.show()[ 0 ].style.display, "", + assert.strictEqual( $divTest.show()[ 0 ].style.display, "", "set display with show() for element under fragment" ); - strictEqual( $divNone.show()[ 0 ].style.display, "", + assert.strictEqual( $divNone.show()[ 0 ].style.display, "", "show() should change display if it already set to none" ); - strictEqual( $divInline.show()[ 0 ].style.display, "inline", + assert.strictEqual( $divInline.show()[ 0 ].style.display, "inline", "show() should not change display if it already set" ); jQuery.each( methods, function( name, opt ) { jQuery.fn[ name ].apply( jQuery( "<div/>" ), opt.concat( [ function() { - strictEqual( jQuery( this ).css( "display" ), nullParentDisplay, + assert.strictEqual( jQuery( this ).css( "display" ), nullParentDisplay, "." + name + " block with null parentNode" ); } ] ) ); jQuery.fn[ name ].apply( jQuery( "<div>test</div>" ), opt.concat( [ function() { - strictEqual( jQuery( this ).css( "display" ), underFragmentDisplay, + assert.strictEqual( jQuery( this ).css( "display" ), underFragmentDisplay, "." + name + " block under fragment" ); } ] ) ); } ); clock.tick( 400 ); } ); -test( "Animation callback should not show animated element as :animated (#7157)", function() { - expect( 1 ); +QUnit.test( "Animation callback should not show animated element as :animated (#7157)", function( assert ) { + assert.expect( 1 ); var foo = jQuery( "#foo" ); foo.animate( { opacity: 0 }, 100, function() { - ok( !foo.is( ":animated" ), "The element is not animated" ); + assert.ok( !foo.is( ":animated" ), "The element is not animated" ); } ); this.clock.tick( 100 ); } ); -test( "Initial step callback should show element as :animated (#14623)", function() { - expect( 1 ); +QUnit.test( "Initial step callback should show element as :animated (#14623)", function( assert ) { + assert.expect( 1 ); var foo = jQuery( "#foo" ); @@ -1632,15 +1632,15 @@ test( "Initial step callback should show element as :animated (#14623)", functio }, { duration: 100, step: function() { - ok( foo.is( ":animated" ), "The element matches :animated inside step function" ); + assert.ok( foo.is( ":animated" ), "The element matches :animated inside step function" ); } } ); this.clock.tick( 1 ); foo.stop(); } ); -test( "hide called on element within hidden parent should set display to none (#10045)", function() { - expect( 3 ); +QUnit.test( "hide called on element within hidden parent should set display to none (#10045)", function( assert ) { + assert.expect( 3 ); var hidden = jQuery( ".hidden" ), elems = jQuery( "<div>hide</div><div>hide0</div><div>hide1</div>" ); @@ -1652,17 +1652,17 @@ test( "hide called on element within hidden parent should set display to none (# elems.eq( 1 ).hide( 0 ), elems.eq( 2 ).hide( 1 ) ).done( function() { - strictEqual( elems.get( 0 ).style.display, "none", "hide() called on element within hidden parent should set display to none" ); - strictEqual( elems.get( 1 ).style.display, "none", "hide( 0 ) called on element within hidden parent should set display to none" ); - strictEqual( elems.get( 2 ).style.display, "none", "hide( 1 ) called on element within hidden parent should set display to none" ); + assert.strictEqual( elems.get( 0 ).style.display, "none", "hide() called on element within hidden parent should set display to none" ); + assert.strictEqual( elems.get( 1 ).style.display, "none", "hide( 0 ) called on element within hidden parent should set display to none" ); + assert.strictEqual( elems.get( 2 ).style.display, "none", "hide( 1 ) called on element within hidden parent should set display to none" ); elems.remove(); } ); this.clock.tick( 10 ); } ); -test( "hide, fadeOut and slideUp called on element width height and width = 0 should set display to none", function() { - expect( 5 ); +QUnit.test( "hide, fadeOut and slideUp called on element width height and width = 0 should set display to none", function( assert ) { + assert.expect( 5 ); var foo = jQuery( "#foo" ), i = 0, @@ -1681,34 +1681,34 @@ test( "hide, fadeOut and slideUp called on element width height and width = 0 sh elems.eq( 3 ).fadeOut(), elems.eq( 4 ).slideUp() ).done( function() { - strictEqual( elems.get( 0 ).style.display, "none", "hide() called on element width height and width = 0 should set display to none" ); - strictEqual( elems.get( 1 ).style.display, "none", + assert.strictEqual( elems.get( 0 ).style.display, "none", "hide() called on element width height and width = 0 should set display to none" ); + assert.strictEqual( elems.get( 1 ).style.display, "none", "hide( jQuery.noop ) called on element width height and width = 0 should set display to none" ); - strictEqual( elems.get( 2 ).style.display, "none", "hide( 1 ) called on element width height and width = 0 should set display to none" ); - strictEqual( elems.get( 3 ).style.display, "none", "fadeOut() called on element width height and width = 0 should set display to none" ); - strictEqual( elems.get( 4 ).style.display, "none", "slideUp() called on element width height and width = 0 should set display to none" ); + assert.strictEqual( elems.get( 2 ).style.display, "none", "hide( 1 ) called on element width height and width = 0 should set display to none" ); + assert.strictEqual( elems.get( 3 ).style.display, "none", "fadeOut() called on element width height and width = 0 should set display to none" ); + assert.strictEqual( elems.get( 4 ).style.display, "none", "slideUp() called on element width height and width = 0 should set display to none" ); } ); this.clock.tick( 400 ); } ); -test( "hide should not leave hidden inline elements visible (#14848)", function() { - expect( 2 ); +QUnit.test( "hide should not leave hidden inline elements visible (#14848)", function( assert ) { + assert.expect( 2 ); var el = jQuery( "#simon1" ); el.hide( 1, function() { - equal( el.css( "display" ), "none", "hidden" ); + assert.equal( el.css( "display" ), "none", "hidden" ); el.hide( 1, function() { - equal( el.css( "display" ), "none", "still hidden" ); + assert.equal( el.css( "display" ), "none", "still hidden" ); } ); } ); this.clock.tick( 100 ); } ); -test( "Handle queue:false promises", function() { - expect( 10 ); +QUnit.test( "Handle queue:false promises", function( assert ) { + assert.expect( 10 ); var foo = jQuery( "#foo" ).clone().addBack(), step = 1; @@ -1719,14 +1719,14 @@ test( "Handle queue:false promises", function() { duration: 10, queue: false, complete: function() { - ok( step++ <= 2, "Step one or two" ); + assert.ok( step++ <= 2, "Step one or two" ); } } ).animate( { bottom: 1 }, { duration: 10, complete: function() { - ok( step > 2 && step < 5, "Step three or four" ); + assert.ok( step > 2 && step < 5, "Step three or four" ); step++; } } ); @@ -1734,13 +1734,13 @@ test( "Handle queue:false promises", function() { this.clock.tick( 10 ); foo.promise().done( function() { - equal( step++, 5, "steps 1-5: queue:false then queue:fx done" ); + assert.equal( step++, 5, "steps 1-5: queue:false then queue:fx done" ); foo.animate( { top: 10 }, { duration: 10, complete: function() { - ok( step > 5 && step < 8, "Step six or seven" ); + assert.ok( step > 5 && step < 8, "Step six or seven" ); step++; } } ).animate( { @@ -1749,19 +1749,19 @@ test( "Handle queue:false promises", function() { duration: 10, queue: false, complete: function() { - ok( step > 7 && step < 10, "Step eight or nine" ); + assert.ok( step > 7 && step < 10, "Step eight or nine" ); step++; } } ).promise().done( function() { - equal( step++, 10, "steps 6-10: queue:fx then queue:false" ); + assert.equal( step++, 10, "steps 6-10: queue:fx then queue:false" ); } ); } ); this.clock.tick( 10 ); } ); -test( "multiple unqueued and promise", function() { - expect( 4 ); +QUnit.test( "multiple unqueued and promise", function( assert ) { + assert.expect( 4 ); var foo = jQuery( "#foo" ), step = 1; @@ -1771,7 +1771,7 @@ test( "multiple unqueued and promise", function() { duration: 500, queue: false, complete: function() { - strictEqual( step++, 2, "Step 2" ); + assert.strictEqual( step++, 2, "Step 2" ); } } ).animate( { top: 100 @@ -1779,7 +1779,7 @@ test( "multiple unqueued and promise", function() { duration: 1000, queue: false, complete: function() { - strictEqual( step++, 3, "Step 3" ); + assert.strictEqual( step++, 3, "Step 3" ); } } ).animate( {}, { duration: 2000, @@ -1787,16 +1787,16 @@ test( "multiple unqueued and promise", function() { complete: function() { // no properties is a non-op and finishes immediately - strictEqual( step++, 1, "Step 1" ); + assert.strictEqual( step++, 1, "Step 1" ); } } ).promise().done( function() { - strictEqual( step++, 4, "Step 4" ); + assert.strictEqual( step++, 4, "Step 4" ); } ); this.clock.tick( 1000 ); } ); -test( "animate does not change start value for non-px animation (#7109)", function() { - expect( 1 ); +QUnit.test( "animate does not change start value for non-px animation (#7109)", function( assert ) { + assert.expect( 1 ); var parent = jQuery( "<div><div></div></div>" ).css( { width: 284, height: 1 } ).appendTo( "#qunit-fixture" ), child = parent.children().css( { fontSize: "98.6in", width: "0.01em", height: 1 } ), @@ -1810,22 +1810,22 @@ test( "animate does not change start value for non-px animation (#7109)", functi } } ).queue( function( next ) { var ratio = computed[ 0 ] / actual; - ok( ratio > 0.9 && ratio < 1.1, "Starting width was close enough" ); + assert.ok( ratio > 0.9 && ratio < 1.1, "Starting width was close enough" ); next(); parent.remove(); } ); this.clock.tick( 10 ); } ); -test( "non-px animation handles non-numeric start (#11971)", function() { - expect( 2 ); +QUnit.test( "non-px animation handles non-numeric start (#11971)", function( assert ) { + assert.expect( 2 ); var foo = jQuery( "#foo" ), initial = foo.css( "backgroundPositionX" ); if ( !initial ) { - expect( 1 ); - ok( true, "Style property not understood" ); + assert.expect( 1 ); + assert.ok( true, "Style property not understood" ); return; } @@ -1837,20 +1837,20 @@ test( "non-px animation handles non-numeric start (#11971)", function() { } if ( parseFloat( initial ) ) { - equal( jQuery.style( this, "backgroundPositionX" ), initial, "Numeric start preserved" ); + assert.equal( jQuery.style( this, "backgroundPositionX" ), initial, "Numeric start preserved" ); } else { - equal( jQuery.style( this, "backgroundPositionX" ), "0%", "Non-numeric start zeroed" ); + assert.equal( jQuery.style( this, "backgroundPositionX" ), "0%", "Non-numeric start zeroed" ); } }, done: function() { - equal( jQuery.style( this, "backgroundPositionX" ), "42%", "End reached" ); + assert.equal( jQuery.style( this, "backgroundPositionX" ), "42%", "End reached" ); } } ); this.clock.tick( 10 ); } ); -test( "Animation callbacks (#11797)", function() { - expect( 15 ); +QUnit.test( "Animation callbacks (#11797)", function( assert ) { + assert.expect( 15 ); var targets = jQuery( "#foo" ).children(), done = false, @@ -1859,24 +1859,24 @@ test( "Animation callbacks (#11797)", function() { targets.eq( 0 ).animate( {}, { duration: 1, start: function() { - ok( true, "empty: start" ); + assert.ok( true, "empty: start" ); }, progress: function( anim, percent ) { - equal( percent, 0, "empty: progress 0" ); + assert.equal( percent, 0, "empty: progress 0" ); }, done: function() { - ok( true, "empty: done" ); + assert.ok( true, "empty: done" ); }, fail: function() { - ok( false, "empty: fail" ); + assert.ok( false, "empty: fail" ); }, always: function() { - ok( true, "empty: always" ); + assert.ok( true, "empty: always" ); done = true; } } ); - ok( done, "empty: done immediately" ); + assert.ok( done, "empty: done immediately" ); done = false; targets.eq( 1 ).animate( { @@ -1884,31 +1884,31 @@ test( "Animation callbacks (#11797)", function() { }, { duration: 1, start: function() { - ok( true, "stopped: start" ); + assert.ok( true, "stopped: start" ); }, progress: function( anim, percent ) { - equal( percent, 0, "stopped: progress 0" ); + assert.equal( percent, 0, "stopped: progress 0" ); }, done: function() { - ok( false, "stopped: done" ); + assert.ok( false, "stopped: done" ); }, fail: function() { - ok( true, "stopped: fail" ); + assert.ok( true, "stopped: fail" ); }, always: function() { - ok( true, "stopped: always" ); + assert.ok( true, "stopped: always" ); done = true; } } ).stop(); - ok( done, "stopped: stopped immediately" ); + assert.ok( done, "stopped: stopped immediately" ); targets.eq( 2 ).animate( { opacity: 0 }, { duration: 1, start: function() { - ok( true, "async: start" ); + assert.ok( true, "async: start" ); }, progress: function( anim, percent ) { @@ -1916,26 +1916,26 @@ test( "Animation callbacks (#11797)", function() { if ( percent === 0 && expectedProgress === 1 ) { return; } - equal( percent, expectedProgress, "async: progress " + expectedProgress ); + assert.equal( percent, expectedProgress, "async: progress " + expectedProgress ); // once at 0, once at 1 expectedProgress++; }, done: function() { - ok( true, "async: done" ); + assert.ok( true, "async: done" ); }, fail: function() { - ok( false, "async: fail" ); + assert.ok( false, "async: fail" ); }, always: function() { - ok( true, "async: always" ); + assert.ok( true, "async: always" ); } } ); this.clock.tick( 10 ); } ); -test( "Animate properly sets overflow hidden when animating width/height (#12117)", function() { - expect( 8 ); +QUnit.test( "Animate properly sets overflow hidden when animating width/height (#12117)", function( assert ) { + assert.expect( 8 ); jQuery.each( [ "height", "width" ], function( _, prop ) { jQuery.each( [ 100, 0 ], function( _, value ) { @@ -1943,26 +1943,26 @@ test( "Animate properly sets overflow hidden when animating width/height (#12117 props = {}; props[ prop ] = value; div.animate( props, 1 ); - equal( div.css( "overflow" ), "hidden", + assert.equal( div.css( "overflow" ), "hidden", "overflow: hidden set when animating " + prop + " to " + value ); div.stop(); - equal( div.css( "overflow" ), "auto", + assert.equal( div.css( "overflow" ), "auto", "overflow: auto restored after animating " + prop + " to " + value ); } ); } ); } ); -test( "Each tick of the timer loop uses a fresh time (#12837)", function() { +QUnit.test( "Each tick of the timer loop uses a fresh time (#12837)", function( assert ) { var lastVal, tmp = jQuery( { test: 0 } ); - expect( 3 ); + assert.expect( 3 ); tmp.animate( { test: 100 }, { step: function( p, fx ) { - ok( fx.now !== lastVal, "Current value is not the last value: " + lastVal + " - " + fx.now ); + assert.ok( fx.now !== lastVal, "Current value is not the last value: " + lastVal + " - " + fx.now ); lastVal = fx.now; } } ); @@ -1977,11 +1977,11 @@ test( "Each tick of the timer loop uses a fresh time (#12837)", function() { tmp.stop(); } ); -test( "Animations with 0 duration don't ease (#12273)", function() { - expect( 1 ); +QUnit.test( "Animations with 0 duration don't ease (#12273)", function( assert ) { + assert.expect( 1 ); jQuery.easing.test = function() { - ok( false, "Called easing" ); + assert.ok( false, "Called easing" ); }; jQuery( "#foo" ).animate( { @@ -1990,7 +1990,7 @@ test( "Animations with 0 duration don't ease (#12273)", function() { duration: 0, easing: "test", complete: function() { - equal( jQuery( this ).height(), 100, "Height is 100" ); + assert.equal( jQuery( this ).height(), 100, "Height is 100" ); } } ); @@ -2002,7 +2002,7 @@ jQuery.map( [ "toggle", "slideToggle", "fadeToggle" ], function( method ) { // this test would look a lot better if we were using something to override // the default timers var duration = 1500; - test( "toggle state tests: " + method + " (#8685)", function() { + QUnit.test( "toggle state tests: " + method + " (#8685)", function( assert ) { function secondToggle() { var stopped = parseFloat( element.css( check ) ); tested = false; @@ -2011,8 +2011,8 @@ jQuery.map( [ "toggle", "slideToggle", "fadeToggle" ], function( method ) { step: function( p, fx ) { if ( fx.pos > 0.1 && fx.prop === check && !tested ) { tested = true; - equal( fx.start, stopped, check + " starts at " + stopped + " where it stopped" ); - equal( fx.end, original, check + " ending value is " + original ); + assert.equal( fx.start, stopped, check + " starts at " + stopped + " where it stopped" ); + assert.equal( fx.end, original, check + " ending value is " + original ); element.stop(); } } @@ -2024,7 +2024,7 @@ jQuery.map( [ "toggle", "slideToggle", "fadeToggle" ], function( method ) { check = method === "slideToggle" ? "height" : "opacity", element = jQuery( "#foo" ).height( 200 ); - expect( 4 ); + assert.expect( 4 ); element[ method ]( { duration: duration, @@ -2033,8 +2033,8 @@ jQuery.map( [ "toggle", "slideToggle", "fadeToggle" ], function( method ) { if ( fx.pos > 0.1 && fx.prop === check && !tested ) { tested = true; original = fx.start; - ok( fx.start !== 0, check + " is starting at " + original + " on first toggle (non-zero)" ); - equal( fx.end, 0, check + " is ending at 0 on first toggle" ); + assert.ok( fx.start !== 0, check + " is starting at " + original + " on first toggle (non-zero)" ); + assert.equal( fx.end, 0, check + " is ending at 0 on first toggle" ); element.stop(); } }, @@ -2046,18 +2046,18 @@ jQuery.map( [ "toggle", "slideToggle", "fadeToggle" ], function( method ) { } ); } ); -test( "jQuery.fx.start & jQuery.fx.stop hook points", function() { +QUnit.test( "jQuery.fx.start & jQuery.fx.stop hook points", function( assert ) { var oldStart = jQuery.fx.start, oldStop = jQuery.fx.stop, foo = jQuery( { foo: 0 } ); - expect( 3 ); + assert.expect( 3 ); jQuery.fx.start = function() { - ok( true, "start called" ); + assert.ok( true, "start called" ); }; jQuery.fx.stop = function() { - ok( true, "stop called" ); + assert.ok( true, "stop called" ); }; // calls start @@ -2075,7 +2075,7 @@ test( "jQuery.fx.start & jQuery.fx.stop hook points", function() { jQuery.fx.stop = oldStop; } ); -test( ".finish() completes all queued animations", function() { +QUnit.test( ".finish() completes all queued animations", function( assert ) { var animations = { top: 100, left: 100, @@ -2084,7 +2084,7 @@ test( ".finish() completes all queued animations", function() { }, div = jQuery( "<div>" ); - expect( 11 ); + assert.expect( 11 ); jQuery.each( animations, function( prop, value ) { var anim = {}; @@ -2092,16 +2092,16 @@ test( ".finish() completes all queued animations", function() { // the delay shouldn't matter at all! div.css( prop, 1 ).animate( anim, function() { - ok( true, "Called animation callback for " + prop ); + assert.ok( true, "Called animation callback for " + prop ); } ).delay( 100 ); } ); - equal( div.queue().length, 8, "8 animations in the queue" ); + assert.equal( div.queue().length, 8, "8 animations in the queue" ); div.finish(); jQuery.each( animations, function( prop, value ) { - equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" ); + assert.equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" ); } ); - equal( div.queue().length, 0, "empty queue when done" ); - equal( div.is( ":animated" ), false, ":animated doesn't match" ); + assert.equal( div.queue().length, 0, "empty queue when done" ); + assert.equal( div.is( ":animated" ), false, ":animated doesn't match" ); // cleanup div.remove(); @@ -2110,7 +2110,7 @@ test( ".finish() completes all queued animations", function() { jQuery.fx.tick(); } ); -test( ".finish( false ) - unqueued animations", function() { +QUnit.test( ".finish( false ) - unqueued animations", function( assert ) { var animations = { top: 100, left: 100, @@ -2119,7 +2119,7 @@ test( ".finish( false ) - unqueued animations", function() { }, div = jQuery( "<div>" ); - expect( 10 ); + assert.expect( 10 ); jQuery.each( animations, function( prop, value ) { var anim = {}; @@ -2127,16 +2127,16 @@ test( ".finish( false ) - unqueued animations", function() { div.css( prop, 1 ).animate( anim, { queue: false, complete: function() { - ok( true, "Called animation callback for " + prop ); + assert.ok( true, "Called animation callback for " + prop ); } } ); } ); - equal( div.queue().length, 0, "0 animations in the queue" ); + assert.equal( div.queue().length, 0, "0 animations in the queue" ); div.finish( false ); jQuery.each( animations, function( prop, value ) { - equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" ); + assert.equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" ); } ); - equal( div.is( ":animated" ), false, ":animated doesn't match" ); + assert.equal( div.is( ":animated" ), false, ":animated doesn't match" ); // cleanup div.remove(); @@ -2145,7 +2145,7 @@ test( ".finish( false ) - unqueued animations", function() { jQuery.fx.tick(); } ); -test( ".finish( \"custom\" ) - custom queue animations", function() { +QUnit.test( ".finish( \"custom\" ) - custom queue animations", function( assert ) { var animations = { top: 100, left: 100, @@ -2154,7 +2154,7 @@ test( ".finish( \"custom\" ) - custom queue animations", function() { }, div = jQuery( "<div>" ); - expect( 11 ); + assert.expect( 11 ); jQuery.each( animations, function( prop, value ) { var anim = {}; @@ -2162,20 +2162,20 @@ test( ".finish( \"custom\" ) - custom queue animations", function() { div.css( prop, 1 ).animate( anim, { queue: "custom", complete: function() { - ok( true, "Called animation callback for " + prop ); + assert.ok( true, "Called animation callback for " + prop ); } } ); } ); - equal( div.queue( "custom" ).length, 4, "4 animations in the queue" ); + assert.equal( div.queue( "custom" ).length, 4, "4 animations in the queue" ); // start the first animation div.dequeue( "custom" ); - equal( div.is( ":animated" ), true, ":animated matches" ); + assert.equal( div.is( ":animated" ), true, ":animated matches" ); div.finish( "custom" ); jQuery.each( animations, function( prop, value ) { - equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" ); + assert.equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" ); } ); - equal( div.is( ":animated" ), false, ":animated doesn't match" ); + assert.equal( div.is( ":animated" ), false, ":animated doesn't match" ); // cleanup div.remove(); @@ -2184,51 +2184,51 @@ test( ".finish( \"custom\" ) - custom queue animations", function() { jQuery.fx.tick(); } ); -test( ".finish() calls finish of custom queue functions", function() { +QUnit.test( ".finish() calls finish of custom queue functions", function( assert ) { function queueTester( next, hooks ) { hooks.stop = function( gotoEnd ) { inside++; - equal( this, div[ 0 ] ); - ok( gotoEnd, "hooks.stop(true) called" ); + assert.equal( this, div[ 0 ] ); + assert.ok( gotoEnd, "hooks.stop(true) called" ); }; } var div = jQuery( "<div>" ), inside = 0, outside = 0; - expect( 6 ); + assert.expect( 6 ); queueTester.finish = function() { outside++; - ok( true, "Finish called on custom queue function" ); + assert.ok( true, "Finish called on custom queue function" ); }; div.queue( queueTester ).queue( queueTester ).queue( queueTester ).finish(); - equal( inside, 1, "1 stop(true) callback" ); - equal( outside, 2, "2 finish callbacks" ); + assert.equal( inside, 1, "1 stop(true) callback" ); + assert.equal( outside, 2, "2 finish callbacks" ); div.remove(); } ); -test( ".finish() is applied correctly when multiple elements were animated (#13937)", function() { - expect( 3 ); +QUnit.test( ".finish() is applied correctly when multiple elements were animated (#13937)", function( assert ) { + assert.expect( 3 ); var elems = jQuery( "<a>0</a><a>1</a><a>2</a>" ); elems.animate( { opacity: 0 }, 1500 ).animate( { opacity: 1 }, 1500 ); setTimeout( function() { elems.eq( 1 ).finish(); - ok( !elems.eq( 1 ).queue().length, "empty queue for .finish()ed element" ); - ok( elems.eq( 0 ).queue().length, "non-empty queue for preceding element" ); - ok( elems.eq( 2 ).queue().length, "non-empty queue for following element" ); + assert.ok( !elems.eq( 1 ).queue().length, "empty queue for .finish()ed element" ); + assert.ok( elems.eq( 0 ).queue().length, "non-empty queue for preceding element" ); + assert.ok( elems.eq( 2 ).queue().length, "non-empty queue for following element" ); elems.stop( true ); }, 100 ); this.clock.tick( 1500 ); } ); -test( "slideDown() after stop() (#13483)", function() { - expect( 2 ); +QUnit.test( "slideDown() after stop() (#13483)", function( assert ) { + assert.expect( 2 ); var ul = jQuery( "<ul style='height: 100px; display: block;'></ul>" ) .appendTo( "#qunit-fixture" ), @@ -2240,7 +2240,7 @@ test( "slideDown() after stop() (#13483)", function() { clock.tick( 500 ); ul.stop( true ); ul.slideDown( 1, function() { - equal( ul.height(), origHeight, "slideDown() after interrupting slideUp() with stop(). Height must be in original value" ); + assert.equal( ul.height(), origHeight, "slideDown() after interrupting slideUp() with stop(). Height must be in original value" ); // Second test. slideDown() -> stop() in the middle -> slideDown() until the end ul.slideUp( 1 ); @@ -2249,7 +2249,7 @@ test( "slideDown() after stop() (#13483)", function() { clock.tick( 500 ); ul.stop( true ); ul.slideDown( 1 ); - equal( ul.height(), origHeight, "slideDown() after interrupting slideDown() with stop(). Height must be in original value" ); + assert.equal( ul.height(), origHeight, "slideDown() after interrupting slideDown() with stop(). Height must be in original value" ); // Cleanup ul.remove(); @@ -2260,8 +2260,8 @@ test( "slideDown() after stop() (#13483)", function() { clock.tick( 10 ); } ); -test( "Respect display value on inline elements (#14824)", function() { - expect( 2 ); +QUnit.test( "Respect display value on inline elements (#14824)", function( assert ) { + assert.expect( 2 ); var clock = this.clock, fromStyleSheet = jQuery( "<span id='span-14824' />" ), @@ -2271,14 +2271,14 @@ test( "Respect display value on inline elements (#14824)", function() { fromStyleSheet.slideUp( function() { jQuery( this ).slideDown( function() { - equal( jQuery( this ).css( "display" ), "block", + assert.equal( jQuery( this ).css( "display" ), "block", "Respect previous display value (from stylesheet) on span element" ); } ); } ); fromStyleAttr.slideUp( function() { jQuery( this ).slideDown( function() { - equal( jQuery( this ).css( "display" ), "block", + assert.equal( jQuery( this ).css( "display" ), "block", "Respect previous display value (from style attribute) on span element" ); } ); } ); @@ -2286,14 +2286,14 @@ test( "Respect display value on inline elements (#14824)", function() { clock.tick( 800 ); } ); -test( "jQuery.easing._default (gh-2218)", function() { - expect( 2 ); +QUnit.test( "jQuery.easing._default (gh-2218)", function( assert ) { + assert.expect( 2 ); jQuery( "#foo" ) .animate( { width: "5px" }, { duration: 5, start: function( anim ) { - equal( anim.opts.easing, jQuery.easing._default, + assert.equal( anim.opts.easing, jQuery.easing._default, "anim.opts.easing should be equal to jQuery.easing._default when the easing argument is not given" ); } } ) @@ -2301,7 +2301,7 @@ test( "jQuery.easing._default (gh-2218)", function() { duration: 5, easing: "linear", start: function( anim ) { - equal( anim.opts.easing, "linear", + assert.equal( anim.opts.easing, "linear", "anim.opts.easing should be equal to the easing argument" ); } } ) @@ -2310,8 +2310,8 @@ test( "jQuery.easing._default (gh-2218)", function() { this.clock.tick( 25 ); } ); -test( "jQuery.easing._default in Animation (gh-2218", function() { - expect( 3 ); +QUnit.test( "jQuery.easing._default in Animation (gh-2218", function( assert ) { + assert.expect( 3 ); var animation, defaultEasing = jQuery.easing._default, @@ -2327,9 +2327,9 @@ test( "jQuery.easing._default in Animation (gh-2218", function() { animation = jQuery.Animation( testObject, testDest, { "duration": 1 } ); animation.done( function() { - equal( testObject.width, testDest.width, "Animated width" ); - ok( called, "Custom jQuery.easing._default called" ); - strictEqual( animation.opts.easing, "custom", + assert.equal( testObject.width, testDest.width, "Animated width" ); + assert.ok( called, "Custom jQuery.easing._default called" ); + assert.strictEqual( animation.opts.easing, "custom", "Animation used custom jQuery.easing._default" ); jQuery.easing._default = defaultEasing; delete jQuery.easing.custom; @@ -2338,8 +2338,8 @@ test( "jQuery.easing._default in Animation (gh-2218", function() { this.clock.tick( 10 ); } ); -test( "jQuery.easing._default in Tween (gh-2218)", function() { - expect( 3 ); +QUnit.test( "jQuery.easing._default in Tween (gh-2218)", function( assert ) { + assert.expect( 3 ); var tween, defaultEasing = jQuery.easing._default, @@ -2354,35 +2354,35 @@ test( "jQuery.easing._default in Tween (gh-2218)", function() { tween = jQuery.Tween( testObject, { "duration": 1 }, "width", 200 ); tween.run( 1 ); - equal( testObject.width, 200, "Animated width" ); - ok( called, "Custom jQuery.easing._default called" ); - strictEqual( tween.easing, "custom", + assert.equal( testObject.width, 200, "Animated width" ); + assert.ok( called, "Custom jQuery.easing._default called" ); + assert.strictEqual( tween.easing, "custom", "Animation used custom jQuery.easing._default" ); jQuery.easing._default = defaultEasing; delete jQuery.easing.custom; } ); -test( "Display value is correct for disconnected nodes (trac-13310)", function() { - expect( 3 ); +QUnit.test( "Display value is correct for disconnected nodes (trac-13310)", function( assert ) { + assert.expect( 3 ); var div = jQuery( "<div/>" ); - equal( div.css( "display", "inline" ).hide().show().appendTo( "body" ).css( "display" ), "inline", "Initialized display value has returned" ); + assert.equal( div.css( "display", "inline" ).hide().show().appendTo( "body" ).css( "display" ), "inline", "Initialized display value has returned" ); div.remove(); div.css( "display", "none" ).hide(); - equal( jQuery._data( div[ 0 ], "display" ), undefined, "display data is undefined after hiding a detached and hidden element" ); + assert.equal( jQuery._data( div[ 0 ], "display" ), undefined, "display data is undefined after hiding a detached and hidden element" ); div.remove(); div.css( "display", "inline-block" ).hide().appendTo( "body" ).fadeIn( function() { - equal( div.css( "display" ), "inline-block", "Initialized display value has returned" ); + assert.equal( div.css( "display" ), "inline-block", "Initialized display value has returned" ); div.remove(); } ); this.clock.tick( 1000 ); } ); -test( "Show/hide/toggle and display: inline", function() { - expect( 40 ); +QUnit.test( "Show/hide/toggle and display: inline", function( assert ) { + assert.expect( 40 ); var clock = this.clock; @@ -2416,7 +2416,7 @@ test( "Show/hide/toggle and display: inline", function() { jQuery( completed ).each( function() { var $el = jQuery( this ), call = $el.data( "call" ); - strictEqual( $el.css( "display" ), "inline-block", kind + " display during " + call ); + assert.strictEqual( $el.css( "display" ), "inline-block", kind + " display during " + call ); } ); // Interrupted elements should remain inline-block @@ -2425,7 +2425,7 @@ test( "Show/hide/toggle and display: inline", function() { jQuery( interrupted ).each( function() { var $el = jQuery( this ), call = $el.data( "call" ); - strictEqual( $el.css( "display" ), "inline-block", kind + " display after " + call ); + assert.strictEqual( $el.css( "display" ), "inline-block", kind + " display after " + call ); } ); // Completed elements should not remain inline-block @@ -2434,7 +2434,7 @@ test( "Show/hide/toggle and display: inline", function() { var $el = jQuery( this ), call = $el.data( "call" ), display = $el.data( "done" ); - strictEqual( $el.css( "display" ), display, kind + " display after " + call ); + assert.strictEqual( $el.css( "display" ), display, kind + " display after " + call ); } ); // A post-animation toggle should not make any element inline-block @@ -2444,7 +2444,7 @@ test( "Show/hide/toggle and display: inline", function() { completed.each( function() { var $el = jQuery( this ), call = $el.data( "call" ); - ok( $el.css( "display" ) !== "inline-block", + assert.ok( $el.css( "display" ) !== "inline-block", kind + " display is not inline-block after " + call + "+toggle" ); } ); } ); diff --git a/test/unit/event.js b/test/unit/event.js index 91ab5e08b..d31795632 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -1,16 +1,16 @@ -module( "event", { +QUnit.module( "event", { setup: function() { document.body.focus(); }, teardown: moduleTeardown } ); -test( "on() with non-null,defined data", function() { +QUnit.test( "on() with non-null,defined data", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var handler = function( event, data ) { - equal( data, 0, "non-null, defined data (zero) is correctly passed" ); + assert.equal( data, 0, "non-null, defined data (zero) is correctly passed" ); }; jQuery( "#foo" ).on( "foo.on", handler ); @@ -23,8 +23,8 @@ test( "on() with non-null,defined data", function() { } ); -test( "Handler changes and .trigger() order", function() { - expect( 1 ); +QUnit.test( "Handler changes and .trigger() order", function( assert ) { + assert.expect( 1 ); var markup = jQuery( "<div><div><p><span><b class=\"a\">b</b></span></p></div></div>" @@ -45,54 +45,54 @@ test( "Handler changes and .trigger() order", function() { markup.find( "b" ).trigger( "click" ); - equal( path, "b p div div ", "Delivered all events" ); + assert.equal( path, "b p div div ", "Delivered all events" ); markup.remove(); } ); -test( "on(), with data", function() { - expect( 4 ); +QUnit.test( "on(), with data", function( assert ) { + assert.expect( 4 ); var test, handler, handler2; handler = function( event ) { - ok( event.data, "on() with data, check passed data exists" ); - equal( event.data[ "foo" ], "bar", "on() with data, Check value of passed data" ); + assert.ok( event.data, "on() with data, check passed data exists" ); + assert.equal( event.data[ "foo" ], "bar", "on() with data, Check value of passed data" ); }; jQuery( "#firstp" ).on( "click", { "foo": "bar" }, handler ).trigger( "click" ).off( "click", handler ); - ok( !jQuery._data( jQuery( "#firstp" )[ 0 ], "events" ), "Event handler unbound when using data." ); + assert.ok( !jQuery._data( jQuery( "#firstp" )[ 0 ], "events" ), "Event handler unbound when using data." ); test = function() {}; handler2 = function( event ) { - equal( event.data, test, "on() with function data, Check value of passed data" ); + assert.equal( event.data, test, "on() with function data, Check value of passed data" ); }; jQuery( "#firstp" ).on( "click", test, handler2 ).trigger( "click" ).off( "click", handler2 ); } ); -test( "click(), with data", function() { - expect( 3 ); +QUnit.test( "click(), with data", function( assert ) { + assert.expect( 3 ); var handler = function( event ) { - ok( event.data, "on() with data, check passed data exists" ); - equal( event.data[ "foo" ], "bar", "on() with data, Check value of passed data" ); + assert.ok( event.data, "on() with data, check passed data exists" ); + assert.equal( event.data[ "foo" ], "bar", "on() with data, Check value of passed data" ); }; jQuery( "#firstp" ).on( "click", { "foo": "bar" }, handler ).trigger( "click" ).off( "click", handler ); - ok( !jQuery._data( jQuery( "#firstp" )[ 0 ], "events" ), "Event handler unbound when using data." ); + assert.ok( !jQuery._data( jQuery( "#firstp" )[ 0 ], "events" ), "Event handler unbound when using data." ); } ); -test( "on(), with data, trigger with data", function() { - expect( 4 ); +QUnit.test( "on(), with data, trigger with data", function( assert ) { + assert.expect( 4 ); var handler = function( event, data ) { - ok( event.data, "check passed data exists" ); - equal( event.data.foo, "bar", "Check value of passed data" ); - ok( data, "Check trigger data" ); - equal( data.bar, "foo", "Check value of trigger data" ); + assert.ok( event.data, "check passed data exists" ); + assert.equal( event.data.foo, "bar", "Check value of passed data" ); + assert.ok( data, "Check trigger data" ); + assert.equal( data.bar, "foo", "Check value of trigger data" ); }; jQuery( "#firstp" ).on( "click", { foo: "bar" }, handler ).trigger( "click", [ { bar: "foo" } ] ).off( "click", handler ); } ); -test( "on(), multiple events at once", function() { - expect( 2 ); +QUnit.test( "on(), multiple events at once", function( assert ) { + assert.expect( 2 ); var handler, clickCounter = 0, mouseoverCounter = 0; @@ -105,12 +105,12 @@ test( "on(), multiple events at once", function() { }; jQuery( "#firstp" ).on( "click mouseover", handler ).trigger( "click" ).trigger( "mouseover" ); - equal( clickCounter, 1, "on() with multiple events at once" ); - equal( mouseoverCounter, 1, "on() with multiple events at once" ); + assert.equal( clickCounter, 1, "on() with multiple events at once" ); + assert.equal( mouseoverCounter, 1, "on() with multiple events at once" ); } ); -test( "on(), five events at once", function() { - expect( 1 ); +QUnit.test( "on(), five events at once", function( assert ) { + assert.expect( 1 ); var count = 0, handler = function() { @@ -122,17 +122,17 @@ test( "on(), five events at once", function() { .trigger( "foo" ).trigger( "bar" ) .trigger( "baz" ); - equal( count, 5, "on() five events at once" ); + assert.equal( count, 5, "on() five events at once" ); } ); -test( "on(), multiple events at once and namespaces", function() { - expect( 7 ); +QUnit.test( "on(), multiple events at once and namespaces", function( assert ) { + assert.expect( 7 ); var cur, div, obj = {}; div = jQuery( "<div/>" ).on( "focusin.a", function( e ) { - equal( e.type, cur, "Verify right single event was fired." ); + assert.equal( e.type, cur, "Verify right single event was fired." ); } ); cur = "focusin"; @@ -142,8 +142,8 @@ test( "on(), multiple events at once and namespaces", function() { div.remove(); div = jQuery( "<div/>" ).on( "click mouseover", obj, function( e ) { - equal( e.type, cur, "Verify right multi event was fired." ); - equal( e.data, obj, "Make sure the data came in correctly." ); + assert.equal( e.type, cur, "Verify right multi event was fired." ); + assert.equal( e.data, obj, "Make sure the data came in correctly." ); } ); cur = "click"; @@ -156,7 +156,7 @@ test( "on(), multiple events at once and namespaces", function() { div.remove(); div = jQuery( "<div/>" ).on( "focusin.a focusout.b", function( e ) { - equal( e.type, cur, "Verify right multi event was fired." ); + assert.equal( e.type, cur, "Verify right multi event was fired." ); } ); cur = "focusin"; @@ -169,24 +169,24 @@ test( "on(), multiple events at once and namespaces", function() { div.remove(); } ); -test( "on(), namespace with special add", function() { - expect( 27 ); +QUnit.test( "on(), namespace with special add", function( assert ) { + assert.expect( 27 ); var i = 0, div = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ).on( "test", function() { - ok( true, "Test event fired." ); + assert.ok( true, "Test event fired." ); } ); jQuery.event.special[ "test" ] = { _default: function( e, data ) { - equal( e.type, "test", "Make sure we're dealing with a test event." ); - ok( data, "And that trigger data was passed." ); - strictEqual( e.target, div[ 0 ], "And that the target is correct." ); - equal( this, window, "And that the context is correct." ); + assert.equal( e.type, "test", "Make sure we're dealing with a test event." ); + assert.ok( data, "And that trigger data was passed." ); + assert.strictEqual( e.target, div[ 0 ], "And that the target is correct." ); + assert.equal( this, window, "And that the context is correct." ); }, setup: function() {}, teardown: function() { - ok( true, "Teardown called." ); + assert.ok( true, "Teardown called." ); }, add: function( handleObj ) { var handler = handleObj.handler; @@ -196,18 +196,18 @@ test( "on(), namespace with special add", function() { }; }, remove: function() { - ok( true, "Remove called." ); + assert.ok( true, "Remove called." ); } }; div.on( "test.a", { x: 1 }, function( e ) { - ok( !!e.xyz, "Make sure that the data is getting passed through." ); - equal( e.data[ "x" ], 1, "Make sure data is attached properly." ); + assert.ok( !!e.xyz, "Make sure that the data is getting passed through." ); + assert.equal( e.data[ "x" ], 1, "Make sure data is attached properly." ); } ); div.on( "test.b", { x: 2 }, function( e ) { - ok( !!e.xyz, "Make sure that the data is getting passed through." ); - equal( e.data[ "x" ], 2, "Make sure data is attached properly." ); + assert.ok( !!e.xyz, "Make sure that the data is getting passed through." ); + assert.equal( e.data[ "x" ], 2, "Make sure data is attached properly." ); } ); // Should trigger 5 @@ -223,7 +223,7 @@ test( "on(), namespace with special add", function() { div.off( "test" ); div = jQuery( "<div/>" ).on( "test", function() { - ok( true, "Test event fired." ); + assert.ok( true, "Test event fired." ); } ); // Should trigger 2 @@ -232,16 +232,16 @@ test( "on(), namespace with special add", function() { delete jQuery.event.special[ "test" ]; } ); -test( "on(), no data", function() { - expect( 1 ); +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" ); }; jQuery( "#firstp" ).on( "click", handler ).trigger( "click" ); } ); -test( "on/one/off(Object)", function() { - expect( 6 ); +QUnit.test( "on/one/off(Object)", function( assert ) { + assert.expect( 6 ); var $elem, clickCounter = 0, @@ -283,12 +283,12 @@ test( "on/one/off(Object)", function() { trigger(); - equal( clickCounter, 3, "on(Object)" ); - equal( mouseoverCounter, 3, "on(Object)" ); + assert.equal( clickCounter, 3, "on(Object)" ); + assert.equal( mouseoverCounter, 3, "on(Object)" ); trigger(); - equal( clickCounter, 4, "on(Object)" ); - equal( mouseoverCounter, 4, "on(Object)" ); + assert.equal( clickCounter, 4, "on(Object)" ); + assert.equal( mouseoverCounter, 4, "on(Object)" ); jQuery( "#firstp" ).off( { "click":handler, @@ -296,12 +296,12 @@ test( "on/one/off(Object)", function() { } ); trigger(); - equal( clickCounter, 4, "on(Object)" ); - equal( mouseoverCounter, 4, "on(Object)" ); + assert.equal( clickCounter, 4, "on(Object)" ); + assert.equal( mouseoverCounter, 4, "on(Object)" ); } ); -test( "on/off(Object), on/off(Object, String)", function() { - expect( 6 ); +QUnit.test( "on/off(Object), on/off(Object, String)", function( assert ) { + assert.expect( 6 ); var events, clickCounter = 0, @@ -326,24 +326,24 @@ test( "on/off(Object), on/off(Object, String)", function() { $p.on( events, "a", 2 ); trigger(); - equal( clickCounter, 3, "on" ); - equal( mouseoverCounter, 3, "on" ); + assert.equal( clickCounter, 3, "on" ); + assert.equal( mouseoverCounter, 3, "on" ); $p.off( events, "a" ); trigger(); - equal( clickCounter, 4, "off" ); - equal( mouseoverCounter, 4, "off" ); + assert.equal( clickCounter, 4, "off" ); + assert.equal( mouseoverCounter, 4, "off" ); jQuery( document ).off( events, "#firstp a" ); trigger(); - equal( clickCounter, 4, "off" ); - equal( mouseoverCounter, 4, "off" ); + assert.equal( clickCounter, 4, "off" ); + assert.equal( mouseoverCounter, 4, "off" ); } ); -test( "on immediate propagation", function() { - expect( 2 ); +QUnit.test( "on immediate propagation", function( assert ) { + assert.expect( 2 ); var lastClick, $p = jQuery( "#firstp" ), @@ -358,7 +358,7 @@ test( "on immediate propagation", function() { lastClick = "click2"; } ); $a.trigger( "click" ); - equal( lastClick, "click1", "on stopImmediatePropagation" ); + assert.equal( lastClick, "click1", "on stopImmediatePropagation" ); jQuery( document ).off( "click", "#firstp a" ); lastClick = ""; @@ -370,16 +370,16 @@ test( "on immediate propagation", function() { lastClick = "click2"; } ); $a.trigger( "click" ); - equal( lastClick, "click1", "on stopImmediatePropagation" ); + assert.equal( lastClick, "click1", "on stopImmediatePropagation" ); $p.off( "click", "**" ); } ); -test( "on bubbling, isDefaultPrevented, stopImmediatePropagation", function() { - expect( 3 ); +QUnit.test( "on bubbling, isDefaultPrevented, stopImmediatePropagation", function( assert ) { + assert.expect( 3 ); var $anchor2 = jQuery( "#anchor2" ), $main = jQuery( "#qunit-fixture" ), neverCallMe = function() { - ok( false, "immediate propagation should have been stopped" ); + assert.ok( false, "immediate propagation should have been stopped" ); }, fakeClick = function( $jq ) { @@ -396,7 +396,7 @@ test( "on bubbling, isDefaultPrevented, stopImmediatePropagation", function() { e.preventDefault(); } ); $main.on( "click", "#foo", function( e ) { - equal( e.isDefaultPrevented(), true, "isDefaultPrevented true passed to bubbled event" ); + assert.equal( e.isDefaultPrevented(), true, "isDefaultPrevented true passed to bubbled event" ); } ); fakeClick( $anchor2 ); $anchor2.off( "click" ); @@ -406,7 +406,7 @@ test( "on bubbling, isDefaultPrevented, stopImmediatePropagation", function() { // Let the default action occur } ); $main.on( "click", "#foo", function( e ) { - equal( e.isDefaultPrevented(), false, "isDefaultPrevented false passed to bubbled event" ); + assert.equal( e.isDefaultPrevented(), false, "isDefaultPrevented false passed to bubbled event" ); } ); fakeClick( $anchor2 ); $anchor2.off( "click" ); @@ -416,11 +416,11 @@ test( "on bubbling, isDefaultPrevented, stopImmediatePropagation", function() { // in such a case. // Support: Android 2.3 if ( !window.addEventListener || /android 2\.3/i.test( navigator.userAgent ) ) { - ok( true, "Old IE or Android 2.3, skipping native stopImmediatePropagation check" ); + assert.ok( true, "Old IE or Android 2.3, skipping native stopImmediatePropagation check" ); } else { $anchor2.on( "click", function( e ) { e.stopImmediatePropagation(); - ok( true, "anchor was clicked and prop stopped" ); + assert.ok( true, "anchor was clicked and prop stopped" ); } ); $anchor2[ 0 ].addEventListener( "click", neverCallMe, false ); fakeClick( $anchor2 ); @@ -428,49 +428,49 @@ test( "on bubbling, isDefaultPrevented, stopImmediatePropagation", function() { } } ); -test( "on(), iframes", function() { - expect( 1 ); +QUnit.test( "on(), iframes", function( assert ) { + assert.expect( 1 ); // events don't work with iframes, see #939 - this test fails in IE because of contentDocument var doc = jQuery( "#loadediframe" ).contents(); jQuery( "div", doc ).on( "click", function() { - ok( true, "Binding to element inside iframe" ); + assert.ok( true, "Binding to element inside iframe" ); } ).trigger( "click" ).off( "click" ); } ); -test( "on(), trigger change on select", function() { - expect( 5 ); +QUnit.test( "on(), trigger change on select", function( assert ) { + assert.expect( 5 ); var counter = 0; function selectOnChange( event ) { - equal( event.data, counter++, "Event.data is not a global event object" ); + assert.equal( event.data, counter++, "Event.data is not a global event object" ); } jQuery( "#form select" ).each( function( i ) { jQuery( this ).on( "change", i, selectOnChange ); } ).trigger( "change" ); } ); -test( "on(), namespaced events, cloned events", function() { - expect( 18 ); +QUnit.test( "on(), namespaced events, cloned events", function( assert ) { + assert.expect( 18 ); var firstp = jQuery( "#firstp" ); firstp.on( "custom.test", function() { - ok( false, "Custom event triggered" ); + assert.ok( false, "Custom event triggered" ); } ); firstp.on( "click", function( e ) { - ok( true, "Normal click triggered" ); - equal( e.type + e.namespace, "click", "Check that only click events trigger this fn" ); + assert.ok( true, "Normal click triggered" ); + assert.equal( e.type + e.namespace, "click", "Check that only click events trigger this fn" ); } ); firstp.on( "click.test", function( e ) { var check = "click"; - ok( true, "Namespaced click triggered" ); + assert.ok( true, "Namespaced click triggered" ); if ( e.namespace ) { check += "test"; } - equal( e.type + e.namespace, check, "Check that only click/click.test events trigger this fn" ); + assert.equal( e.type + e.namespace, check, "Check that only click/click.test events trigger this fn" ); } ); //clone(true) element to verify events are cloned correctly @@ -496,16 +496,16 @@ test( "on(), namespaced events, cloned events", function() { // using contents will get comments regular, text, and comment nodes jQuery( "#nonnodes" ).contents().on( "tester", function() { - equal( this.nodeType, 1, "Check node,textnode,comment on just does real nodes" ); + assert.equal( this.nodeType, 1, "Check node,textnode,comment on just does real nodes" ); } ).trigger( "tester" ); // Make sure events stick with appendTo'd elements (which are cloned) #2027 jQuery( "<a href='#fail' class='test'>test</a>" ).on( "click", function() { return false; } ).appendTo( "#qunit-fixture" ); - ok( jQuery( "a.test" ).eq( 0 ).triggerHandler( "click" ) === false, "Handler is bound to appendTo'd elements" ); + assert.ok( jQuery( "a.test" ).eq( 0 ).triggerHandler( "click" ) === false, "Handler is bound to appendTo'd elements" ); } ); -test( "on(), multi-namespaced events", function() { - expect( 6 ); +QUnit.test( "on(), multi-namespaced events", function( assert ) { + assert.expect( 6 ); var order = [ "click.test.abc", @@ -517,7 +517,7 @@ test( "on(), multi-namespaced events", function() { ]; function check( name, msg ) { - deepEqual( name, order.shift(), msg ); + assert.deepEqual( name, order.shift(), msg ); } jQuery( "#firstp" ).on( "custom.test", function() { @@ -562,15 +562,15 @@ test( "on(), multi-namespaced events", function() { jQuery( "#firstp" ).trigger( "custom" ); } ); -test( "namespace-only event binding is a no-op", function() { - expect( 2 ); +QUnit.test( "namespace-only event binding is a no-op", function( assert ) { + assert.expect( 2 ); jQuery( "#firstp" ) .on( ".whoops", function() { - ok( false, "called a namespace-only event" ); + assert.ok( false, "called a namespace-only event" ); } ) .on( "whoops", function() { - ok( true, "called whoops" ); + assert.ok( true, "called whoops" ); } ) .trigger( "whoops" ) // 1 .off( ".whoops" ) @@ -578,19 +578,19 @@ test( "namespace-only event binding is a no-op", function() { .off( "whoops" ); } ); -test( "Empty namespace is ignored", function() { - expect( 1 ); +QUnit.test( "Empty namespace is ignored", function( assert ) { + assert.expect( 1 ); jQuery( "#firstp" ) .on( "meow.", function( e ) { - equal( e.namespace, "", "triggered a namespace-less meow event" ); + assert.equal( e.namespace, "", "triggered a namespace-less meow event" ); } ) .trigger( "meow." ) .off( "meow." ); } ); -test( "on(), with same function", function() { - expect( 2 ); +QUnit.test( "on(), with same function", function( assert ) { + assert.expect( 2 ); var count = 0, func = function() { count++; @@ -599,16 +599,16 @@ test( "on(), with same function", function() { jQuery( "#liveHandlerOrder" ).on( "foo.bar", func ).on( "foo.zar", func ); jQuery( "#liveHandlerOrder" ).trigger( "foo.bar" ); - equal( count, 1, "Verify binding function with multiple namespaces." ); + assert.equal( count, 1, "Verify binding function with multiple namespaces." ); jQuery( "#liveHandlerOrder" ).off( "foo.bar", func ).off( "foo.zar", func ); jQuery( "#liveHandlerOrder" ).trigger( "foo.bar" ); - equal( count, 1, "Verify that removing events still work." ); + assert.equal( count, 1, "Verify that removing events still work." ); } ); -test( "on(), make sure order is maintained", function() { - expect( 1 ); +QUnit.test( "on(), make sure order is maintained", function( assert ) { + assert.expect( 1 ); var elem = jQuery( "#firstp" ), log = [], check = []; @@ -623,75 +623,75 @@ test( "on(), make sure order is maintained", function() { elem.trigger( "click" ); - equal( log.join( "," ), check.join( "," ), "Make sure order was maintained." ); + assert.equal( log.join( "," ), check.join( "," ), "Make sure order was maintained." ); elem.off( "click" ); } ); -test( "on(), with different this object", function() { - expect( 4 ); +QUnit.test( "on(), with different this object", function( assert ) { + assert.expect( 4 ); var thisObject = { myThis: true }, data = { myData: true }, handler1 = function() { - equal( this, thisObject, "on() with different this object" ); + assert.equal( this, thisObject, "on() with different this object" ); }, handler2 = function( event ) { - equal( this, thisObject, "on() with different this object and data" ); - equal( event.data, data, "on() with different this object and data" ); + assert.equal( this, thisObject, "on() with different this object and data" ); + assert.equal( event.data, data, "on() with different this object and data" ); }; jQuery( "#firstp" ) .on( "click", jQuery.proxy( handler1, thisObject ) ).trigger( "click" ).off( "click", handler1 ) .on( "click", data, jQuery.proxy( handler2, thisObject ) ).trigger( "click" ).off( "click", handler2 ); - ok( !jQuery._data( jQuery( "#firstp" )[ 0 ], "events" ), "Event handler unbound when using different this object and data." ); + assert.ok( !jQuery._data( jQuery( "#firstp" )[ 0 ], "events" ), "Event handler unbound when using different this object and data." ); } ); -test( "on(name, false), off(name, false)", function() { - expect( 3 ); +QUnit.test( "on(name, false), off(name, false)", function( assert ) { + assert.expect( 3 ); var main = 0; jQuery( "#qunit-fixture" ).on( "click", function() { main++; } ); jQuery( "#ap" ).trigger( "click" ); - equal( main, 1, "Verify that the trigger happened correctly." ); + assert.equal( main, 1, "Verify that the trigger happened correctly." ); main = 0; jQuery( "#ap" ).on( "click", false ); jQuery( "#ap" ).trigger( "click" ); - equal( main, 0, "Verify that no bubble happened." ); + assert.equal( main, 0, "Verify that no bubble happened." ); main = 0; jQuery( "#ap" ).off( "click", false ); jQuery( "#ap" ).trigger( "click" ); - equal( main, 1, "Verify that the trigger happened correctly." ); + assert.equal( main, 1, "Verify that the trigger happened correctly." ); // manually clean up events from elements outside the fixture jQuery( "#qunit-fixture" ).off( "click" ); } ); -test( "on(name, selector, false), off(name, selector, false)", function() { - expect( 3 ); +QUnit.test( "on(name, selector, false), off(name, selector, false)", function( assert ) { + assert.expect( 3 ); var main = 0; jQuery( "#qunit-fixture" ).on( "click", "#ap", function() { main++; } ); jQuery( "#ap" ).trigger( "click" ); - equal( main, 1, "Verify that the trigger happened correctly." ); + assert.equal( main, 1, "Verify that the trigger happened correctly." ); main = 0; jQuery( "#ap" ).on( "click", "#groups", false ); jQuery( "#groups" ).trigger( "click" ); - equal( main, 0, "Verify that no bubble happened." ); + assert.equal( main, 0, "Verify that no bubble happened." ); main = 0; jQuery( "#ap" ).off( "click", "#groups", false ); jQuery( "#groups" ).trigger( "click" ); - equal( main, 1, "Verify that the trigger happened correctly." ); + assert.equal( main, 1, "Verify that the trigger happened correctly." ); jQuery( "#qunit-fixture" ).off( "click", "#ap" ); } ); -test( "on()/trigger()/off() on plain object", function() { - expect( 7 ); +QUnit.test( "on()/trigger()/off() on plain object", function( assert ) { + assert.expect( 7 ); var events, obj = {}; @@ -704,18 +704,18 @@ test( "on()/trigger()/off() on plain object", function() { jQuery( obj ).on( { "test": function() { - ok( true, "Custom event run." ); + assert.ok( true, "Custom event run." ); }, "submit": function() { - ok( true, "Custom submit event run." ); + assert.ok( true, "Custom submit event run." ); } } ); events = jQuery._data( obj, "events" ); - ok( events, "Object has events bound." ); - equal( obj[ "events" ], undefined, "Events object on plain objects is not events" ); - equal( obj[ "test" ], undefined, "Make sure that test event is not on the plain object." ); - equal( obj[ "handle" ], undefined, "Make sure that the event handler is not on the plain object." ); + assert.ok( events, "Object has events bound." ); + assert.equal( obj[ "events" ], undefined, "Events object on plain objects is not events" ); + assert.equal( obj[ "test" ], undefined, "Make sure that test event is not on the plain object." ); + assert.equal( obj[ "handle" ], undefined, "Make sure that the event handler is not on the plain object." ); // Should trigger 1 jQuery( obj ).trigger( "test" ); @@ -730,19 +730,19 @@ test( "on()/trigger()/off() on plain object", function() { // Make sure it doesn't complain when no events are found jQuery( obj ).off( "test" ); - equal( obj && obj[ jQuery.expando ] && + assert.equal( obj && obj[ jQuery.expando ] && obj[ jQuery.expando ][ jQuery.expando ] && obj[ jQuery.expando ][ jQuery.expando ][ "events" ], undefined, "Make sure events object is removed" ); } ); -test( "off(type)", function() { - expect( 1 ); +QUnit.test( "off(type)", function( assert ) { + assert.expect( 1 ); var message, func, $elem = jQuery( "#firstp" ); function error() { - ok( false, message ); + assert.ok( false, message ); } message = "unbind passing function"; @@ -771,7 +771,7 @@ test( "off(type)", function() { // Should only unbind the specified function jQuery( document ).on( "click", function() { - ok( true, "called handler after selective removal" ); + assert.ok( true, "called handler after selective removal" ); } ); func = function() {}; jQuery( document ) @@ -781,16 +781,16 @@ test( "off(type)", function() { .off( "click" ); } ); -test( "off(eventObject)", function() { - expect( 4 ); +QUnit.test( "off(eventObject)", function( assert ) { + assert.expect( 4 ); var $elem = jQuery( "#firstp" ), num; - function assert( expected ) { + function check( expected ) { num = 0; $elem.trigger( "foo" ).triggerHandler( "bar" ); - equal( num, expected, "Check the right handlers are triggered" ); + assert.equal( num, expected, "Check the right handlers are triggered" ); } $elem @@ -809,19 +809,19 @@ test( "off(eventObject)", function() { num += 4; } ); - assert( 7 ); - assert( 5 ); + check( 7 ); + check( 5 ); $elem.off( "bar" ); - assert( 1 ); + check( 1 ); $elem.off(); - assert( 0 ); + check( 0 ); } ); if ( jQuery.fn.hover ) { - test( "hover() mouseenter mouseleave", function() { - expect( 1 ); + QUnit.test( "hover() mouseenter mouseleave", function( assert ) { + assert.expect( 1 ); var times = 0, handler1 = function() { ++times; }, @@ -837,13 +837,13 @@ if ( jQuery.fn.hover ) { .off( "mouseenter mouseleave", handler1 ) .mouseenter().mouseleave(); - equal( times, 4, "hover handlers fired" ); + assert.equal( times, 4, "hover handlers fired" ); } ); } -test( "mouseover triggers mouseenter", function() { - expect( 1 ); +QUnit.test( "mouseover triggers mouseenter", function( assert ) { + assert.expect( 1 ); var count = 0, elem = jQuery( "<a />" ); @@ -851,13 +851,13 @@ test( "mouseover triggers mouseenter", function() { count++; } ); elem.trigger( "mouseover" ); - equal( count, 1, "make sure mouseover triggers a mouseenter" ); + assert.equal( count, 1, "make sure mouseover triggers a mouseenter" ); elem.remove(); } ); -test( "pointerover triggers pointerenter", function() { - expect( 1 ); +QUnit.test( "pointerover triggers pointerenter", function( assert ) { + assert.expect( 1 ); var count = 0, elem = jQuery( "<a />" ); @@ -865,20 +865,20 @@ test( "pointerover triggers pointerenter", function() { count++; } ); elem.trigger( "pointerover" ); - equal( count, 1, "make sure pointerover triggers a pointerenter" ); + assert.equal( count, 1, "make sure pointerover triggers a pointerenter" ); elem.remove(); } ); -test( "withinElement implemented with jQuery.contains()", function() { +QUnit.test( "withinElement implemented with jQuery.contains()", function( assert ) { - expect( 1 ); + assert.expect( 1 ); jQuery( "#qunit-fixture" ).append( "<div id='jc-outer'><div id='jc-inner'></div></div>" ); jQuery( "#jc-outer" ).on( "mouseenter mouseleave", function( event ) { - equal( this.id, "jc-outer", this.id + " " + event.type ); + assert.equal( this.id, "jc-outer", this.id + " " + event.type ); } ).trigger( "mouseenter" ); @@ -889,8 +889,8 @@ test( "withinElement implemented with jQuery.contains()", function() { } ); -test( "mouseenter, mouseleave don't catch exceptions", function() { - expect( 2 ); +QUnit.test( "mouseenter, mouseleave don't catch exceptions", function( assert ) { + assert.expect( 2 ); var elem = jQuery( "#firstp" ).on( "mouseenter mouseleave", function() { throw "an Exception"; @@ -899,27 +899,27 @@ test( "mouseenter, mouseleave don't catch exceptions", function() { try { elem.trigger( "mouseenter" ); } catch ( e ) { - equal( e, "an Exception", "mouseenter doesn't catch exceptions" ); + assert.equal( e, "an Exception", "mouseenter doesn't catch exceptions" ); } try { elem.trigger( "mouseleave" ); } catch ( e ) { - equal( e, "an Exception", "mouseleave doesn't catch exceptions" ); + assert.equal( e, "an Exception", "mouseleave doesn't catch exceptions" ); } } ); if ( jQuery.fn.click ) { - test( "trigger() shortcuts", function() { - expect( 5 ); + QUnit.test( "trigger() shortcuts", function( assert ) { + assert.expect( 5 ); var counter, clickCounter, elem = jQuery( "<li><a href='#'>Change location</a></li>" ).prependTo( "#firstUL" ); elem.find( "a" ).on( "click", function() { var close = jQuery( "spanx", this ); // same with jQuery(this).find("span"); - equal( close.length, 0, "Context element does not exist, length must be zero" ); - ok( !close[ 0 ], "Context element does not exist, direct access to element must return undefined" ); + 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(); @@ -927,7 +927,7 @@ if ( jQuery.fn.click ) { elem.remove(); jQuery( "#check1" ).click( function() { - ok( true, "click event handler for checkbox gets fired twice, see #815" ); + assert.ok( true, "click event handler for checkbox gets fired twice, see #815" ); } ).click(); counter = 0; @@ -935,14 +935,14 @@ if ( jQuery.fn.click ) { counter++; }; jQuery( "#firstp" ).click(); - equal( counter, 1, "Check that click, triggers onclick event handler also" ); + assert.equal( counter, 1, "Check that click, triggers onclick event handler also" ); clickCounter = 0; jQuery( "#simon1" )[ 0 ].onclick = function() { clickCounter++; }; jQuery( "#simon1" ).click(); - equal( clickCounter, 1, "Check that click, triggers onclick event handler on an a tag also" ); + 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( "<xml:namespace ns='urn:schemas-microsoft-com:vml' prefix='v' />" ).appendTo( "head" ); @@ -952,8 +952,8 @@ if ( jQuery.fn.click ) { } -test( "trigger() bubbling", function() { - expect( 18 ); +QUnit.test( "trigger() bubbling", function( assert ) { + assert.expect( 18 ); var win = 0, doc = 0, html = 0, body = 0, main = 0, ap = 0; @@ -965,32 +965,32 @@ test( "trigger() bubbling", function() { jQuery( "#ap" ).on( "click", function() { ap++; return false; } ); jQuery( "html" ).trigger( "click" ); - equal( win, 1, "HTML bubble" ); - equal( doc, 1, "HTML bubble" ); - equal( html, 1, "HTML bubble" ); + assert.equal( win, 1, "HTML bubble" ); + assert.equal( doc, 1, "HTML bubble" ); + assert.equal( html, 1, "HTML bubble" ); jQuery( "body" ).trigger( "click" ); - equal( win, 2, "Body bubble" ); - equal( doc, 2, "Body bubble" ); - equal( html, 2, "Body bubble" ); - equal( body, 1, "Body bubble" ); + assert.equal( win, 2, "Body bubble" ); + assert.equal( doc, 2, "Body bubble" ); + assert.equal( html, 2, "Body bubble" ); + assert.equal( body, 1, "Body bubble" ); jQuery( "#qunit-fixture" ).trigger( "click" ); - equal( win, 3, "Main bubble" ); - equal( doc, 3, "Main bubble" ); - equal( html, 3, "Main bubble" ); - equal( body, 2, "Main bubble" ); - equal( main, 1, "Main bubble" ); + assert.equal( win, 3, "Main bubble" ); + assert.equal( doc, 3, "Main bubble" ); + assert.equal( html, 3, "Main bubble" ); + assert.equal( body, 2, "Main bubble" ); + assert.equal( main, 1, "Main bubble" ); jQuery( "#ap" ).trigger( "click" ); - equal( doc, 3, "ap bubble" ); - equal( html, 3, "ap bubble" ); - equal( body, 2, "ap bubble" ); - equal( main, 1, "ap bubble" ); - equal( ap, 1, "ap bubble" ); + assert.equal( doc, 3, "ap bubble" ); + assert.equal( html, 3, "ap bubble" ); + assert.equal( body, 2, "ap bubble" ); + assert.equal( main, 1, "ap bubble" ); + assert.equal( ap, 1, "ap bubble" ); jQuery( document ).trigger( "click" ); - equal( win, 4, "doc bubble" ); + assert.equal( win, 4, "doc bubble" ); // manually clean up events from elements outside the fixture jQuery( window ).off( "click" ); @@ -998,15 +998,15 @@ test( "trigger() bubbling", function() { jQuery( "html, body, #qunit-fixture" ).off( "click" ); } ); -test( "trigger(type, [data], [fn])", function() { - expect( 16 ); +QUnit.test( "trigger(type, [data], [fn])", function( assert ) { + assert.expect( 16 ); var $elem, pass, form, elem2, handler = function( event, a, b, c ) { - equal( event.type, "click", "check passed data" ); - equal( a, 1, "check passed data" ); - equal( b, "2", "check passed data" ); - equal( c, "abc", "check passed data" ); + assert.equal( event.type, "click", "check passed data" ); + assert.equal( a, 1, "check passed data" ); + assert.equal( b, "2", "check passed data" ); + assert.equal( c, "abc", "check passed data" ); return "test"; }; @@ -1014,15 +1014,15 @@ test( "trigger(type, [data], [fn])", function() { // Simulate a "native" click $elem[ 0 ].click = function() { - ok( true, "Native call was triggered" ); + assert.ok( true, "Native call was triggered" ); }; jQuery( document ).on( "mouseenter", "#firstp", function() { - ok( true, "Trigger mouseenter bound by on" ); + assert.ok( true, "Trigger mouseenter bound by on" ); } ); jQuery( document ).on( "mouseleave", "#firstp", function() { - ok( true, "Trigger mouseleave bound by on" ); + assert.ok( true, "Trigger mouseleave bound by on" ); } ); $elem.trigger( "mouseenter" ); @@ -1037,12 +1037,12 @@ test( "trigger(type, [data], [fn])", function() { // Simulate a "native" click $elem[ 0 ].click = function() { - ok( false, "Native call was triggered" ); + assert.ok( false, "Native call was triggered" ); }; // Trigger only the handlers (no native) // Triggers 5 - equal( $elem.triggerHandler( "click", [ 1, "2", "abc" ] ), "test", "Verify handler response" ); + assert.equal( $elem.triggerHandler( "click", [ 1, "2", "abc" ] ), "test", "Verify handler response" ); pass = true; try { @@ -1052,7 +1052,7 @@ test( "trigger(type, [data], [fn])", function() { } catch ( e ) { pass = false; } - ok( pass, "Trigger focus on hidden element" ); + assert.ok( pass, "Trigger focus on hidden element" ); pass = true; try { @@ -1060,13 +1060,13 @@ test( "trigger(type, [data], [fn])", function() { } catch ( e ) { pass = false; } - ok( pass, "Trigger on a table with a colon in the even type, see #3533" ); + assert.ok( pass, "Trigger on a table with a colon in the even type, see #3533" ); form = jQuery( "<form action=''></form>" ).appendTo( "body" ); // Make sure it can be prevented locally form.on( "submit", function() { - ok( true, "Local `on` still works." ); + assert.ok( true, "Local `on` still works." ); return false; } ); @@ -1076,7 +1076,7 @@ test( "trigger(type, [data], [fn])", function() { form.off( "submit" ); jQuery( document ).on( "submit", function() { - ok( true, "Make sure bubble works up to document." ); + assert.ok( true, "Make sure bubble works up to document." ); return false; } ); @@ -1088,8 +1088,8 @@ test( "trigger(type, [data], [fn])", function() { form.remove(); } ); -test( "submit event bubbles on copied forms (#11649)", function() { - expect( 3 ); +QUnit.test( "submit event bubbles on copied forms (#11649)", function( assert ) { + assert.expect( 3 ); var $formByClone, $formByHTML, $testForm = jQuery( "#testForm" ), @@ -1100,7 +1100,7 @@ test( "submit event bubbles on copied forms (#11649)", function() { e.preventDefault(); } function delegatedSubmit() { - ok( true, "Make sure submit event bubbles up." ); + assert.ok( true, "Make sure submit event bubbles up." ); return false; } @@ -1124,8 +1124,8 @@ test( "submit event bubbles on copied forms (#11649)", function() { $testForm.off( "submit", noSubmit ); } ); -test( "change event bubbles on copied forms (#11796)", function() { - expect( 3 ); +QUnit.test( "change event bubbles on copied forms (#11796)", function( assert ) { + assert.expect( 3 ); var $formByClone, $formByHTML, $form = jQuery( "#form" ), @@ -1133,7 +1133,7 @@ test( "change event bubbles on copied forms (#11796)", function() { $wrapperDiv = jQuery( "<div/>" ).appendTo( $fixture ); function delegatedChange() { - ok( true, "Make sure change event bubbles up." ); + assert.ok( true, "Make sure change event bubbles up." ); return false; } @@ -1156,8 +1156,8 @@ test( "change event bubbles on copied forms (#11796)", function() { $fixture.off( "change", "form", delegatedChange ); } ); -test( "trigger(eventObject, [data], [fn])", function() { - expect( 28 ); +QUnit.test( "trigger(eventObject, [data], [fn])", function( assert ) { + assert.expect( 28 ); var event, $parent = jQuery( "<div id='par' />" ).appendTo( "body" ), @@ -1166,30 +1166,30 @@ test( "trigger(eventObject, [data], [fn])", function() { $parent.get( 0 ).style.display = "none"; event = jQuery.Event( "noNew" ); - ok( event !== window, "Instantiate jQuery.Event without the 'new' keyword" ); - equal( event.type, "noNew", "Verify its type" ); + assert.ok( event !== window, "Instantiate jQuery.Event without the 'new' keyword" ); + assert.equal( event.type, "noNew", "Verify its type" ); - equal( event.isDefaultPrevented(), false, "Verify isDefaultPrevented" ); - equal( event.isPropagationStopped(), false, "Verify isPropagationStopped" ); - equal( event.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" ); + assert.equal( event.isDefaultPrevented(), false, "Verify isDefaultPrevented" ); + assert.equal( event.isPropagationStopped(), false, "Verify isPropagationStopped" ); + assert.equal( event.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" ); event.preventDefault(); - equal( event.isDefaultPrevented(), true, "Verify isDefaultPrevented" ); + assert.equal( event.isDefaultPrevented(), true, "Verify isDefaultPrevented" ); event.stopPropagation(); - equal( event.isPropagationStopped(), true, "Verify isPropagationStopped" ); + assert.equal( event.isPropagationStopped(), true, "Verify isPropagationStopped" ); event.isPropagationStopped = function() { return false; }; event.stopImmediatePropagation(); - equal( event.isPropagationStopped(), true, "Verify isPropagationStopped" ); - equal( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" ); + assert.equal( event.isPropagationStopped(), true, "Verify isPropagationStopped" ); + assert.equal( event.isImmediatePropagationStopped(), true, "Verify isPropagationStopped" ); $parent.on( "foo", function( e ) { // Tries bubbling - equal( e.type, "foo", "Verify event type when passed passing an event object" ); - equal( e.target.id, "child", "Verify event.target when passed passing an event object" ); - equal( e.currentTarget.id, "par", "Verify event.currentTarget when passed passing an event object" ); - equal( e.secret, "boo!", "Verify event object's custom attribute when passed passing an event object" ); + assert.equal( e.type, "foo", "Verify event type when passed passing an event object" ); + assert.equal( e.target.id, "child", "Verify event.target when passed passing an event object" ); + assert.equal( e.currentTarget.id, "par", "Verify event.currentTarget when passed passing an event object" ); + assert.equal( e.secret, "boo!", "Verify event object's custom attribute when passed passing an event object" ); } ); // test with an event object @@ -1203,20 +1203,20 @@ test( "trigger(eventObject, [data], [fn])", function() { $parent.off(); function error() { - ok( false, "This assertion shouldn't be reached" ); + assert.ok( false, "This assertion shouldn't be reached" ); } $parent.on( "foo", error ); $child.on( "foo", function( e, a, b, c ) { - equal( arguments.length, 4, "Check arguments length" ); - equal( a, 1, "Check first custom argument" ); - equal( b, 2, "Check second custom argument" ); - equal( c, 3, "Check third custom argument" ); + assert.equal( arguments.length, 4, "Check arguments length" ); + assert.equal( a, 1, "Check first custom argument" ); + assert.equal( b, 2, "Check second custom argument" ); + assert.equal( c, 3, "Check third custom argument" ); - equal( e.isDefaultPrevented(), false, "Verify isDefaultPrevented" ); - equal( e.isPropagationStopped(), false, "Verify isPropagationStopped" ); - equal( e.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" ); + assert.equal( e.isDefaultPrevented(), false, "Verify isDefaultPrevented" ); + assert.equal( e.isPropagationStopped(), false, "Verify isPropagationStopped" ); + assert.equal( e.isImmediatePropagationStopped(), false, "Verify isImmediatePropagationStopped" ); // Skips both errors e.stopImmediatePropagation(); @@ -1230,7 +1230,7 @@ test( "trigger(eventObject, [data], [fn])", function() { event = new jQuery.Event( "foo" ); $child.trigger( event, [ 1,2,3 ] ).off(); - equal( event.result, "result", "Check event.result attribute" ); + assert.equal( event.result, "result", "Check event.result attribute" ); // Will error if it bubbles $child.triggerHandler( "foo" ); @@ -1241,27 +1241,27 @@ test( "trigger(eventObject, [data], [fn])", function() { // Ensure triggerHandler doesn't molest its event object (#xxx) event = jQuery.Event( "zowie" ); jQuery( document ).triggerHandler( event ); - equal( event.type, "zowie", "Verify its type" ); - equal( event.isPropagationStopped(), false, "propagation not stopped" ); - equal( event.isDefaultPrevented(), false, "default not prevented" ); + assert.equal( event.type, "zowie", "Verify its type" ); + assert.equal( event.isPropagationStopped(), false, "propagation not stopped" ); + assert.equal( event.isDefaultPrevented(), false, "default not prevented" ); } ); // Explicitly introduce global variable for oldIE so QUnit doesn't complain if checking globals window.onclick = undefined; -test( ".trigger() bubbling on disconnected elements (#10489)", function() { - expect( 2 ); +QUnit.test( ".trigger() bubbling on disconnected elements (#10489)", function( assert ) { + assert.expect( 2 ); jQuery( window ).on( "click", function() { - ok( false, "click fired on window" ); + assert.ok( false, "click fired on window" ); } ); jQuery( "<div><p>hi</p></div>" ) .on( "click", function() { - ok( true, "click fired on div" ); + assert.ok( true, "click fired on div" ); } ) .find( "p" ) .on( "click", function() { - ok( true, "click fired on p" ); + assert.ok( true, "click fired on p" ); } ) .trigger( "click" ) .off( "click" ) @@ -1272,18 +1272,18 @@ test( ".trigger() bubbling on disconnected elements (#10489)", function() { jQuery( window ).off( "click" ); } ); -test( ".trigger() doesn't bubble load event (#10717)", function() { - expect( 1 ); +QUnit.test( ".trigger() doesn't bubble load event (#10717)", function( assert ) { + assert.expect( 1 ); jQuery( window ).on( "load", function() { - ok( false, "load fired on window" ); + assert.ok( false, "load fired on window" ); } ); // It's not an image, but as long as it fires load... jQuery( "<img src='index.html' />" ) .appendTo( "body" ) .on( "load", function() { - ok( true, "load fired on img" ); + assert.ok( true, "load fired on img" ); } ) .trigger( "load" ) .remove(); @@ -1291,8 +1291,8 @@ test( ".trigger() doesn't bubble load event (#10717)", function() { jQuery( window ).off( "load" ); } ); -test( "Delegated events in SVG (#10791; #13180)", function() { - expect( 2 ); +QUnit.test( "Delegated events in SVG (#10791; #13180)", function( assert ) { + assert.expect( 2 ); var useElem, e, svg = jQuery( @@ -1307,10 +1307,10 @@ test( "Delegated events in SVG (#10791; #13180)", function() { jQuery( "#qunit-fixture" ) .append( svg ) .on( "click", "#svg-by-id", function() { - ok( true, "delegated id selector" ); + assert.ok( true, "delegated id selector" ); } ) .on( "click", "[class~='svg-by-class']", function() { - ok( true, "delegated class selector" ); + assert.ok( true, "delegated class selector" ); } ) .find( "#svg-by-id, [class~='svg-by-class']" ) .trigger( "click" ) @@ -1328,8 +1328,8 @@ test( "Delegated events in SVG (#10791; #13180)", function() { jQuery( "#qunit-fixture" ).off( "click" ); } ); -test( "Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", function() { - expect( 5 ); +QUnit.test( "Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", function( assert ) { + assert.expect( 5 ); // Alias names like "id" cause havoc var form = jQuery( @@ -1344,7 +1344,7 @@ test( "Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", funct jQuery( "body" ) .on( "submit", "#myform", function() { - ok( true, "delegated id selector with aliased id" ); + assert.ok( true, "delegated id selector with aliased id" ); } ) .find( "#myform" ) .trigger( "submit" ) @@ -1354,7 +1354,7 @@ test( "Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", funct form.append( "<input type='text' name='disabled' value='differently abled' />" ); jQuery( "body" ) .on( "submit", "#myform", function() { - ok( true, "delegated id selector with aliased disabled" ); + assert.ok( true, "delegated id selector with aliased disabled" ); } ) .find( "#myform" ) .trigger( "submit" ) @@ -1364,10 +1364,10 @@ test( "Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", funct form .append( "<button id='nestyDisabledBtn'><span>Zing</span></button>" ) .on( "click", "#nestyDisabledBtn", function() { - ok( true, "click on enabled/disabled button with nesty elements" ); + assert.ok( true, "click on enabled/disabled button with nesty elements" ); } ) .on( "mouseover", "#nestyDisabledBtn", function() { - ok( true, "mouse on enabled/disabled button with nesty elements" ); + assert.ok( true, "mouse on enabled/disabled button with nesty elements" ); } ) .find( "span" ) .trigger( "click" ) // yep @@ -1383,8 +1383,8 @@ test( "Delegated events in forms (#10844; #11145; #8165; #11382, #11764)", funct form.remove(); } ); -test( "Submit event can be stopped (#11049)", function() { - expect( 1 ); +QUnit.test( "Submit event can be stopped (#11049)", function( assert ) { + assert.expect( 1 ); // Since we manually bubble in IE, make sure inner handlers get a chance to cancel var form = jQuery( @@ -1397,14 +1397,14 @@ test( "Submit event can be stopped (#11049)", function() { jQuery( "body" ) .on( "submit", function() { - ok( true, "submit bubbled on first handler" ); + assert.ok( true, "submit bubbled on first handler" ); return false; } ) .find( "#myform input[type=submit]" ) .each( function() { this.click(); } ) .end() .on( "submit", function() { - ok( false, "submit bubbled on second handler" ); + assert.ok( false, "submit bubbled on second handler" ); return false; } ) .find( "#myform input[type=submit]" ) @@ -1427,7 +1427,7 @@ test( "Submit event can be stopped (#11049)", function() { // handler making it impossible to feature-detect the support. if ( window.onbeforeunload === null && !/(ipad|iphone|ipod|android 2\.3)/i.test( navigator.userAgent ) ) { - asyncTest( "on(beforeunload)", 4, function() { + QUnit.asyncTest( "on(beforeunload)", 4, function( assert ) { var win, fired = false, iframe = jQuery( "<iframe src='data/iframe.html' />" ); @@ -1437,22 +1437,22 @@ if ( window.onbeforeunload === null && jQuery( win ).on( "beforeunload", function() { fired = true; - ok( true, "beforeunload event is fired" ); + assert.ok( true, "beforeunload event is fired" ); } ); - strictEqual( win.onbeforeunload, null, "onbeforeunload property on window object still equals null" ); + assert.strictEqual( win.onbeforeunload, null, "onbeforeunload property on window object still equals null" ); win.onbeforeunload = function() { - ok( true, "window.onbeforeunload handler is called" ); + assert.ok( true, "window.onbeforeunload handler is called" ); iframe = jQuery( "<iframe src='data/iframe.html' />" ); iframe.appendTo( "#qunit-fixture" ).one( "load", function() { win = iframe[ 0 ].contentWindow || iframe[ 0 ].contentDocument; jQuery( win ).on( "beforeunload", function() { - strictEqual( win.onbeforeunload, null, "Event handler is fired, even when onbeforeunload property on window is nulled" ); + assert.strictEqual( win.onbeforeunload, null, "Event handler is fired, even when onbeforeunload property on window is nulled" ); - start(); + QUnit.start(); } ); jQuery( win ).on( "unload", function() { @@ -1472,25 +1472,25 @@ if ( window.onbeforeunload === null && } ); } -test( "jQuery.Event( type, props )", function() { +QUnit.test( "jQuery.Event( type, props )", function( assert ) { - expect( 6 ); + assert.expect( 6 ); var event = jQuery.Event( "keydown", { keyCode: 64 } ), handler = function( event ) { - ok( "keyCode" in event, "Special property 'keyCode' exists" ); - equal( event.keyCode, 64, "event.keyCode has explicit value '64'" ); + assert.ok( "keyCode" in event, "Special property 'keyCode' exists" ); + assert.equal( event.keyCode, 64, "event.keyCode has explicit value '64'" ); }; // Supports jQuery.Event implementation - equal( event.type, "keydown", "Verify type" ); + assert.equal( event.type, "keydown", "Verify type" ); // ensure "type" in props won't clobber the one set by constructor - equal( jQuery.inArray( "type", jQuery.event.props ), -1, "'type' property not in props (#10375)" ); + assert.equal( jQuery.inArray( "type", jQuery.event.props ), -1, "'type' property not in props (#10375)" ); - ok( "keyCode" in event, "Special 'keyCode' property exists" ); + assert.ok( "keyCode" in event, "Special 'keyCode' property exists" ); - strictEqual( jQuery.isPlainObject( event ), false, "Instances of $.Event should not be identified as a plain object." ); + assert.strictEqual( jQuery.isPlainObject( event ), false, "Instances of $.Event should not be identified as a plain object." ); jQuery( "body" ).on( "keydown", handler ).trigger( event ); @@ -1498,41 +1498,41 @@ test( "jQuery.Event( type, props )", function() { } ); -test( "jQuery.Event properties", function() { - expect( 12 ); +QUnit.test( "jQuery.Event properties", function( assert ) { + assert.expect( 12 ); var handler, event, $structure = jQuery( "<div id='ancestor'><p id='delegate'><span id='target'>shiny</span></p></div>" ), $target = $structure.find( "#target" ); handler = function( e ) { - strictEqual( e.currentTarget, this, "currentTarget at " + this.id ); - equal( e.isTrigger, 3, "trigger at " + this.id ); + assert.strictEqual( e.currentTarget, this, "currentTarget at " + this.id ); + assert.equal( e.isTrigger, 3, "trigger at " + this.id ); }; $structure.one( "click", handler ); $structure.one( "click", "p", handler ); $target.one( "click", handler ); $target[ 0 ].onclick = function( e ) { - strictEqual( e.currentTarget, this, "currentTarget at target (native handler)" ); - equal( e.isTrigger, 3, "trigger at target (native handler)" ); + assert.strictEqual( e.currentTarget, this, "currentTarget at target (native handler)" ); + assert.equal( e.isTrigger, 3, "trigger at target (native handler)" ); }; $target.trigger( "click" ); $target.one( "click", function( e ) { - equal( e.isTrigger, 2, "triggerHandler at target" ); + assert.equal( e.isTrigger, 2, "triggerHandler at target" ); } ); $target[ 0 ].onclick = function( e ) { - equal( e.isTrigger, 2, "triggerHandler at target (native handler)" ); + assert.equal( e.isTrigger, 2, "triggerHandler at target (native handler)" ); }; $target.triggerHandler( "click" ); handler = function( e ) { - strictEqual( e.isTrigger, undefined, "native event at " + this.id ); + assert.strictEqual( e.isTrigger, undefined, "native event at " + this.id ); event = e; }; $target.one( "click", handler ); $target[ 0 ].onclick = function( e ) { - strictEqual( e.isTrigger, undefined, "native event at target (native handler)" ); + assert.strictEqual( e.isTrigger, undefined, "native event at target (native handler)" ); $target[ 0 ].onclick = null; }; fireNative( $target[ 0 ], "click" ); @@ -1543,8 +1543,8 @@ test( "jQuery.Event properties", function() { } } ); -test( ".on()/.off()", function() { - expect( 65 ); +QUnit.test( ".on()/.off()", function( assert ) { + assert.expect( 65 ); var event, clicked, hash, called, livec, lived, livee, submit = 0, div = 0, livea = 0, liveb = 0; @@ -1556,68 +1556,68 @@ test( ".on()/.off()", function() { // Nothing should trigger on the body jQuery( "body" ).trigger( "click" ); - equal( submit, 0, "Click on body" ); - equal( div, 0, "Click on body" ); - equal( livea, 0, "Click on body" ); - equal( liveb, 0, "Click on body" ); + assert.equal( submit, 0, "Click on body" ); + assert.equal( div, 0, "Click on body" ); + assert.equal( livea, 0, "Click on body" ); + assert.equal( liveb, 0, "Click on body" ); // This should trigger two events submit = 0; div = 0; livea = 0; liveb = 0; jQuery( "div#nothiddendiv" ).trigger( "click" ); - equal( submit, 0, "Click on div" ); - equal( div, 1, "Click on div" ); - equal( livea, 1, "Click on div" ); - equal( liveb, 0, "Click on div" ); + assert.equal( submit, 0, "Click on div" ); + assert.equal( div, 1, "Click on div" ); + assert.equal( livea, 1, "Click on div" ); + assert.equal( liveb, 0, "Click on div" ); // This should trigger three events (w/ bubbling) submit = 0; div = 0; livea = 0; liveb = 0; jQuery( "div#nothiddendivchild" ).trigger( "click" ); - equal( submit, 0, "Click on inner div" ); - equal( div, 2, "Click on inner div" ); - equal( livea, 1, "Click on inner div" ); - equal( liveb, 1, "Click on inner div" ); + assert.equal( submit, 0, "Click on inner div" ); + assert.equal( div, 2, "Click on inner div" ); + assert.equal( livea, 1, "Click on inner div" ); + assert.equal( liveb, 1, "Click on inner div" ); // This should trigger one submit submit = 0; div = 0; livea = 0; liveb = 0; jQuery( "div#nothiddendivchild" ).trigger( "submit" ); - equal( submit, 1, "Submit on div" ); - equal( div, 0, "Submit on div" ); - equal( livea, 0, "Submit on div" ); - equal( liveb, 0, "Submit on div" ); + assert.equal( submit, 1, "Submit on div" ); + assert.equal( div, 0, "Submit on div" ); + assert.equal( livea, 0, "Submit on div" ); + assert.equal( liveb, 0, "Submit on div" ); // Make sure no other events were removed in the process submit = 0; div = 0; livea = 0; liveb = 0; jQuery( "div#nothiddendivchild" ).trigger( "click" ); - equal( submit, 0, "off Click on inner div" ); - equal( div, 2, "off Click on inner div" ); - equal( livea, 1, "off Click on inner div" ); - equal( liveb, 1, "off Click on inner div" ); + assert.equal( submit, 0, "off Click on inner div" ); + assert.equal( div, 2, "off Click on inner div" ); + assert.equal( livea, 1, "off Click on inner div" ); + assert.equal( liveb, 1, "off Click on inner div" ); // Now make sure that the removal works submit = 0; div = 0; livea = 0; liveb = 0; jQuery( "#body" ).off( "click", "div#nothiddendivchild" ); jQuery( "div#nothiddendivchild" ).trigger( "click" ); - equal( submit, 0, "off Click on inner div" ); - equal( div, 2, "off Click on inner div" ); - equal( livea, 1, "off Click on inner div" ); - equal( liveb, 0, "off Click on inner div" ); + assert.equal( submit, 0, "off Click on inner div" ); + assert.equal( div, 2, "off Click on inner div" ); + assert.equal( livea, 1, "off Click on inner div" ); + assert.equal( liveb, 0, "off Click on inner div" ); // Make sure that the click wasn't removed too early submit = 0; div = 0; livea = 0; liveb = 0; jQuery( "div#nothiddendiv" ).trigger( "click" ); - equal( submit, 0, "off Click on inner div" ); - equal( div, 1, "off Click on inner div" ); - equal( livea, 1, "off Click on inner div" ); - equal( liveb, 0, "off Click on inner div" ); + assert.equal( submit, 0, "off Click on inner div" ); + assert.equal( div, 1, "off Click on inner div" ); + assert.equal( livea, 1, "off Click on inner div" ); + assert.equal( liveb, 0, "off Click on inner div" ); // Make sure that stopPropagation doesn't stop live events submit = 0; div = 0; livea = 0; liveb = 0; jQuery( "#body" ).on( "click", "div#nothiddendivchild", function( e ) { liveb++; e.stopPropagation(); } ); jQuery( "div#nothiddendivchild" ).trigger( "click" ); - equal( submit, 0, "stopPropagation Click on inner div" ); - equal( div, 1, "stopPropagation Click on inner div" ); - equal( livea, 0, "stopPropagation Click on inner div" ); - equal( liveb, 1, "stopPropagation Click on inner div" ); + assert.equal( submit, 0, "stopPropagation Click on inner div" ); + assert.equal( div, 1, "stopPropagation Click on inner div" ); + assert.equal( livea, 0, "stopPropagation Click on inner div" ); + assert.equal( liveb, 1, "stopPropagation Click on inner div" ); // Make sure click events only fire with primary click submit = 0; div = 0; livea = 0; liveb = 0; @@ -1625,7 +1625,7 @@ test( ".on()/.off()", function() { event.button = 1; jQuery( "div#nothiddendiv" ).trigger( event ); - equal( livea, 0, "on secondary click" ); + assert.equal( livea, 0, "on secondary click" ); jQuery( "#body" ).off( "click", "div#nothiddendivchild" ); jQuery( "#body" ).off( "click", "div#nothiddendiv" ); @@ -1639,12 +1639,12 @@ test( ".on()/.off()", function() { jQuery( "#foo" ).trigger( "click" ); jQuery( "#qunit-fixture" ).trigger( "click" ); jQuery( "body" ).trigger( "click" ); - equal( clicked, 2, "on with a context" ); + assert.equal( clicked, 2, "on with a context" ); // Test unbinding with a different context jQuery( "#qunit-fixture" ).off( "click", "#foo" ); jQuery( "#foo" ).trigger( "click" ); - equal( clicked, 2, "off with a context" ); + 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" ); } ); @@ -1663,9 +1663,9 @@ test( ".on()/.off()", function() { // Test binding with different this object, event data, and trigger data jQuery( "#body" ).on( "click", "#foo", true, jQuery.proxy( function( e, data ) { - equal( e.data, true, "on with with different this object, event data, and trigger data" ); - equal( this.foo, "bar", "on with with different this object, event data, and trigger data" ); - equal( data, true, "on with with different this object, event data, and trigger data" ); + assert.equal( e.data, true, "on with with different this object, event data, and trigger data" ); + assert.equal( this.foo, "bar", "on with with different this object, event data, and trigger data" ); + assert.equal( data, true, "on with with different this object, event data, and trigger data" ); }, { "foo": "bar" } ) ); jQuery( "#foo" ).trigger( "click", true ); jQuery( "#body" ).off( "click", "#foo" ); @@ -1674,14 +1674,14 @@ test( ".on()/.off()", function() { jQuery( "#body" ).on( "click", "#anchor2", function() { return false; } ); hash = window.location.hash; jQuery( "#anchor2" ).trigger( "click" ); - equal( window.location.hash, hash, "return false worked" ); + assert.equal( window.location.hash, hash, "return false worked" ); jQuery( "#body" ).off( "click", "#anchor2" ); // Verify that .preventDefault() prevents default action jQuery( "#body" ).on( "click", "#anchor2", function( e ) { e.preventDefault(); } ); hash = window.location.hash; jQuery( "#anchor2" ).trigger( "click" ); - equal( window.location.hash, hash, "e.preventDefault() worked" ); + assert.equal( window.location.hash, hash, "e.preventDefault() worked" ); jQuery( "#body" ).off( "click", "#anchor2" ); // Test binding the same handler to multiple points @@ -1692,22 +1692,22 @@ test( ".on()/.off()", function() { jQuery( "#body" ).on( "click", "#anchor2", callback ); jQuery( "#nothiddendiv" ).trigger( "click" ); - equal( called, 1, "Verify that only one click occurred." ); + assert.equal( called, 1, "Verify that only one click occurred." ); called = 0; jQuery( "#anchor2" ).trigger( "click" ); - equal( called, 1, "Verify that only one click occurred." ); + assert.equal( called, 1, "Verify that only one click occurred." ); // Make sure that only one callback is removed jQuery( "#body" ).off( "click", "#anchor2", callback ); called = 0; jQuery( "#nothiddendiv" ).trigger( "click" ); - equal( called, 1, "Verify that only one click occurred." ); + assert.equal( called, 1, "Verify that only one click occurred." ); called = 0; jQuery( "#anchor2" ).trigger( "click" ); - equal( called, 0, "Verify that no click occurred." ); + assert.equal( called, 0, "Verify that no click occurred." ); // Make sure that it still works if the selector is the same, // but the event type is different @@ -1718,11 +1718,11 @@ test( ".on()/.off()", function() { called = 0; jQuery( "#nothiddendiv" ).trigger( "click" ); - equal( called, 0, "Verify that no click occurred." ); + assert.equal( called, 0, "Verify that no click occurred." ); called = 0; jQuery( "#nothiddendiv" ).trigger( "foo" ); - equal( called, 1, "Verify that one foo occurred." ); + assert.equal( called, 1, "Verify that one foo occurred." ); // Cleanup jQuery( "#body" ).off( "foo", "#nothiddendiv", callback ); @@ -1736,8 +1736,8 @@ test( ".on()/.off()", function() { jQuery( "#body" ).on( "click", "#nothiddendivchild", function( e ) { if ( e.target ) {livec++;} } ); jQuery( "#nothiddendiv span" ).trigger( "click" ); - equal( jQuery( "#nothiddendiv span" ).length, 0, "Verify that first handler occurred and modified the DOM." ); - equal( livec, 1, "Verify that second handler occurred even with nuked target." ); + assert.equal( jQuery( "#nothiddendiv span" ).length, 0, "Verify that first handler occurred and modified the DOM." ); + assert.equal( livec, 1, "Verify that second handler occurred even with nuked target." ); // Cleanup jQuery( "#body" ).off( "click", "#nothiddendivchild" ); @@ -1752,8 +1752,8 @@ test( ".on()/.off()", function() { jQuery( "#body" ).on( "click", "span#liveSpan1", function() { livee++; } ); jQuery( "span#liveSpan1 a" ).trigger( "click" ); - equal( lived, 1, "Verify that only one first handler occurred." ); - equal( livee, 0, "Verify that second handler doesn't." ); + assert.equal( lived, 1, "Verify that only one first handler occurred." ); + assert.equal( livee, 0, "Verify that second handler doesn't." ); // and one pair in inverse jQuery( "#body" ).on( "click", "span#liveSpan2", function() { livee++; } ); @@ -1762,18 +1762,18 @@ test( ".on()/.off()", function() { lived = 0; livee = 0; jQuery( "span#liveSpan2 a" ).trigger( "click" ); - equal( lived, 1, "Verify that only one first handler occurred." ); - equal( livee, 0, "Verify that second handler doesn't." ); + assert.equal( lived, 1, "Verify that only one first handler occurred." ); + assert.equal( livee, 0, "Verify that second handler doesn't." ); // Cleanup jQuery( "#body" ).off( "click", "**" ); // Test this, target and currentTarget are correct jQuery( "#body" ).on( "click", "span#liveSpan1", function( e ) { - equal( this.id, "liveSpan1", "Check the this within a on handler" ); - equal( e.currentTarget.id, "liveSpan1", "Check the event.currentTarget within a on handler" ); - equal( e.delegateTarget, document.body, "Check the event.delegateTarget within a on handler" ); - equal( e.target.nodeName.toUpperCase(), "A", "Check the event.target within a on handler" ); + assert.equal( this.id, "liveSpan1", "Check the this within a on handler" ); + assert.equal( e.currentTarget.id, "liveSpan1", "Check the event.currentTarget within a on handler" ); + assert.equal( e.delegateTarget, document.body, "Check the event.delegateTarget within a on handler" ); + assert.equal( e.target.nodeName.toUpperCase(), "A", "Check the event.target within a on handler" ); } ); jQuery( "span#liveSpan1 a" ).trigger( "click" ); @@ -1789,63 +1789,63 @@ test( ".on()/.off()", function() { jQuery( "#body" ).on( "click", "#nothiddendiv div", clickB ); jQuery( "#body" ).on( "mouseover", "#nothiddendiv div", function() { livee++; } ); - equal( livee, 0, "No clicks, deep selector." ); + assert.equal( livee, 0, "No clicks, deep selector." ); livee = 0; jQuery( "#nothiddendivchild" ).trigger( "click" ); - equal( livee, 2, "Click, deep selector." ); + assert.equal( livee, 2, "Click, deep selector." ); livee = 0; jQuery( "#nothiddendivchild" ).trigger( "mouseover" ); - equal( livee, 1, "Mouseover, deep selector." ); + assert.equal( livee, 1, "Mouseover, deep selector." ); jQuery( "#body" ).off( "mouseover", "#nothiddendiv div" ); livee = 0; jQuery( "#nothiddendivchild" ).trigger( "click" ); - equal( livee, 2, "Click, deep selector." ); + assert.equal( livee, 2, "Click, deep selector." ); livee = 0; jQuery( "#nothiddendivchild" ).trigger( "mouseover" ); - equal( livee, 0, "Mouseover, deep selector." ); + assert.equal( livee, 0, "Mouseover, deep selector." ); jQuery( "#body" ).off( "click", "#nothiddendiv div", clickB ); livee = 0; jQuery( "#nothiddendivchild" ).trigger( "click" ); - equal( livee, 1, "Click, deep selector." ); + assert.equal( livee, 1, "Click, deep selector." ); jQuery( "#body" ).off( "click", "#nothiddendiv div" ); } ); -test( "jQuery.off using dispatched jQuery.Event", function() { - expect( 1 ); +QUnit.test( "jQuery.off using dispatched jQuery.Event", function( assert ) { + assert.expect( 1 ); var markup = jQuery( "<p><a href='#'>target</a></p>" ), count = 0; markup .on( "click.name", "a", function( event ) { - equal( ++count, 1, "event called once before removal" ); + assert.equal( ++count, 1, "event called once before removal" ); jQuery().off( event ); } ) .find( "a" ).trigger( "click" ).trigger( "click" ).end() .remove(); } ); -test( "delegated event with delegateTarget-relative selector", function() { - expect( 3 ); +QUnit.test( "delegated event with delegateTarget-relative selector", function( assert ) { + assert.expect( 3 ); var markup = jQuery( "<div><ul><li><a id=\"a0\"></a><ul id=\"ul0\"><li class=test><a id=\"a0_0\"></a></li><li><a id=\"a0_1\"></a></li></ul></li></ul></div>" ).appendTo( "#qunit-fixture" ); // Non-positional selector (#12383) markup.find( "#ul0" ) .on( "click", "div li a", function() { - ok( false, "div is ABOVE the delegation point!" ); + assert.ok( false, "div is ABOVE the delegation point!" ); } ) .on( "click", "ul a", function() { - ok( false, "ul IS the delegation point!" ); + assert.ok( false, "ul IS the delegation point!" ); } ) .on( "click", "li.test a", function() { - ok( true, "li.test is below the delegation point." ); + assert.ok( true, "li.test is below the delegation point." ); } ) .find( "#a0_0" ).trigger( "click" ).end() .off( "click" ); @@ -1853,11 +1853,11 @@ test( "delegated event with delegateTarget-relative selector", function() { // Positional selector (#11315) markup.find( "ul" ).eq( 0 ) .on( "click", ">li>a", function() { - ok( this.id === "a0", "child li was clicked" ); + assert.ok( this.id === "a0", "child li was clicked" ); } ) .find( "#ul0" ) .on( "click", "li:first>a", function() { - ok( this.id === "a0_0", "first li under #u10 was clicked" ); + assert.ok( this.id === "a0_0", "first li under #u10 was clicked" ); } ) .end() .find( "a" ).trigger( "click" ).end() @@ -1866,8 +1866,8 @@ test( "delegated event with delegateTarget-relative selector", function() { markup.remove(); } ); -test( "delegated event with selector matching Object.prototype property (#13203)", function() { - expect( 1 ); +QUnit.test( "delegated event with selector matching Object.prototype property (#13203)", function( assert ) { + assert.expect( 1 ); var matched = 0; @@ -1877,38 +1877,38 @@ test( "delegated event with selector matching Object.prototype property (#13203) jQuery( "#anchor2" ).trigger( "click" ); - equal( matched, 0, "Nothing matched 'toString'" ); + assert.equal( matched, 0, "Nothing matched 'toString'" ); } ); -test( "delegated event with intermediate DOM manipulation (#13208)", function() { - expect( 1 ); +QUnit.test( "delegated event with intermediate DOM manipulation (#13208)", function( assert ) { + assert.expect( 1 ); jQuery( "#foo" ).on( "click", "[id=sap]", function() {} ); jQuery( "#sap" ).on( "click", "[id=anchor2]", function() { document.createDocumentFragment().appendChild( this.parentNode ); - ok( true, "Element removed" ); + assert.ok( true, "Element removed" ); } ); jQuery( "#anchor2" ).trigger( "click" ); } ); -test( "stopPropagation() stops directly-bound events on delegated target", function() { - expect( 1 ); +QUnit.test( "stopPropagation() stops directly-bound events on delegated target", function( assert ) { + assert.expect( 1 ); var markup = jQuery( "<div><p><a href=\"#\">target</a></p></div>" ); markup .on( "click", function() { - ok( false, "directly-bound event on delegate target was called" ); + assert.ok( false, "directly-bound event on delegate target was called" ); } ) .on( "click", "a", function( e ) { e.stopPropagation(); - ok( true, "delegated handler was called" ); + assert.ok( true, "delegated handler was called" ); } ) .find( "a" ).trigger( "click" ).end() .remove(); } ); -test( "off all bound delegated events", function() { - expect( 2 ); +QUnit.test( "off all bound delegated events", function( assert ) { + assert.expect( 2 ); var count = 0, clicks = 0, @@ -1921,15 +1921,15 @@ test( "off all bound delegated events", function() { jQuery( "div#nothiddendivchild" ).trigger( "click" ); jQuery( "div#nothiddendivchild" ).trigger( "submit" ); - equal( count, 0, "Make sure no events were triggered." ); + assert.equal( count, 0, "Make sure no events were triggered." ); div.trigger( "click" ); - equal( clicks, 2, "Make sure delegated and directly bound event occurred." ); + assert.equal( clicks, 2, "Make sure delegated and directly bound event occurred." ); div.off( "click" ); } ); -test( "on with multiple delegated events", function() { - expect( 1 ); +QUnit.test( "on with multiple delegated events", function( assert ) { + assert.expect( 1 ); var count = 0, div = jQuery( "#body" ); @@ -1939,13 +1939,13 @@ test( "on with multiple delegated events", function() { jQuery( "div#nothiddendivchild" ).trigger( "click" ); jQuery( "div#nothiddendivchild" ).trigger( "submit" ); - equal( count, 2, "Make sure both the click and submit were triggered." ); + assert.equal( count, 2, "Make sure both the click and submit were triggered." ); jQuery( "#body" ).off( undefined, "**" ); } ); -test( "delegated on with change", function() { - expect( 8 ); +QUnit.test( "delegated on with change", function( assert ) { + assert.expect( 8 ); var select, checkbox, checkboxFunction, text, textChange, oldTextVal, @@ -1970,17 +1970,17 @@ test( "delegated on with change", function() { selectChange = 0; select[ 0 ].selectedIndex = select[ 0 ].selectedIndex ? 0 : 1; select.trigger( "change" ); - equal( selectChange, 1, "Change on click." ); + assert.equal( selectChange, 1, "Change on click." ); // test keys on select selectChange = 0; select[ 0 ].selectedIndex = select[ 0 ].selectedIndex ? 0 : 1; select.trigger( "change" ); - equal( selectChange, 1, "Change on keyup." ); + assert.equal( selectChange, 1, "Change on keyup." ); // test click on checkbox checkbox.trigger( "change" ); - equal( checkboxChange, 1, "Change on checkbox." ); + assert.equal( checkboxChange, 1, "Change on checkbox." ); // test blur/focus on text text = jQuery( "#name" ); @@ -1993,7 +1993,7 @@ test( "delegated on with change", function() { text.val( oldTextVal + "foo" ); text.trigger( "change" ); - equal( textChange, 1, "Change on text input." ); + assert.equal( textChange, 1, "Change on text input." ); text.val( oldTextVal ); jQuery( "#body" ).off( "change", "#name" ); @@ -2008,7 +2008,7 @@ test( "delegated on with change", function() { password.val( oldPasswordVal + "foo" ); password.trigger( "change" ); - equal( passwordChange, 1, "Change on password input." ); + assert.equal( passwordChange, 1, "Change on password input." ); password.val( oldPasswordVal ); jQuery( "#body" ).off( "change", "#name" ); @@ -2020,21 +2020,21 @@ test( "delegated on with change", function() { jQuery( "#body" ).off( "change", "select[name='S1']" ); select[ 0 ].selectedIndex = select[ 0 ].selectedIndex ? 0 : 1; select.trigger( "change" ); - equal( selectChange, 0, "Die on click works." ); + assert.equal( selectChange, 0, "Die on click works." ); selectChange = 0; select[ 0 ].selectedIndex = select[ 0 ].selectedIndex ? 0 : 1; select.trigger( "change" ); - equal( selectChange, 0, "Die on keyup works." ); + assert.equal( selectChange, 0, "Die on keyup works." ); // die specific checkbox jQuery( "#body" ).off( "change", "#check2", checkboxFunction ); checkbox.trigger( "change" ); - equal( checkboxChange, 1, "Die on checkbox." ); + assert.equal( checkboxChange, 1, "Die on checkbox." ); } ); -test( "delegated on with submit", function() { - expect( 2 ); +QUnit.test( "delegated on with submit", function( assert ) { + assert.expect( 2 ); var count1 = 0, count2 = 0; @@ -2049,15 +2049,15 @@ test( "delegated on with submit", function() { } ); jQuery( "#testForm input[name=sub1]" ).trigger( "submit" ); - equal( count1, 1, "Verify form submit." ); - equal( count2, 1, "Verify body submit." ); + assert.equal( count1, 1, "Verify form submit." ); + assert.equal( count2, 1, "Verify body submit." ); jQuery( "#body" ).off( undefined, "**" ); jQuery( document ).off( undefined, "**" ); } ); -test( "delegated off() with only namespaces", function() { - expect( 2 ); +QUnit.test( "delegated off() with only namespaces", function( assert ) { + assert.expect( 2 ); var $delegate = jQuery( "#liveHandlerOrder" ), count = 0; @@ -2068,53 +2068,53 @@ test( "delegated off() with only namespaces", function() { jQuery( "a", $delegate ).eq( 0 ).trigger( "click.ns" ); - equal( count, 1, "delegated click.ns" ); + assert.equal( count, 1, "delegated click.ns" ); $delegate.off( ".ns", "**" ); jQuery( "a", $delegate ).eq( 1 ).trigger( "click.ns" ); - equal( count, 1, "no more .ns after off" ); + assert.equal( count, 1, "no more .ns after off" ); } ); -test( "Non DOM element events", function() { - expect( 1 ); +QUnit.test( "Non DOM element events", function( assert ) { + assert.expect( 1 ); var o = {}; jQuery( o ).on( "nonelementobj", function() { - ok( true, "Event on non-DOM object triggered" ); + assert.ok( true, "Event on non-DOM object triggered" ); } ); jQuery( o ).trigger( "nonelementobj" ).off( "nonelementobj" ); } ); -test( "inline handler returning false stops default", function() { - expect( 1 ); +QUnit.test( "inline handler returning false stops default", function( assert ) { + assert.expect( 1 ); var markup = jQuery( "<div><a href=\"#\" onclick=\"return false\">x</a></div>" ); markup.on( "click", function( e ) { - ok( e.isDefaultPrevented(), "inline handler prevented default" ); + assert.ok( e.isDefaultPrevented(), "inline handler prevented default" ); return false; } ); markup.find( "a" ).trigger( "click" ); markup.off( "click" ); } ); -test( "window resize", function() { - expect( 2 ); +QUnit.test( "window resize", function( assert ) { + assert.expect( 2 ); jQuery( window ).off(); jQuery( window ).on( "resize", function() { - ok( true, "Resize event fired." ); + assert.ok( true, "Resize event fired." ); } ).trigger( "resize" ).off( "resize" ); - ok( !jQuery._data( window, "events" ), "Make sure all the events are gone." ); + assert.ok( !jQuery._data( window, "events" ), "Make sure all the events are gone." ); } ); -test( "focusin bubbles", function() { - expect( 2 ); +QUnit.test( "focusin bubbles", function( assert ) { + assert.expect( 2 ); var input = jQuery( "<input type='text' />" ).prependTo( "body" ), order = 0; @@ -2123,11 +2123,11 @@ test( "focusin bubbles", function() { input[ 0 ].focus(); jQuery( "body" ).on( "focusin.focusinBubblesTest", function() { - equal( 1, order++, "focusin on the body second" ); + assert.equal( 1, order++, "focusin on the body second" ); } ); input.on( "focusin.focusinBubblesTest", function() { - equal( 0, order++, "focusin on the element first" ); + assert.equal( 0, order++, "focusin on the element first" ); } ); // Removed since DOM focus is unreliable on test swarm @@ -2147,29 +2147,29 @@ test( "focusin bubbles", function() { jQuery( "body" ).off( "focusin.focusinBubblesTest" ); } ); -test( "custom events with colons (#3533, #8272)", function() { - expect( 1 ); +QUnit.test( "custom events with colons (#3533, #8272)", function( assert ) { + assert.expect( 1 ); var tab = jQuery( "<table><tr><td>trigger</td></tr></table>" ).appendTo( "body" ); try { tab.trigger( "back:forth" ); - ok( true, "colon events don't throw" ); + assert.ok( true, "colon events don't throw" ); } catch ( e ) { - ok( false, "colon events die" ); + assert.ok( false, "colon events die" ); } tab.remove(); } ); -test( ".on and .off", function() { - expect( 9 ); +QUnit.test( ".on and .off", function( assert ) { + assert.expect( 9 ); var counter, mixfn, data, $onandoff = jQuery( "<div id=\"onandoff\"><p>on<b>and</b>off</p><div>worked<em>or</em>borked?</div></div>" ).appendTo( "body" ); // Simple case jQuery( "#onandoff" ) .on( "whip", function() { - ok( true, "whipped it good" ); + assert.ok( true, "whipped it good" ); } ) .trigger( "whip" ) .off(); @@ -2186,7 +2186,7 @@ test( ".on and .off", function() { .trigger( "click" ) .trigger( "click", 17 ) .off( "click" ); - equal( counter, 54, "direct event bindings with data" ); + assert.equal( counter, 54, "direct event bindings with data" ); // Delegated events only counter = 0; @@ -2202,7 +2202,7 @@ test( ".on and .off", function() { .trigger( "click", 17 ) .end() .off( "click", "em" ); - equal( counter, 54, "delegated event bindings with data" ); + assert.equal( counter, 54, "delegated event bindings with data" ); // Mixed event bindings and types counter = 0; @@ -2215,7 +2215,7 @@ test( ".on and .off", function() { .on( "cluck", mixfn ) .trigger( "what!" ) .each( function() { - equal( counter, 0, "nothing triggered yet" ); + assert.equal( counter, 0, "nothing triggered yet" ); } ) .find( "em" ) .one( "cluck", 3, mixfn ) @@ -2224,12 +2224,12 @@ test( ".on and .off", function() { .trigger( "cluck", 9 ) // 2+9 + 0+9 = 20 .end() .each( function() { - equal( counter, 49, "after triggering em element" ); + assert.equal( counter, 49, "after triggering em element" ); } ) .off( "cluck", function() {} ) // shouldn't remove anything .trigger( "cluck", 2 ) // 0+2 = 2 .each( function() { - equal( counter, 51, "after triggering #onandoff cluck" ); + assert.equal( counter, 51, "after triggering #onandoff cluck" ); } ) .find( "b" ) .on( "click", 95, mixfn ) @@ -2239,7 +2239,7 @@ test( ".on and .off", function() { .off( "click clack cluck" ) .end() .each( function() { - equal( counter, 51, "after triggering b" ); + assert.equal( counter, 51, "after triggering b" ); } ) .trigger( "cluck", 3 ) // 0+3 = 3 .off( "clack", "em", mixfn ) @@ -2247,30 +2247,30 @@ test( ".on and .off", function() { .trigger( "clack" ) // 0 .end() .each( function() { - equal( counter, 54, "final triggers" ); + assert.equal( counter, 54, "final triggers" ); } ) .off( "click cluck" ); // We should have removed all the event handlers ... kinda hacky way to check this data = jQuery.data[ jQuery( "#onandoff" )[ 0 ].expando ] || {}; - equal( data[ "events" ], undefined, "no events left" ); + assert.equal( data[ "events" ], undefined, "no events left" ); $onandoff.remove(); } ); -test( "special on name mapping", function() { - expect( 7 ); +QUnit.test( "special on name mapping", function( assert ) { + assert.expect( 7 ); jQuery.event.special[ "slap" ] = { bindType: "click", delegateType: "swing", handle: function( event ) { - equal( event.handleObj.origType, "slap", "slapped your mammy, " + event.type ); + assert.equal( event.handleObj.origType, "slap", "slapped your mammy, " + event.type ); } }; var comeback = function( event ) { - ok( true, "event " + event.type + " triggered" ); + assert.ok( true, "event " + event.type + " triggered" ); }; jQuery( "<div><button id=\"mammy\">Are We Not Men?</button></div>" ) @@ -2298,7 +2298,7 @@ test( "special on name mapping", function() { bindType: "click", delegateType: "click", handle: function( event ) { - equal( event.handleObj.origType, "gutfeeling", "got a gutfeeling" ); + assert.equal( event.handleObj.origType, "gutfeeling", "got a gutfeeling" ); // Need to call the handler since .one() uses it to unbind return event.handleObj.handler.call( this, event ); @@ -2330,11 +2330,11 @@ test( "special on name mapping", function() { delete jQuery.event.special[ "gutfeeling" ]; } ); -test( ".on and .off, selective mixed removal (#10705)", function() { - expect( 7 ); +QUnit.test( ".on and .off, selective mixed removal (#10705)", function( assert ) { + assert.expect( 7 ); var timingx = function( e ) { - ok( true, "triggered " + e.type ); + assert.ok( true, "triggered " + e.type ); }; jQuery( "<p>Strange Pursuit</p>" ) @@ -2352,15 +2352,15 @@ test( ".on and .off, selective mixed removal (#10705)", function() { .trigger( "click" ); // 0 } ); -test( ".on( event-map, null-selector, data ) #11130", function() { +QUnit.test( ".on( event-map, null-selector, data ) #11130", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var $p = jQuery( "<p>Strange Pursuit</p>" ), data = "bar", map = { "foo": function( event ) { - equal( event.data, "bar", "event.data correctly relayed with null selector" ); + assert.equal( event.data, "bar", "event.data correctly relayed with null selector" ); $p.remove(); } }; @@ -2368,8 +2368,8 @@ test( ".on( event-map, null-selector, data ) #11130", function() { $p.on( map, null, data ).trigger( "foo" ); } ); -test( "clone() delegated events (#11076)", function() { - expect( 3 ); +QUnit.test( "clone() delegated events (#11076)", function( assert ) { + assert.expect( 3 ); var counter = { "center": 0, "fold": 0, "centerfold": 0 }, clicked = function() { @@ -2383,56 +2383,56 @@ test( "clone() delegated events (#11076)", function() { clone = table.clone( true ); clone.find( "td" ).trigger( "click" ); - equal( counter[ "center" ], 1, "first child" ); - equal( counter[ "fold" ], 1, "last child" ); - equal( counter[ "centerfold" ], 2, "all children" ); + assert.equal( counter[ "center" ], 1, "first child" ); + assert.equal( counter[ "fold" ], 1, "last child" ); + assert.equal( counter[ "centerfold" ], 2, "all children" ); table.remove(); clone.remove(); } ); -test( "checkbox state (#3827)", function() { - expect( 9 ); +QUnit.test( "checkbox state (#3827)", function( assert ) { + assert.expect( 9 ); var markup = jQuery( "<div><input type=checkbox><div>" ).appendTo( "#qunit-fixture" ), cb = markup.find( "input" )[ 0 ]; jQuery( cb ).on( "click", function() { - equal( this.checked, false, "just-clicked checkbox is not checked" ); + assert.equal( this.checked, false, "just-clicked checkbox is not checked" ); } ); markup.on( "click", function() { - equal( cb.checked, false, "checkbox is not checked in bubbled event" ); + assert.equal( cb.checked, false, "checkbox is not checked in bubbled event" ); } ); // Native click cb.checked = true; - equal( cb.checked, true, "native - checkbox is initially checked" ); + assert.equal( cb.checked, true, "native - checkbox is initially checked" ); cb.click(); - equal( cb.checked, false, "native - checkbox is no longer checked" ); + assert.equal( cb.checked, false, "native - checkbox is no longer checked" ); // jQuery click cb.checked = true; - equal( cb.checked, true, "jQuery - checkbox is initially checked" ); + assert.equal( cb.checked, true, "jQuery - checkbox is initially checked" ); jQuery( cb ).trigger( "click" ); - equal( cb.checked, false, "jQuery - checkbox is no longer checked" ); + assert.equal( cb.checked, false, "jQuery - checkbox is no longer checked" ); // Handlers only; checkbox state remains false jQuery( cb ).triggerHandler( "click" ); } ); -test( "hover event no longer special since 1.9", function() { - expect( 1 ); +QUnit.test( "hover event no longer special since 1.9", function( assert ) { + assert.expect( 1 ); jQuery( "<div>craft</div>" ) .on( "hover", function( e ) { - equal( e.type, "hover", "I am hovering!" ); + assert.equal( e.type, "hover", "I am hovering!" ); } ) .trigger( "hover" ) .off( "hover" ); } ); -test( "fixHooks extensions", function() { - expect( 2 ); +QUnit.test( "fixHooks extensions", function( assert ) { + assert.expect( 2 ); // IE requires focusable elements to be visible, so append to body var $fixture = jQuery( "<input type='text' id='hook-fixture' />" ).appendTo( "body" ), @@ -2440,7 +2440,7 @@ test( "fixHooks extensions", function() { // Ensure the property doesn't exist $fixture.on( "click", function( event ) { - ok( !( "blurrinessLevel" in event ), "event.blurrinessLevel does not exist" ); + assert.ok( !( "blurrinessLevel" in event ), "event.blurrinessLevel does not exist" ); } ); fireNative( $fixture[ 0 ], "click" ); $fixture.off( "click" ); @@ -2454,7 +2454,7 @@ test( "fixHooks extensions", function() { // Trigger a native click and ensure the property is set $fixture.on( "click", function( event ) { - equal( event.blurrinessLevel, 42, "event.blurrinessLevel was set" ); + assert.equal( event.blurrinessLevel, 42, "event.blurrinessLevel was set" ); } ); fireNative( $fixture[ 0 ], "click" ); @@ -2467,97 +2467,120 @@ test( "fixHooks extensions", function() { // this test in IE8 since a native HTML5 drag event will never occur there. if ( document.createEvent ) { - test( "drag/drop events copy mouse-related event properties (gh-1925, gh-2009)", function() { - expect( 4 ); + QUnit.test( "drag/drop events copy mouse-related event properties (gh-1925, gh-2009)", function( assert ) { + assert.expect( 4 ); var $fixture = jQuery( "<div id='drag-fixture'></div>" ).appendTo( "body" ); $fixture.on( "dragmove", function( evt ) { - ok( "pageX" in evt, "checking for pageX property on dragmove" ); - ok( "pageY" in evt, "checking for pageY property on dragmove" ); + assert.ok( "pageX" in evt, "checking for pageX property on dragmove" ); + assert.ok( "pageY" in evt, "checking for pageY property on dragmove" ); } ); fireNative( $fixture[ 0 ], "dragmove" ); $fixture.on( "drop", function( evt ) { - ok( "pageX" in evt, "checking for pageX property on drop" ); - ok( "pageY" in evt, "checking for pageY property on drop" ); + assert.ok( "pageX" in evt, "checking for pageX property on drop" ); + assert.ok( "pageY" in evt, "checking for pageY property on drop" ); } ); fireNative( $fixture[ 0 ], "drop" ); $fixture.unbind( "dragmove drop" ).remove(); } ); } -test( "focusin using non-element targets", function() { - expect( 2 ); +QUnit.test( "focusin using non-element targets", function( assert ) { + assert.expect( 2 ); jQuery( document ).on( "focusin", function( e ) { - ok( e.type === "focusin", "got a focusin event on a document" ); + assert.ok( e.type === "focusin", "got a focusin event on a document" ); } ).trigger( "focusin" ).off( "focusin" ); jQuery( window ).on( "focusin", function( e ) { - ok( e.type === "focusin", "got a focusin event on a window" ); + assert.ok( e.type === "focusin", "got a focusin event on a window" ); } ).trigger( "focusin" ).off( "focusin" ); } ); -testIframeWithCallback( "focusin from an iframe", "event/focusinCrossFrame.html", function( frameDoc ) { - expect( 1 ); +testIframeWithCallback( + "focusin from an iframe", + "event/focusinCrossFrame.html", + function( frameDoc, assert ) { + assert.expect( 1 ); - var input = jQuery( frameDoc ).find( "#frame-input" ); + var input = jQuery( frameDoc ).find( "#frame-input" ); - // Create a focusin handler on the parent; shouldn't affect the iframe's fate - jQuery ( "body" ).on( "focusin.iframeTest", function() { - ok( false, "fired a focusin event in the parent document" ); - } ); + // Create a focusin handler on the parent; shouldn't affect the iframe's fate + jQuery ( "body" ).on( "focusin.iframeTest", function() { + assert.ok( false, "fired a focusin event in the parent document" ); + } ); - input.on( "focusin", function() { - ok( true, "fired a focusin event in the iframe" ); - } ); + input.on( "focusin", function() { + assert.ok( true, "fired a focusin event in the iframe" ); + } ); - // Avoid a native event; Chrome can't force focus to another frame - input.trigger( "focusin" ); + // Avoid a native event; Chrome can't force focus to another frame + input.trigger( "focusin" ); - // Must manually remove handler to avoid leaks in our data store - input.remove(); + // Must manually remove handler to avoid leaks in our data store + input.remove(); - // Be sure it was removed; nothing should happen - input.trigger( "focusin" ); + // Be sure it was removed; nothing should happen + input.trigger( "focusin" ); - // Remove body handler manually since it's outside the fixture - jQuery( "body" ).off( "focusin.iframeTest" ); -} ); + // Remove body handler manually since it's outside the fixture + jQuery( "body" ).off( "focusin.iframeTest" ); + } +); -testIframeWithCallback( "jQuery.ready promise", "event/promiseReady.html", function( isOk ) { - expect( 1 ); - ok( isOk, "$.when( $.ready ) works" ); -} ); +testIframeWithCallback( + "jQuery.ready promise", + "event/promiseReady.html", + function( isOk, assert ) { + assert.expect( 1 ); + assert.ok( isOk, "$.when( $.ready ) works" ); + } +); -testIframeWithCallback( "Focusing iframe element", "event/focusElem.html", function( isOk ) { - expect( 1 ); - ok( isOk, "Focused an element in an iframe" ); -} ); +testIframeWithCallback( + "Focusing iframe element", + "event/focusElem.html", + function( isOk, assert ) { + assert.expect( 1 ); + assert.ok( isOk, "Focused an element in an iframe" ); + } +); -testIframeWithCallback( "triggerHandler(onbeforeunload)", "event/triggerunload.html", function( isOk ) { - expect( 1 ); - ok( isOk, "Triggered onbeforeunload without an error" ); -} ); +testIframeWithCallback( + "triggerHandler(onbeforeunload)", + "event/triggerunload.html", + function( isOk, assert ) { + assert.expect( 1 ); + assert.ok( isOk, "Triggered onbeforeunload without an error" ); + } +); // need PHP here to make the incepted IFRAME hang if ( hasPHP ) { - testIframeWithCallback( "jQuery.ready synchronous load with long loading subresources", "event/syncReady.html", function( isOk ) { - expect( 1 ); - ok( isOk, "jQuery loaded synchronously fires ready when the DOM can truly be interacted with" ); - } ); + testIframeWithCallback( + "jQuery.ready synchronous load with long loading subresources", + "event/syncReady.html", + function( isOk, assert ) { + assert.expect( 1 ); + assert.ok( + isOk, + "jQuery loaded synchronously fires ready when the DOM can truly be interacted with" + ); + } + ); } -test( "change handler should be detached from element", function() { - expect( 2 ); +QUnit.test( "change handler should be detached from element", function( assert ) { + assert.expect( 2 ); var $fixture = jQuery( "<input type='text' id='change-ie-leak' />" ).appendTo( "body" ), originRemoveEvent = jQuery.removeEvent, wrapperRemoveEvent = function( elem, type, handle ) { - equal( "change", type, "Event handler for 'change' event should be removed" ); - equal( "change-ie-leak", jQuery( elem ).attr( "id" ), "Event handler for 'change' event should be removed from appropriate element" ); + assert.equal( "change", type, "Event handler for 'change' event should be removed" ); + assert.equal( "change-ie-leak", jQuery( elem ).attr( "id" ), "Event handler for 'change' event should be removed from appropriate element" ); originRemoveEvent( elem, type, handle ); }; @@ -2571,8 +2594,8 @@ test( "change handler should be detached from element", function() { jQuery.removeEvent = originRemoveEvent; } ); -asyncTest( "trigger click on checkbox, fires change event", function() { - expect( 1 ); +QUnit.asyncTest( "trigger click on checkbox, fires change event", function( assert ) { + assert.expect( 1 ); var check = jQuery( "#check2" ); @@ -2580,13 +2603,13 @@ asyncTest( "trigger click on checkbox, fires change event", function() { // get it? check.off( "change" ); - ok( true, "Change event fired as a result of triggered click" ); - start(); + assert.ok( true, "Change event fired as a result of triggered click" ); + QUnit.start(); } ).trigger( "click" ); } ); -test( "Namespace preserved when passed an Event (#12739)", function() { - expect( 4 ); +QUnit.test( "Namespace preserved when passed an Event (#12739)", function( assert ) { + assert.expect( 4 ); var markup = jQuery( "<div id='parent'><div id='child'></div></div>" @@ -2600,14 +2623,14 @@ test( "Namespace preserved when passed an Event (#12739)", function() { if ( !e.handled ) { triggered++; e.handled = true; - equal( e.namespace, "bar", "namespace is bar" ); + assert.equal( e.namespace, "bar", "namespace is bar" ); jQuery( e.target ).find( "div" ).each( function() { jQuery( this ).triggerHandler( e ); } ); } } ) .on( "foo.bar2", function() { - ok( false, "foo.bar2 called on trigger " + triggered + " id " + this.id ); + assert.ok( false, "foo.bar2 called on trigger " + triggered + " id " + this.id ); } ); markup.trigger( "foo.bar" ); @@ -2617,11 +2640,11 @@ test( "Namespace preserved when passed an Event (#12739)", function() { markup.trigger( fooEvent ); markup.remove(); - equal( triggered, 3, "foo.bar triggered" ); + assert.equal( triggered, 3, "foo.bar triggered" ); } ); -test( "make sure events cloned correctly", function() { - expect( 18 ); +QUnit.test( "make sure events cloned correctly", function( assert ) { + assert.expect( 18 ); var clone, fixture = jQuery( "#qunit-fixture" ), @@ -2629,21 +2652,21 @@ test( "make sure events cloned correctly", function() { p = jQuery( "#firstp" ); fixture.on( "click change", function( event, result ) { - ok( result, event.type + " on original element is fired" ); + assert.ok( result, event.type + " on original element is fired" ); } ).on( "click", "#firstp", function( event, result ) { - ok( result, "Click on original child element though delegation is fired" ); + assert.ok( result, "Click on original child element though delegation is fired" ); } ).on( "change", "#check1", function( event, result ) { - ok( result, "Change on original child element though delegation is fired" ); + assert.ok( result, "Change on original child element though delegation is fired" ); } ); p.on( "click", function() { - ok( true, "Click on original child element is fired" ); + assert.ok( true, "Click on original child element is fired" ); } ); checkbox.on( "change", function() { - ok( true, "Change on original child element is fired" ); + assert.ok( true, "Change on original child element is fired" ); } ); fixture.clone().trigger( "click" ).trigger( "change" ); // 0 events should be fired @@ -2673,8 +2696,8 @@ test( "make sure events cloned correctly", function() { clone.find( "#check1" ).trigger( "change" ); // 0 events should fire } ); -test( "String.prototype.namespace does not cause trigger() to throw (#13360)", function() { - expect( 1 ); +QUnit.test( "String.prototype.namespace does not cause trigger() to throw (#13360)", function( assert ) { + assert.expect( 1 ); var errored = false; String.prototype.namespace = function() {}; @@ -2684,20 +2707,20 @@ test( "String.prototype.namespace does not cause trigger() to throw (#13360)", f } catch ( e ) { errored = true; } - equal( errored, false, "trigger() did not throw exception" ); + assert.equal( errored, false, "trigger() did not throw exception" ); delete String.prototype.namespace; } ); -test( "Inline event result is returned (#13993)", function() { - expect( 1 ); +QUnit.test( "Inline event result is returned (#13993)", function( assert ) { + assert.expect( 1 ); var result = jQuery( "<p onclick='return 42'>hello</p>" ).triggerHandler( "click" ); - equal( result, 42, "inline handler returned value" ); + assert.equal( result, 42, "inline handler returned value" ); } ); -test( "preventDefault() on focusin does not throw exception", function( assert ) { - expect( 1 ); +QUnit.test( "preventDefault() on focusin does not throw exception", function( assert ) { + assert.expect( 1 ); var done = assert.async(), input = jQuery( "<input/>" ).appendTo( "#form" ); @@ -2718,7 +2741,7 @@ test( "preventDefault() on focusin does not throw exception", function( assert ) } ).trigger( "focus" ); } ); -test( "Donor event interference", function( assert ) { +QUnit.test( "Donor event interference", function( assert ) { assert.expect( 10 ); var html = "<div id='donor-outer'>" + @@ -2750,7 +2773,7 @@ test( "Donor event interference", function( assert ) { jQuery( "#donor-input" )[ 0 ].click(); } ); -test( "originalEvent property for IE8", function( assert ) { +QUnit.test( "originalEvent property for IE8", function( assert ) { if ( !( /msie 8\.0/i.test( window.navigator.userAgent ) ) ) { assert.expect( 1 ); assert.ok( true, "Assertions should run only in IE" ); @@ -2792,7 +2815,7 @@ test( "originalEvent property for IE8", function( assert ) { jQuery( "#donor-input" )[ 0 ].click(); } ); -test( "originalEvent property for Chrome, Safari and FF of simulated event", function( assert ) { +QUnit.test( "originalEvent property for Chrome, Safari and FF of simulated event", function( assert ) { var userAgent = window.navigator.userAgent; if ( !( /chrome/i.test( userAgent ) || @@ -2827,8 +2850,8 @@ test( "originalEvent property for Chrome, Safari and FF of simulated event", fun // This tests are unreliable in Firefox if ( !( /firefox/i.test( window.navigator.userAgent ) ) ) { - test( "Check order of focusin/focusout events", function() { - expect( 2 ); + QUnit.test( "Check order of focusin/focusout events", function( assert ) { + assert.expect( 2 ); var focus, blur, input = jQuery( "#name" ); @@ -2837,13 +2860,13 @@ if ( !( /firefox/i.test( window.navigator.userAgent ) ) ) { focus = true; } ).on( "focusin", function() { - ok( !focus, "Focusin event should fire before focus does" ); + assert.ok( !focus, "Focusin event should fire before focus does" ); } ).on( "blur", function() { blur = true; } ).on( "focusout", function() { - ok( !blur, "Focusout event should fire before blur does" ); + assert.ok( !blur, "Focusout event should fire before blur does" ); } ); // gain focus @@ -2856,8 +2879,8 @@ if ( !( /firefox/i.test( window.navigator.userAgent ) ) ) { input.off(); } ); - test( "focus-blur order (#12868)", function() { - expect( 5 ); + QUnit.test( "focus-blur order (#12868)", function( assert ) { + assert.expect( 5 ); var order, $text = jQuery( "#text1" ), @@ -2866,38 +2889,38 @@ if ( !( /firefox/i.test( window.navigator.userAgent ) ) ) { // Support: IE<11 // IE8-10 fire focus/blur events asynchronously; this is the resulting mess. // IE's browser window must be topmost for this to work properly!! - stop(); + QUnit.stop(); $radio[ 0 ].focus(); setTimeout( function() { $text .on( "focus", function() { - equal( order++, 1, "text focus" ); + assert.equal( order++, 1, "text focus" ); } ) .on( "blur", function() { - equal( order++, 0, "text blur" ); + assert.equal( order++, 0, "text blur" ); } ); $radio .on( "focus", function() { - equal( order++, 1, "radio focus" ); + assert.equal( order++, 1, "radio focus" ); } ) .on( "blur", function() { - equal( order++, 0, "radio blur" ); + assert.equal( order++, 0, "radio blur" ); } ); // Enabled input getting focus order = 0; - equal( document.activeElement, $radio[ 0 ], "radio has focus" ); + assert.equal( document.activeElement, $radio[ 0 ], "radio has focus" ); $text.trigger( "focus" ); setTimeout( function() { - equal( document.activeElement, $text[ 0 ], "text has focus" ); + assert.equal( document.activeElement, $text[ 0 ], "text has focus" ); // Run handlers without native method on an input order = 1; $radio.triggerHandler( "focus" ); $text.off(); - start(); + QUnit.start(); }, 50 ); }, 50 ); } ); diff --git a/test/unit/exports.js b/test/unit/exports.js index 113f42316..bca8954cf 100644 --- a/test/unit/exports.js +++ b/test/unit/exports.js @@ -1,7 +1,7 @@ -module( "exports", { teardown: moduleTeardown } ); +QUnit.module( "exports", { teardown: moduleTeardown } ); -test( "amdModule", function() { - expect( 1 ); +QUnit.test( "amdModule", function( assert ) { + assert.expect( 1 ); - equal( jQuery, amdDefined, "Make sure defined module matches jQuery" ); + assert.equal( jQuery, amdDefined, "Make sure defined module matches jQuery" ); } ); diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 26aedcbe2..f3a3e5415 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1,4 +1,4 @@ -module( "manipulation", { +QUnit.module( "manipulation", { teardown: moduleTeardown } ); @@ -29,55 +29,55 @@ function manipulationFunctionReturningObj( value ) { Returns a function that returns the value */ -test( "text()", function() { +QUnit.test( "text()", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var expected, frag, $newLineTest; expected = "This link has class=\"blog\": Simon Willison's Weblog"; - equal( jQuery( "#sap" ).text(), expected, "Check for merged text of more then one element." ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for merged text of more then one element." ); // Check serialization of text values - equal( jQuery( document.createTextNode( "foo" ) ).text(), "foo", "Text node was retrieved from .text()." ); - notEqual( jQuery( document ).text(), "", "Retrieving text for the document retrieves all text (#10724)." ); + assert.equal( jQuery( document.createTextNode( "foo" ) ).text(), "foo", "Text node was retrieved from .text()." ); + assert.notEqual( jQuery( document ).text(), "", "Retrieving text for the document retrieves all text (#10724)." ); // Retrieve from document fragments #10864 frag = document.createDocumentFragment(); frag.appendChild( document.createTextNode( "foo" ) ); - equal( jQuery( frag ).text(), "foo", "Document Fragment Text node was retrieved from .text()." ); + assert.equal( jQuery( frag ).text(), "foo", "Document Fragment Text node was retrieved from .text()." ); $newLineTest = jQuery( "<div>test<br/>testy</div>" ).appendTo( "#moretests" ); $newLineTest.find( "br" ).replaceWith( "\n" ); - equal( $newLineTest.text(), "test\ntesty", "text() does not remove new lines (#11153)" ); + assert.equal( $newLineTest.text(), "test\ntesty", "text() does not remove new lines (#11153)" ); $newLineTest.remove(); } ); -test( "text(undefined)", function() { +QUnit.test( "text(undefined)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); - equal( jQuery( "#foo" ).text( "<div" ).text( undefined )[ 0 ].innerHTML, "<div", ".text(undefined) is chainable (#5571)" ); + assert.equal( jQuery( "#foo" ).text( "<div" ).text( undefined )[ 0 ].innerHTML, "<div", ".text(undefined) is chainable (#5571)" ); } ); -function testText( valueObj ) { +function testText( valueObj, assert ) { - expect( 7 ); + assert.expect( 7 ); var val, j, expected, $multipleElements, $parentDiv, $childDiv; val = valueObj( "<div><b>Hello</b> cruel world!</div>" ); - equal( jQuery( "#foo" ).text( val )[ 0 ].innerHTML.replace( />/g, ">" ), "<div><b>Hello</b> cruel world!</div>", "Check escaped text" ); + assert.equal( jQuery( "#foo" ).text( val )[ 0 ].innerHTML.replace( />/g, ">" ), "<div><b>Hello</b> cruel world!</div>", "Check escaped text" ); // using contents will get comments regular, text, and comment nodes j = jQuery( "#nonnodes" ).contents(); j.text( valueObj( "hi!" ) ); - equal( jQuery( j[ 0 ] ).text(), "hi!", "Check node,textnode,comment with text()" ); - equal( j[ 1 ].nodeValue, " there ", "Check node,textnode,comment with text()" ); + assert.equal( jQuery( j[ 0 ] ).text(), "hi!", "Check node,textnode,comment with text()" ); + assert.equal( j[ 1 ].nodeValue, " there ", "Check node,textnode,comment with text()" ); - equal( j[ 2 ].nodeType, 8, "Check node,textnode,comment with text()" ); + assert.equal( j[ 2 ].nodeType, 8, "Check node,textnode,comment with text()" ); // Update multiple elements #11809 expected = "New"; @@ -85,8 +85,8 @@ function testText( valueObj ) { $multipleElements = jQuery( "<div>Hello</div>" ).add( "<div>World</div>" ); $multipleElements.text( expected ); - equal( $multipleElements.eq( 0 ).text(), expected, "text() updates multiple elements (#11809)" ); - equal( $multipleElements.eq( 1 ).text(), expected, "text() updates multiple elements (#11809)" ); + assert.equal( $multipleElements.eq( 0 ).text(), expected, "text() updates multiple elements (#11809)" ); + assert.equal( $multipleElements.eq( 1 ).text(), expected, "text() updates multiple elements (#11809)" ); // Prevent memory leaks #11809 $childDiv = jQuery( "<div/>" ); @@ -95,32 +95,32 @@ function testText( valueObj ) { $parentDiv.append( $childDiv ); $parentDiv.text( "Dry off" ); - equal( $childDiv.data( "leak" ), undefined, "Check for leaks (#11809)" ); + assert.equal( $childDiv.data( "leak" ), undefined, "Check for leaks (#11809)" ); } -test( "text(String)", function() { - testText( manipulationBareObj ); +QUnit.test( "text(String)", function( assert ) { + testText(manipulationBareObj, assert ); } ); -test( "text(Function)", function() { - testText( manipulationFunctionReturningObj ); +QUnit.test( "text(Function)", function( assert ) { + testText(manipulationFunctionReturningObj, assert ); } ); -test( "text(Function) with incoming value", function() { +QUnit.test( "text(Function) with incoming value", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var old = "This link has class=\"blog\": Simon Willison's Weblog"; jQuery( "#sap" ).text( function( i, val ) { - equal( val, old, "Make sure the incoming value is correct." ); + assert.equal( val, old, "Make sure the incoming value is correct." ); return "foobar"; } ); - equal( jQuery( "#sap" ).text(), "foobar", "Check for merged text of more then one element." ); + assert.equal( jQuery( "#sap" ).text(), "foobar", "Check for merged text of more then one element." ); } ); -function testAppendForObject( valueObj, isFragment ) { +function testAppendForObject( valueObj, isFragment, assert ) { var $base, type = isFragment ? " (DocumentFragment)" : " (Element)", text = "This link has class=\"blog\": Simon Willison's Weblog", @@ -138,68 +138,68 @@ function testAppendForObject( valueObj, isFragment ) { $base = jQuery( el ); } - equal( $base.clone().append( valueObj( first.cloneNode( true ) ) ).text(), + assert.equal( $base.clone().append( valueObj( first.cloneNode( true ) ) ).text(), text + "Try them out:", "Check for appending of element" + type ); - equal( $base.clone().append( valueObj( [ first.cloneNode( true ), yahoo.cloneNode( true ) ] ) ).text(), + assert.equal( $base.clone().append( valueObj( [ first.cloneNode( true ), yahoo.cloneNode( true ) ] ) ).text(), text + "Try them out:Yahoo", "Check for appending of array of elements" + type ); - equal( $base.clone().append( valueObj( jQuery( "#yahoo, #first" ).clone() ) ).text(), + assert.equal( $base.clone().append( valueObj( jQuery( "#yahoo, #first" ).clone() ) ).text(), text + "YahooTry them out:", "Check for appending of jQuery object" + type ); - equal( $base.clone().append( valueObj( 5 ) ).text(), + assert.equal( $base.clone().append( valueObj( 5 ) ).text(), text + "5", "Check for appending a number" + type ); - equal( $base.clone().append( valueObj( [ jQuery( "#first" ).clone(), jQuery( "#yahoo, #google" ).clone() ] ) ).text(), + assert.equal( $base.clone().append( valueObj( [ jQuery( "#first" ).clone(), jQuery( "#yahoo, #google" ).clone() ] ) ).text(), text + "Try them out:GoogleYahoo", "Check for appending of array of jQuery objects" ); - equal( $base.clone().append( valueObj( " text with spaces " ) ).text(), + assert.equal( $base.clone().append( valueObj( " text with spaces " ) ).text(), text + " text with spaces ", "Check for appending text with spaces" + type ); - equal( $base.clone().append( valueObj( [] ) ).text(), + assert.equal( $base.clone().append( valueObj( [] ) ).text(), text, "Check for appending an empty array" + type ); - equal( $base.clone().append( valueObj( "" ) ).text(), + assert.equal( $base.clone().append( valueObj( "" ) ).text(), text, "Check for appending an empty string" + type ); - equal( $base.clone().append( valueObj( document.getElementsByTagName( "foo" ) ) ).text(), + assert.equal( $base.clone().append( valueObj( document.getElementsByTagName( "foo" ) ) ).text(), text, "Check for appending an empty nodelist" + type ); - equal( $base.clone().append( "<span></span>", "<span></span>", "<span></span>" ).children().length, + assert.equal( $base.clone().append( "<span></span>", "<span></span>", "<span></span>" ).children().length, $base.children().length + 3, "Make sure that multiple arguments works." + type ); - equal( $base.clone().append( valueObj( document.getElementById( "form" ).cloneNode( true ) ) ).children( "form" ).length, + assert.equal( $base.clone().append( valueObj( document.getElementById( "form" ).cloneNode( true ) ) ).children( "form" ).length, 1, "Check for appending a form (#910)" + type ); } -function testAppend( valueObj ) { +function testAppend( valueObj, assert ) { - expect( 78 ); + assert.expect( 78 ); - testAppendForObject( valueObj, false ); - testAppendForObject( valueObj, true ); + testAppendForObject( valueObj,false, assert ); + testAppendForObject( valueObj,true, assert ); var defaultText, result, message, iframe, iframeDoc, j, d, $input, $radioChecked, $radioUnchecked, $radioParent, $map, $table; @@ -207,27 +207,27 @@ function testAppend( valueObj ) { defaultText = "Try them out:"; result = jQuery( "#first" ).append( valueObj( "<b>buga</b>" ) ); - equal( result.text(), defaultText + "buga", "Check if text appending works" ); - equal( jQuery( "#select3" ).append( valueObj( "<option value='appendTest'>Append Test</option>" ) ).find( "option:last-child" ).attr( "value" ), "appendTest", "Appending html options to select element" ); + assert.equal( result.text(), defaultText + "buga", "Check if text appending works" ); + assert.equal( jQuery( "#select3" ).append( valueObj( "<option value='appendTest'>Append Test</option>" ) ).find( "option:last-child" ).attr( "value" ), "appendTest", "Appending html options to select element" ); jQuery( "#qunit-fixture form" ).append( valueObj( "<input name='radiotest' type='radio' checked='checked' />" ) ); jQuery( "#qunit-fixture form input[name=radiotest]" ).each( function() { - ok( jQuery( this ).is( ":checked" ), "Append checked radio" ); + assert.ok( jQuery( this ).is( ":checked" ), "Append checked radio" ); } ).remove(); jQuery( "#qunit-fixture form" ).append( valueObj( "<input name='radiotest2' type='radio' checked = 'checked' />" ) ); jQuery( "#qunit-fixture form input[name=radiotest2]" ).each( function() { - ok( jQuery( this ).is( ":checked" ), "Append alternately formated checked radio" ); + assert.ok( jQuery( this ).is( ":checked" ), "Append alternately formated checked radio" ); } ).remove(); jQuery( "#qunit-fixture form" ).append( valueObj( "<input name='radiotest3' type='radio' checked />" ) ); jQuery( "#qunit-fixture form input[name=radiotest3]" ).each( function() { - ok( jQuery( this ).is( ":checked" ), "Append HTML5-formated checked radio" ); + assert.ok( jQuery( this ).is( ":checked" ), "Append HTML5-formated checked radio" ); } ).remove(); jQuery( "#qunit-fixture form" ).append( valueObj( "<input type='radio' checked='checked' name='radiotest4' />" ) ); jQuery( "#qunit-fixture form input[name=radiotest4]" ).each( function() { - ok( jQuery( this ).is( ":checked" ), "Append with name attribute after checked attribute" ); + assert.ok( jQuery( this ).is( ":checked" ), "Append with name attribute after checked attribute" ); } ).remove(); message = "Test for appending a DOM node to the contents of an iframe"; @@ -236,12 +236,12 @@ function testAppend( valueObj ) { try { if ( iframeDoc && iframeDoc.body ) { - equal( jQuery( iframeDoc.body ).append( valueObj( "<div id='success'>test</div>" ) )[ 0 ].lastChild.id, "success", message ); + assert.equal( jQuery( iframeDoc.body ).append( valueObj( "<div id='success'>test</div>" ) )[ 0 ].lastChild.id, "success", message ); } else { - ok( true, message + " - can't test" ); + assert.ok( true, message + " - can't test" ); } } catch ( e ) { - strictEqual( e.message || e, undefined, message ); + assert.strictEqual( e.message || e, undefined, message ); } jQuery( "<fieldset/>" ).appendTo( "#form" ).append( valueObj( "<legend id='legend'>test</legend>" ) ); @@ -249,47 +249,47 @@ function testAppend( valueObj ) { $map = jQuery( "<map/>" ).append( valueObj( "<area id='map01' shape='rect' coords='50,50,150,150' href='http://www.jquery.com/' alt='jQuery'>" ) ); - equal( $map[ 0 ].childNodes.length, 1, "The area was inserted." ); - equal( $map[ 0 ].firstChild.nodeName.toLowerCase(), "area", "The area was inserted." ); + assert.equal( $map[ 0 ].childNodes.length, 1, "The area was inserted." ); + assert.equal( $map[ 0 ].firstChild.nodeName.toLowerCase(), "area", "The area was inserted." ); jQuery( "#select1" ).append( valueObj( "<OPTION>Test</OPTION>" ) ); - equal( jQuery( "#select1 option:last-child" ).text(), "Test", "Appending OPTION (all caps)" ); + assert.equal( jQuery( "#select1 option:last-child" ).text(), "Test", "Appending OPTION (all caps)" ); jQuery( "#select1" ).append( valueObj( "<optgroup label='optgroup'><option>optgroup</option></optgroup>" ) ); - equal( jQuery( "#select1 optgroup" ).attr( "label" ), "optgroup", "Label attribute in newly inserted optgroup is correct" ); - equal( jQuery( "#select1 option" ).last().text(), "optgroup", "Appending optgroup" ); + assert.equal( jQuery( "#select1 optgroup" ).attr( "label" ), "optgroup", "Label attribute in newly inserted optgroup is correct" ); + assert.equal( jQuery( "#select1 option" ).last().text(), "optgroup", "Appending optgroup" ); $table = jQuery( "#table" ).empty(); jQuery.each( "thead tbody tfoot colgroup caption tr th td".split( " " ), function( i, name ) { $table.append( valueObj( "<" + name + "/>" ) ); - ok( $table.find( name ).length >= 1, "Append " + name ); - ok( jQuery.parseHTML( "<" + name + "/>" ).length, name + " wrapped correctly" ); + assert.ok( $table.find( name ).length >= 1, "Append " + name ); + assert.ok( jQuery.parseHTML( "<" + name + "/>" ).length, name + " wrapped correctly" ); } ); jQuery( "#table colgroup" ).append( valueObj( "<col/>" ) ); - equal( jQuery( "#table colgroup col" ).length, 1, "Append col" ); + assert.equal( jQuery( "#table colgroup col" ).length, 1, "Append col" ); jQuery( "#form" ) .append( valueObj( "<select id='appendSelect1'></select>" ) ) .append( valueObj( "<select id='appendSelect2'><option>Test</option></select>" ) ); t( "Append Select", "#appendSelect1, #appendSelect2", [ "appendSelect1", "appendSelect2" ] ); - equal( "Two nodes", jQuery( "<div />" ).append( "Two", " nodes" ).text(), "Appending two text nodes (#4011)" ); - equal( jQuery( "<div />" ).append( "1", "", 3 ).text(), "13", "If median is false-like value, subsequent arguments should not be ignored" ); + assert.equal( "Two nodes", jQuery( "<div />" ).append( "Two", " nodes" ).text(), "Appending two text nodes (#4011)" ); + assert.equal( jQuery( "<div />" ).append( "1", "", 3 ).text(), "13", "If median is false-like value, subsequent arguments should not be ignored" ); // using contents will get comments regular, text, and comment nodes j = jQuery( "#nonnodes" ).contents(); d = jQuery( "<div/>" ).appendTo( "#nonnodes" ).append( j ); - equal( jQuery( "#nonnodes" ).length, 1, "Check node,textnode,comment append moved leaving just the div" ); - equal( d.contents().length, 3, "Check node,textnode,comment append works" ); + assert.equal( jQuery( "#nonnodes" ).length, 1, "Check node,textnode,comment append moved leaving just the div" ); + assert.equal( d.contents().length, 3, "Check node,textnode,comment append works" ); d.contents().appendTo( "#nonnodes" ); d.remove(); - equal( jQuery( "#nonnodes" ).contents().length, 3, "Check node,textnode,comment append cleanup worked" ); + assert.equal( jQuery( "#nonnodes" ).contents().length, 3, "Check node,textnode,comment append cleanup worked" ); $input = jQuery( "<input type='checkbox'/>" ).prop( "checked", true ).appendTo( "#testForm" ); - equal( $input[ 0 ].checked, true, "A checked checkbox that is appended stays checked" ); + assert.equal( $input[ 0 ].checked, true, "A checked checkbox that is appended stays checked" ); $radioChecked = jQuery( "input[type='radio'][name='R1']" ).eq( 1 ); $radioParent = $radioChecked.parent(); @@ -299,40 +299,40 @@ function testAppend( valueObj ) { jQuery( "<div/>" ).insertBefore( $radioParent ).append( $radioParent ); - equal( $radioChecked[ 0 ].checked, true, "Reappending radios uphold which radio is checked" ); - equal( $radioUnchecked[ 0 ].checked, false, "Reappending radios uphold not being checked" ); + assert.equal( $radioChecked[ 0 ].checked, true, "Reappending radios uphold which radio is checked" ); + assert.equal( $radioUnchecked[ 0 ].checked, false, "Reappending radios uphold not being checked" ); - equal( jQuery( "<div/>" ).append( valueObj( "option<area/>" ) )[ 0 ].childNodes.length, 2, "HTML-string with leading text should be processed correctly" ); + assert.equal( jQuery( "<div/>" ).append( valueObj( "option<area/>" ) )[ 0 ].childNodes.length, 2, "HTML-string with leading text should be processed correctly" ); } -test( "append(String|Element|Array<Element>|jQuery)", function() { - testAppend( manipulationBareObj ); +QUnit.test( "append(String|Element|Array<Element>|jQuery)", function( assert ) { + testAppend(manipulationBareObj, assert ); } ); -test( "append(Function)", function() { - testAppend( manipulationFunctionReturningObj ); +QUnit.test( "append(Function)", function( assert ) { + testAppend(manipulationFunctionReturningObj, assert ); } ); -test( "append(param) to object, see #11280", function() { +QUnit.test( "append(param) to object, see #11280", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var object = jQuery( document.createElement( "object" ) ).appendTo( document.body ); - equal( object.children().length, 0, "object does not start with children" ); + assert.equal( object.children().length, 0, "object does not start with children" ); object.append( jQuery( "<param type='wmode' name='foo'>" ) ); - equal( object.children().length, 1, "appended param" ); - equal( object.children().eq( 0 ).attr( "name" ), "foo", "param has name=foo" ); + assert.equal( object.children().length, 1, "appended param" ); + assert.equal( object.children().eq( 0 ).attr( "name" ), "foo", "param has name=foo" ); object = jQuery( "<object><param type='baz' name='bar'></object>" ); - equal( object.children().length, 1, "object created with child param" ); - equal( object.children().eq( 0 ).attr( "name" ), "bar", "param has name=bar" ); + assert.equal( object.children().length, 1, "object created with child param" ); + assert.equal( object.children().eq( 0 ).attr( "name" ), "bar", "param has name=bar" ); } ); -test( "append(Function) returns String", function() { +QUnit.test( "append(Function) returns String", function( assert ) { - expect( 4 ); + assert.expect( 4 ); var defaultText, result, select, old; @@ -340,74 +340,74 @@ test( "append(Function) returns String", function() { old = jQuery( "#first" ).html(); result = jQuery( "#first" ).append( function( i, val ) { - equal( val, old, "Make sure the incoming value is correct." ); + assert.equal( val, old, "Make sure the incoming value is correct." ); return "<b>buga</b>"; } ); - equal( result.text(), defaultText + "buga", "Check if text appending works" ); + assert.equal( result.text(), defaultText + "buga", "Check if text appending works" ); select = jQuery( "#select3" ); old = select.html(); - equal( select.append( function( i, val ) { - equal( val, old, "Make sure the incoming value is correct." ); + assert.equal( select.append( function( i, val ) { + assert.equal( val, old, "Make sure the incoming value is correct." ); return "<option value='appendTest'>Append Test</option>"; } ).find( "option:last-child" ).attr( "value" ), "appendTest", "Appending html options to select element" ); } ); -test( "append(Function) returns Element", function() { +QUnit.test( "append(Function) returns Element", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:", old = jQuery( "#sap" ).html(); jQuery( "#sap" ).append( function( i, val ) { - equal( val, old, "Make sure the incoming value is correct." ); + assert.equal( val, old, "Make sure the incoming value is correct." ); return document.getElementById( "first" ); } ); - equal( jQuery( "#sap" ).text(), expected, "Check for appending of element" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for appending of element" ); } ); -test( "append(Function) returns Array<Element>", function() { +QUnit.test( "append(Function) returns Array<Element>", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo", old = jQuery( "#sap" ).html(); jQuery( "#sap" ).append( function( i, val ) { - equal( val, old, "Make sure the incoming value is correct." ); + assert.equal( val, old, "Make sure the incoming value is correct." ); return [ document.getElementById( "first" ), document.getElementById( "yahoo" ) ]; } ); - equal( jQuery( "#sap" ).text(), expected, "Check for appending of array of elements" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for appending of array of elements" ); } ); -test( "append(Function) returns jQuery", function() { +QUnit.test( "append(Function) returns jQuery", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:", old = jQuery( "#sap" ).html(); jQuery( "#sap" ).append( function( i, val ) { - equal( val, old, "Make sure the incoming value is correct." ); + assert.equal( val, old, "Make sure the incoming value is correct." ); return jQuery( "#yahoo, #first" ); } ); - equal( jQuery( "#sap" ).text(), expected, "Check for appending of jQuery object" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for appending of jQuery object" ); } ); -test( "append(Function) returns Number", function() { +QUnit.test( "append(Function) returns Number", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var old = jQuery( "#sap" ).html(); jQuery( "#sap" ).append( function( i, val ) { - equal( val, old, "Make sure the incoming value is correct." ); + assert.equal( val, old, "Make sure the incoming value is correct." ); return 5; } ); - ok( jQuery( "#sap" )[ 0 ].innerHTML.match( /5$/ ), "Check for appending a number" ); + assert.ok( jQuery( "#sap" )[ 0 ].innerHTML.match( /5$/ ), "Check for appending a number" ); } ); -test( "XML DOM manipulation (#9960)", function() { +QUnit.test( "XML DOM manipulation (#9960)", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var scxml1Adopted, xmlDoc1 = jQuery.parseXML( "<scxml xmlns='http://www.w3.org/2005/07/scxml' version='1.0'><state x='100' y='100' initial='actions' id='provisioning'></state><state x='100' y='100' id='error'></state><state x='100' y='100' id='finished' final='true'></state></scxml>" ), @@ -428,16 +428,16 @@ test( "XML DOM manipulation (#9960)", function() { } scxml1.append( state ); - strictEqual( scxml1[ 0 ].lastChild, state[ 0 ], "append" ); + assert.strictEqual( scxml1[ 0 ].lastChild, state[ 0 ], "append" ); scxml1.prepend( state ); - strictEqual( scxml1[ 0 ].firstChild, state[ 0 ], "prepend" ); + assert.strictEqual( scxml1[ 0 ].firstChild, state[ 0 ], "prepend" ); scxml1.find( "#finished" ).after( state ); - strictEqual( scxml1[ 0 ].lastChild, state[ 0 ], "after" ); + assert.strictEqual( scxml1[ 0 ].lastChild, state[ 0 ], "after" ); scxml1.find( "#provisioning" ).before( state ); - strictEqual( scxml1[ 0 ].firstChild, state[ 0 ], "before" ); + assert.strictEqual( scxml1[ 0 ].firstChild, state[ 0 ], "before" ); // Support: Android 2.3 if ( /android 2\.3/i.test( navigator.userAgent ) ) { @@ -446,24 +446,24 @@ test( "XML DOM manipulation (#9960)", function() { } else { scxml2.replaceWith( scxml1 ); } - deepEqual( jQuery( "state", xml2 ).get(), scxml1.find( "state" ).get(), "replaceWith" ); + assert.deepEqual( jQuery( "state", xml2 ).get(), scxml1.find( "state" ).get(), "replaceWith" ); } ); -test( "append the same fragment with events (Bug #6997, 5566)", function() { +QUnit.test( "append the same fragment with events (Bug #6997, 5566)", function( assert ) { var element, clone, doExtra = !jQuery.support.noCloneEvent && document[ "fireEvent" ]; - expect( 2 + ( doExtra ? 1 : 0 ) ); + assert.expect( 2 + ( doExtra ? 1 : 0 ) ); - stop(); + QUnit.stop(); // This patch modified the way that cloning occurs in IE; we need to make sure that // native event handlers on the original object don't get disturbed when they are // modified on the clone if ( doExtra ) { element = jQuery( "div:first" ).on( "click", function() { - ok( true, "Event exists on original after being unbound on clone" ); + assert.ok( true, "Event exists on original after being unbound on clone" ); jQuery( this ).off( "click" ); } ); clone = element.clone( true ).off( "click" ); @@ -475,24 +475,24 @@ test( "append the same fragment with events (Bug #6997, 5566)", function() { } element = jQuery( "<a class='test6997'></a>" ).on( "click", function() { - ok( true, "Append second element events work" ); + assert.ok( true, "Append second element events work" ); } ); jQuery( "#listWithTabIndex li" ).append( element ) .find( "a.test6997" ).eq( 1 ).trigger( "click" ); element = jQuery( "<li class='test6997'></li>" ).on( "click", function() { - ok( true, "Before second element events work" ); - start(); + assert.ok( true, "Before second element events work" ); + QUnit.start(); } ); jQuery( "#listWithTabIndex li" ).before( element ); jQuery( "#listWithTabIndex li.test6997" ).eq( 1 ).trigger( "click" ); } ); -test( "append HTML5 sectioning elements (Bug #6485)", function() { +QUnit.test( "append HTML5 sectioning elements (Bug #6485)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var article, aside; @@ -501,81 +501,81 @@ test( "append HTML5 sectioning elements (Bug #6485)", function() { article = jQuery( "article" ); aside = jQuery( "aside" ); - equal( article.get( 0 ).style.fontSize, "10px", "HTML5 elements are styleable" ); - equal( aside.length, 1, "HTML5 elements do not collapse their children" ); + assert.equal( article.get( 0 ).style.fontSize, "10px", "HTML5 elements are styleable" ); + assert.equal( aside.length, 1, "HTML5 elements do not collapse their children" ); } ); if ( jQuery.css ) { - test( "HTML5 Elements inherit styles from style rules (Bug #10501)", function() { + QUnit.test( "HTML5 Elements inherit styles from style rules (Bug #10501)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); jQuery( "#qunit-fixture" ).append( "<article id='article'></article>" ); jQuery( "#article" ).append( "<section>This section should have a pink background.</section>" ); // In IE, the missing background color will claim its value is "transparent" - notEqual( jQuery( "section" ).css( "background-color" ), "transparent", "HTML5 elements inherit styles" ); + assert.notEqual( jQuery( "section" ).css( "background-color" ), "transparent", "HTML5 elements inherit styles" ); } ); } -test( "html(String) with HTML5 (Bug #6485)", function() { +QUnit.test( "html(String) with HTML5 (Bug #6485)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); jQuery( "#qunit-fixture" ).html( "<article><section><aside>HTML5 elements</aside></section></article>" ); - equal( jQuery( "#qunit-fixture" ).children().children().length, 1, "Make sure HTML5 article elements can hold children. innerHTML shortcut path" ); - equal( jQuery( "#qunit-fixture" ).children().children().children().length, 1, "Make sure nested HTML5 elements can hold children." ); + assert.equal( jQuery( "#qunit-fixture" ).children().children().length, 1, "Make sure HTML5 article elements can hold children. innerHTML shortcut path" ); + assert.equal( jQuery( "#qunit-fixture" ).children().children().children().length, 1, "Make sure nested HTML5 elements can hold children." ); } ); -test( "html(String) tag-hyphenated elements (Bug #1987)", function() { +QUnit.test( "html(String) tag-hyphenated elements (Bug #1987)", function( assert ) { // Support: IE8 if ( /msie 8\.0/i.test( navigator.userAgent ) ) { - expect( 1 ); - ok( true, "IE8 doesn't support custom elements" ); + assert.expect( 1 ); + assert.ok( true, "IE8 doesn't support custom elements" ); return; } - expect( 27 ); + assert.expect( 27 ); jQuery.each( "thead tbody tfoot colgroup caption tr th td".split( " " ), function( i, name ) { var j = jQuery( "<" + name + "-d></" + name + "-d><" + name + "-d></" + name + "-d>" ); - ok( j[ 0 ], "Create a tag-hyphenated element" ); - ok( jQuery.nodeName( j[ 0 ], name.toUpperCase() + "-D" ), "Hyphenated node name" ); - ok( jQuery.nodeName( j[ 1 ], name.toUpperCase() + "-D" ), "Hyphenated node name" ); + assert.ok( j[ 0 ], "Create a tag-hyphenated element" ); + assert.ok( jQuery.nodeName( j[ 0 ], name.toUpperCase() + "-D" ), "Hyphenated node name" ); + assert.ok( jQuery.nodeName( j[ 1 ], name.toUpperCase() + "-D" ), "Hyphenated node name" ); } ); var j = jQuery( "<tr-multiple-hyphens><td-with-hyphen>text</td-with-hyphen></tr-multiple-hyphens>" ); - ok( jQuery.nodeName( j[ 0 ], "TR-MULTIPLE-HYPHENS" ), "Tags with multiple hypens" ); - ok( jQuery.nodeName( j.children()[ 0 ], "TD-WITH-HYPHEN" ), "Tags with multiple hypens" ); - equal( j.children().text(), "text", "Tags with multiple hypens behave normally" ); + assert.ok( jQuery.nodeName( j[ 0 ], "TR-MULTIPLE-HYPHENS" ), "Tags with multiple hypens" ); + assert.ok( jQuery.nodeName( j.children()[ 0 ], "TD-WITH-HYPHEN" ), "Tags with multiple hypens" ); + assert.equal( j.children().text(), "text", "Tags with multiple hypens behave normally" ); } ); -test( "IE8 serialization bug", function() { +QUnit.test( "IE8 serialization bug", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var wrapper = jQuery( "<div></div>" ); wrapper.html( "<div></div><article></article>" ); - equal( wrapper.children( "article" ).length, 1, "HTML5 elements are insertable with .html()" ); + assert.equal( wrapper.children( "article" ).length, 1, "HTML5 elements are insertable with .html()" ); wrapper.html( "<div></div><link></link>" ); - equal( wrapper.children( "link" ).length, 1, "Link elements are insertable with .html()" ); + assert.equal( wrapper.children( "link" ).length, 1, "Link elements are insertable with .html()" ); } ); -test( "html() object element #10324", function() { +QUnit.test( "html() object element #10324", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var object = jQuery( "<object id='object2'><param name='object2test' value='test'></param></object>?" ).appendTo( "#qunit-fixture" ), clone = object.clone(); - equal( clone.html(), object.html(), "html() returns correct innerhtml of cloned object elements" ); + assert.equal( clone.html(), object.html(), "html() returns correct innerhtml of cloned object elements" ); } ); -test( "append(xml)", function() { +QUnit.test( "append(xml)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var xmlDoc, xml1, xml2; @@ -608,60 +608,60 @@ test( "append(xml)", function() { xml1 = xmlDoc.createElement( "head" ); xml2 = xmlDoc.createElement( "test" ); - ok( jQuery( xml1 ).append( xml2 ), "Append an xml element to another without raising an exception." ); + assert.ok( jQuery( xml1 ).append( xml2 ), "Append an xml element to another without raising an exception." ); } ); -test( "appendTo(String)", function() { +QUnit.test( "appendTo(String)", function( assert ) { - expect( 4 ); + assert.expect( 4 ); var l, defaultText; defaultText = "Try them out:"; jQuery( "<b>buga</b>" ).appendTo( "#first" ); - equal( jQuery( "#first" ).text(), defaultText + "buga", "Check if text appending works" ); - equal( jQuery( "<option value='appendTest'>Append Test</option>" ).appendTo( "#select3" ).parent().find( "option:last-child" ).attr( "value" ), "appendTest", "Appending html options to select element" ); + assert.equal( jQuery( "#first" ).text(), defaultText + "buga", "Check if text appending works" ); + assert.equal( jQuery( "<option value='appendTest'>Append Test</option>" ).appendTo( "#select3" ).parent().find( "option:last-child" ).attr( "value" ), "appendTest", "Appending html options to select element" ); l = jQuery( "#first" ).children().length + 2; jQuery( "<strong>test</strong>" ); jQuery( "<strong>test</strong>" ); jQuery( [ jQuery( "<strong>test</strong>" )[ 0 ], jQuery( "<strong>test</strong>" )[ 0 ] ] ) .appendTo( "#first" ); - equal( jQuery( "#first" ).children().length, l, "Make sure the elements were inserted." ); - equal( jQuery( "#first" ).children().last()[ 0 ].nodeName.toLowerCase(), "strong", "Verify the last element." ); + assert.equal( jQuery( "#first" ).children().length, l, "Make sure the elements were inserted." ); + assert.equal( jQuery( "#first" ).children().last()[ 0 ].nodeName.toLowerCase(), "strong", "Verify the last element." ); } ); -test( "appendTo(Element|Array<Element>)", function() { +QUnit.test( "appendTo(Element|Array<Element>)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:"; jQuery( document.getElementById( "first" ) ).appendTo( "#sap" ); - equal( jQuery( "#sap" ).text(), expected, "Check for appending of element" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for appending of element" ); expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo"; jQuery( [ document.getElementById( "first" ), document.getElementById( "yahoo" ) ] ).appendTo( "#sap" ); - equal( jQuery( "#sap" ).text(), expected, "Check for appending of array of elements" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for appending of array of elements" ); } ); -test( "appendTo(jQuery)", function() { +QUnit.test( "appendTo(jQuery)", function( assert ) { - expect( 10 ); + assert.expect( 10 ); var expected, num, div; - ok( jQuery( document.createElement( "script" ) ).appendTo( "body" ).length, "Make sure a disconnected script can be appended." ); + assert.ok( jQuery( document.createElement( "script" ) ).appendTo( "body" ).length, "Make sure a disconnected script can be appended." ); expected = "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:"; jQuery( "#yahoo, #first" ).appendTo( "#sap" ); - equal( jQuery( "#sap" ).text(), expected, "Check for appending of jQuery object" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for appending of jQuery object" ); jQuery( "#select1" ).appendTo( "#foo" ); t( "Append select", "#foo select", [ "select1" ] ); div = jQuery( "<div/>" ).on( "click", function() { - ok( true, "Running a cloned click." ); + assert.ok( true, "Running a cloned click." ); } ); div.appendTo( "#qunit-fixture, #moretests" ); @@ -670,197 +670,197 @@ test( "appendTo(jQuery)", function() { div = jQuery( "<div/>" ).appendTo( "#qunit-fixture, #moretests" ); - equal( div.length, 2, "appendTo returns the inserted elements" ); + assert.equal( div.length, 2, "appendTo returns the inserted elements" ); div.addClass( "test" ); - ok( jQuery( "#qunit-fixture div" ).last().hasClass( "test" ), "appendTo element was modified after the insertion" ); - ok( jQuery( "#moretests div" ).last().hasClass( "test" ), "appendTo element was modified after the insertion" ); + assert.ok( jQuery( "#qunit-fixture div" ).last().hasClass( "test" ), "appendTo element was modified after the insertion" ); + assert.ok( jQuery( "#moretests div" ).last().hasClass( "test" ), "appendTo element was modified after the insertion" ); div = jQuery( "<div/>" ); jQuery( "<span>a</span><b>b</b>" ).filter( "span" ).appendTo( div ); - equal( div.children().length, 1, "Make sure the right number of children were inserted." ); + assert.equal( div.children().length, 1, "Make sure the right number of children were inserted." ); div = jQuery( "#moretests div" ); num = jQuery( "#qunit-fixture div" ).length; div.remove().appendTo( "#qunit-fixture" ); - equal( jQuery( "#qunit-fixture div" ).length, num, "Make sure all the removed divs were inserted." ); + assert.equal( jQuery( "#qunit-fixture div" ).length, num, "Make sure all the removed divs were inserted." ); } ); -test( "prepend(String)", function() { +QUnit.test( "prepend(String)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var result, expected; expected = "Try them out:"; result = jQuery( "#first" ).prepend( "<b>buga</b>" ); - equal( result.text(), "buga" + expected, "Check if text prepending works" ); - equal( jQuery( "#select3" ).prepend( "<option value='prependTest'>Prepend Test</option>" ).find( "option:first-child" ).attr( "value" ), "prependTest", "Prepending html options to select element" ); + assert.equal( result.text(), "buga" + expected, "Check if text prepending works" ); + assert.equal( jQuery( "#select3" ).prepend( "<option value='prependTest'>Prepend Test</option>" ).find( "option:first-child" ).attr( "value" ), "prependTest", "Prepending html options to select element" ); } ); -test( "prepend(Element)", function() { +QUnit.test( "prepend(Element)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog"; jQuery( "#sap" ).prepend( document.getElementById( "first" ) ); - equal( jQuery( "#sap" ).text(), expected, "Check for prepending of element" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for prepending of element" ); } ); -test( "prepend(Array<Element>)", function() { +QUnit.test( "prepend(Array<Element>)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog"; jQuery( "#sap" ).prepend( [ document.getElementById( "first" ), document.getElementById( "yahoo" ) ] ); - equal( jQuery( "#sap" ).text(), expected, "Check for prepending of array of elements" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for prepending of array of elements" ); } ); -test( "prepend(jQuery)", function() { +QUnit.test( "prepend(jQuery)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog"; jQuery( "#sap" ).prepend( jQuery( "#yahoo, #first" ) ); - equal( jQuery( "#sap" ).text(), expected, "Check for prepending of jQuery object" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for prepending of jQuery object" ); } ); -test( "prepend(Array<jQuery>)", function() { +QUnit.test( "prepend(Array<jQuery>)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "Try them out:GoogleYahooThis link has class=\"blog\": Simon Willison's Weblog"; jQuery( "#sap" ).prepend( [ jQuery( "#first" ), jQuery( "#yahoo, #google" ) ] ); - equal( jQuery( "#sap" ).text(), expected, "Check for prepending of array of jQuery objects" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for prepending of array of jQuery objects" ); } ); -test( "prepend(Function) with incoming value -- String", function() { +QUnit.test( "prepend(Function) with incoming value -- String", function( assert ) { - expect( 4 ); + assert.expect( 4 ); var defaultText, old, result; defaultText = "Try them out:"; old = jQuery( "#first" ).html(); result = jQuery( "#first" ).prepend( function( i, val ) { - equal( val, old, "Make sure the incoming value is correct." ); + assert.equal( val, old, "Make sure the incoming value is correct." ); return "<b>buga</b>"; } ); - equal( result.text(), "buga" + defaultText, "Check if text prepending works" ); + assert.equal( result.text(), "buga" + defaultText, "Check if text prepending works" ); old = jQuery( "#select3" ).html(); - equal( jQuery( "#select3" ).prepend( function( i, val ) { - equal( val, old, "Make sure the incoming value is correct." ); + assert.equal( jQuery( "#select3" ).prepend( function( i, val ) { + assert.equal( val, old, "Make sure the incoming value is correct." ); return "<option value='prependTest'>Prepend Test</option>"; } ).find( "option:first-child" ).attr( "value" ), "prependTest", "Prepending html options to select element" ); } ); -test( "prepend(Function) with incoming value -- Element", function() { +QUnit.test( "prepend(Function) with incoming value -- Element", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var old, expected; expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog"; old = jQuery( "#sap" ).html(); jQuery( "#sap" ).prepend( function( i, val ) { - equal( val, old, "Make sure the incoming value is correct." ); + assert.equal( val, old, "Make sure the incoming value is correct." ); return document.getElementById( "first" ); } ); - equal( jQuery( "#sap" ).text(), expected, "Check for prepending of element" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for prepending of element" ); } ); -test( "prepend(Function) with incoming value -- Array<Element>", function() { +QUnit.test( "prepend(Function) with incoming value -- Array<Element>", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var old, expected; expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog"; old = jQuery( "#sap" ).html(); jQuery( "#sap" ).prepend( function( i, val ) { - equal( val, old, "Make sure the incoming value is correct." ); + assert.equal( val, old, "Make sure the incoming value is correct." ); return [ document.getElementById( "first" ), document.getElementById( "yahoo" ) ]; } ); - equal( jQuery( "#sap" ).text(), expected, "Check for prepending of array of elements" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for prepending of array of elements" ); } ); -test( "prepend(Function) with incoming value -- jQuery", function() { +QUnit.test( "prepend(Function) with incoming value -- jQuery", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var old, expected; expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog"; old = jQuery( "#sap" ).html(); jQuery( "#sap" ).prepend( function( i, val ) { - equal( val, old, "Make sure the incoming value is correct." ); + assert.equal( val, old, "Make sure the incoming value is correct." ); return jQuery( "#yahoo, #first" ); } ); - equal( jQuery( "#sap" ).text(), expected, "Check for prepending of jQuery object" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for prepending of jQuery object" ); } ); -test( "prependTo(String)", function() { +QUnit.test( "prependTo(String)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var defaultText; defaultText = "Try them out:"; jQuery( "<b>buga</b>" ).prependTo( "#first" ); - equal( jQuery( "#first" ).text(), "buga" + defaultText, "Check if text prepending works" ); - equal( jQuery( "<option value='prependTest'>Prepend Test</option>" ).prependTo( "#select3" ).parent().find( "option:first-child" ).attr( "value" ), "prependTest", "Prepending html options to select element" ); + assert.equal( jQuery( "#first" ).text(), "buga" + defaultText, "Check if text prepending works" ); + assert.equal( jQuery( "<option value='prependTest'>Prepend Test</option>" ).prependTo( "#select3" ).parent().find( "option:first-child" ).attr( "value" ), "prependTest", "Prepending html options to select element" ); } ); -test( "prependTo(Element)", function() { +QUnit.test( "prependTo(Element)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog"; jQuery( document.getElementById( "first" ) ).prependTo( "#sap" ); - equal( jQuery( "#sap" ).text(), expected, "Check for prepending of element" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for prepending of element" ); } ); -test( "prependTo(Array<Element>)", function() { +QUnit.test( "prependTo(Array<Element>)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog"; jQuery( [ document.getElementById( "first" ), document.getElementById( "yahoo" ) ] ).prependTo( "#sap" ); - equal( jQuery( "#sap" ).text(), expected, "Check for prepending of array of elements" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for prepending of array of elements" ); } ); -test( "prependTo(jQuery)", function() { +QUnit.test( "prependTo(jQuery)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "YahooTry them out:This link has class=\"blog\": Simon Willison's Weblog"; jQuery( "#yahoo, #first" ).prependTo( "#sap" ); - equal( jQuery( "#sap" ).text(), expected, "Check for prepending of jQuery object" ); + assert.equal( jQuery( "#sap" ).text(), expected, "Check for prepending of jQuery object" ); } ); -test( "prependTo(Array<jQuery>)", function() { +QUnit.test( "prependTo(Array<jQuery>)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); jQuery( "<select id='prependSelect1'></select>" ).prependTo( "#form" ); jQuery( "<select id='prependSelect2'><option>Test</option></select>" ).prependTo( "#form" ); @@ -868,384 +868,384 @@ test( "prependTo(Array<jQuery>)", function() { t( "Prepend Select", "#prependSelect2, #prependSelect1", [ "prependSelect2", "prependSelect1" ] ); } ); -test( "before(String)", function() { +QUnit.test( "before(String)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "This is a normal link: bugaYahoo"; jQuery( "#yahoo" ).before( manipulationBareObj( "<b>buga</b>" ) ); - equal( jQuery( "#en" ).text(), expected, "Insert String before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert String before" ); } ); -test( "before(Element)", function() { +QUnit.test( "before(Element)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "This is a normal link: Try them out:Yahoo"; jQuery( "#yahoo" ).before( manipulationBareObj( document.getElementById( "first" ) ) ); - equal( jQuery( "#en" ).text(), expected, "Insert element before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert element before" ); } ); -test( "before(Array<Element>)", function() { +QUnit.test( "before(Array<Element>)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "This is a normal link: Try them out:diveintomarkYahoo"; jQuery( "#yahoo" ).before( manipulationBareObj( [ document.getElementById( "first" ), document.getElementById( "mark" ) ] ) ); - equal( jQuery( "#en" ).text(), expected, "Insert array of elements before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert array of elements before" ); } ); -test( "before(jQuery)", function() { +QUnit.test( "before(jQuery)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "This is a normal link: diveintomarkTry them out:Yahoo"; jQuery( "#yahoo" ).before( manipulationBareObj( jQuery( "#mark, #first" ) ) ); - equal( jQuery( "#en" ).text(), expected, "Insert jQuery before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert jQuery before" ); } ); -test( "before(Array<jQuery>)", function() { +QUnit.test( "before(Array<jQuery>)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "This is a normal link: Try them out:GooglediveintomarkYahoo"; jQuery( "#yahoo" ).before( manipulationBareObj( [ jQuery( "#first" ), jQuery( "#mark, #google" ) ] ) ); - equal( jQuery( "#en" ).text(), expected, "Insert array of jQuery objects before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert array of jQuery objects before" ); } ); -test( "before(Function) -- Returns String", function() { +QUnit.test( "before(Function) -- Returns String", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "This is a normal link: bugaYahoo"; jQuery( "#yahoo" ).before( manipulationFunctionReturningObj( "<b>buga</b>" ) ); - equal( jQuery( "#en" ).text(), expected, "Insert String before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert String before" ); } ); -test( "before(Function) -- Returns Element", function() { +QUnit.test( "before(Function) -- Returns Element", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "This is a normal link: Try them out:Yahoo"; jQuery( "#yahoo" ).before( manipulationFunctionReturningObj( document.getElementById( "first" ) ) ); - equal( jQuery( "#en" ).text(), expected, "Insert element before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert element before" ); } ); -test( "before(Function) -- Returns Array<Element>", function() { +QUnit.test( "before(Function) -- Returns Array<Element>", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "This is a normal link: Try them out:diveintomarkYahoo"; jQuery( "#yahoo" ).before( manipulationFunctionReturningObj( [ document.getElementById( "first" ), document.getElementById( "mark" ) ] ) ); - equal( jQuery( "#en" ).text(), expected, "Insert array of elements before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert array of elements before" ); } ); -test( "before(Function) -- Returns jQuery", function() { +QUnit.test( "before(Function) -- Returns jQuery", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "This is a normal link: diveintomarkTry them out:Yahoo"; jQuery( "#yahoo" ).before( manipulationFunctionReturningObj( jQuery( "#mark, #first" ) ) ); - equal( jQuery( "#en" ).text(), expected, "Insert jQuery before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert jQuery before" ); } ); -test( "before(Function) -- Returns Array<jQuery>", function() { +QUnit.test( "before(Function) -- Returns Array<jQuery>", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected; expected = "This is a normal link: Try them out:GooglediveintomarkYahoo"; jQuery( "#yahoo" ).before( manipulationFunctionReturningObj( [ jQuery( "#first" ), jQuery( "#mark, #google" ) ] ) ); - equal( jQuery( "#en" ).text(), expected, "Insert array of jQuery objects before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert array of jQuery objects before" ); } ); -test( "before(no-op)", function() { +QUnit.test( "before(no-op)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var set; set = jQuery( "<div/>" ).before( "<span>test</span>" ); - equal( set[ 0 ].nodeName.toLowerCase(), "div", "Insert before a disconnected node should be a no-op" ); - equal( set.length, 1, "Insert the element before the disconnected node. should be a no-op" ); + assert.equal( set[ 0 ].nodeName.toLowerCase(), "div", "Insert before a disconnected node should be a no-op" ); + assert.equal( set.length, 1, "Insert the element before the disconnected node. should be a no-op" ); } ); -test( "before and after w/ empty object (#10812)", function() { +QUnit.test( "before and after w/ empty object (#10812)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var res; res = jQuery( "#notInTheDocument" ).before( "(" ).after( ")" ); - equal( res.length, 0, "didn't choke on empty object" ); + assert.equal( res.length, 0, "didn't choke on empty object" ); } ); -test( ".before() and .after() disconnected node", function() { +QUnit.test( ".before() and .after() disconnected node", function( assert ) { - expect( 2 ); + assert.expect( 2 ); - equal( jQuery( "<input type='checkbox'/>" ).before( "<div/>" ).length, 1, "before() on disconnected node is no-op" ); - equal( jQuery( "<input type='checkbox'/>" ).after( "<div/>" ).length, 1, "after() on disconnected node is no-op" ); + assert.equal( jQuery( "<input type='checkbox'/>" ).before( "<div/>" ).length, 1, "before() on disconnected node is no-op" ); + assert.equal( jQuery( "<input type='checkbox'/>" ).after( "<div/>" ).length, 1, "after() on disconnected node is no-op" ); } ); -test( "insert with .before() on disconnected node last", function() { +QUnit.test( "insert with .before() on disconnected node last", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expectedBefore = "This is a normal link: bugaYahoo"; jQuery( "#yahoo" ).add( "<span/>" ).before( "<b>buga</b>" ); - equal( jQuery( "#en" ).text(), expectedBefore, "Insert String before with disconnected node last" ); + assert.equal( jQuery( "#en" ).text(), expectedBefore, "Insert String before with disconnected node last" ); } ); -test( "insert with .before() on disconnected node first", function() { +QUnit.test( "insert with .before() on disconnected node first", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expectedBefore = "This is a normal link: bugaYahoo"; jQuery( "<span/>" ).add( "#yahoo" ).before( "<b>buga</b>" ); - equal( jQuery( "#en" ).text(), expectedBefore, "Insert String before with disconnected node first" ); + assert.equal( jQuery( "#en" ).text(), expectedBefore, "Insert String before with disconnected node first" ); } ); -test( "insert with .before() on disconnected node last", function() { +QUnit.test( "insert with .before() on disconnected node last", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expectedAfter = "This is a normal link: Yahoobuga"; jQuery( "#yahoo" ).add( "<span/>" ).after( "<b>buga</b>" ); - equal( jQuery( "#en" ).text(), expectedAfter, "Insert String after with disconnected node last" ); + assert.equal( jQuery( "#en" ).text(), expectedAfter, "Insert String after with disconnected node last" ); } ); -test( "insert with .before() on disconnected node last", function() { +QUnit.test( "insert with .before() on disconnected node last", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expectedAfter = "This is a normal link: Yahoobuga"; jQuery( "<span/>" ).add( "#yahoo" ).after( "<b>buga</b>" ); - equal( jQuery( "#en" ).text(), expectedAfter, "Insert String after with disconnected node first" ); + assert.equal( jQuery( "#en" ).text(), expectedAfter, "Insert String after with disconnected node first" ); } ); -test( "insertBefore(String)", function() { +QUnit.test( "insertBefore(String)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: bugaYahoo"; jQuery( "<b>buga</b>" ).insertBefore( "#yahoo" ); - equal( jQuery( "#en" ).text(), expected, "Insert String before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert String before" ); } ); -test( "insertBefore(Element)", function() { +QUnit.test( "insertBefore(Element)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: Try them out:Yahoo"; jQuery( document.getElementById( "first" ) ).insertBefore( "#yahoo" ); - equal( jQuery( "#en" ).text(), expected, "Insert element before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert element before" ); } ); -test( "insertBefore(Array<Element>)", function() { +QUnit.test( "insertBefore(Array<Element>)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: Try them out:diveintomarkYahoo"; jQuery( [ document.getElementById( "first" ), document.getElementById( "mark" ) ] ).insertBefore( "#yahoo" ); - equal( jQuery( "#en" ).text(), expected, "Insert array of elements before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert array of elements before" ); } ); -test( "insertBefore(jQuery)", function() { +QUnit.test( "insertBefore(jQuery)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: diveintomarkTry them out:Yahoo"; jQuery( "#mark, #first" ).insertBefore( "#yahoo" ); - equal( jQuery( "#en" ).text(), expected, "Insert jQuery before" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert jQuery before" ); } ); -test( ".after(String)", function() { +QUnit.test( ".after(String)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: Yahoobuga"; jQuery( "#yahoo" ).after( "<b>buga</b>" ); - equal( jQuery( "#en" ).text(), expected, "Insert String after" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert String after" ); } ); -test( ".after(Element)", function() { +QUnit.test( ".after(Element)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: YahooTry them out:"; jQuery( "#yahoo" ).after( document.getElementById( "first" ) ); - equal( jQuery( "#en" ).text(), expected, "Insert element after" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert element after" ); } ); -test( ".after(Array<Element>)", function() { +QUnit.test( ".after(Array<Element>)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: YahooTry them out:diveintomark"; jQuery( "#yahoo" ).after( [ document.getElementById( "first" ), document.getElementById( "mark" ) ] ); - equal( jQuery( "#en" ).text(), expected, "Insert array of elements after" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert array of elements after" ); } ); -test( ".after(jQuery)", function() { +QUnit.test( ".after(jQuery)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: YahooTry them out:Googlediveintomark"; jQuery( "#yahoo" ).after( [ jQuery( "#first" ), jQuery( "#mark, #google" ) ] ); - equal( jQuery( "#en" ).text(), expected, "Insert array of jQuery objects after" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert array of jQuery objects after" ); } ); -test( ".after(Function) returns String", function() { +QUnit.test( ".after(Function) returns String", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: Yahoobuga", val = manipulationFunctionReturningObj; jQuery( "#yahoo" ).after( val( "<b>buga</b>" ) ); - equal( jQuery( "#en" ).text(), expected, "Insert String after" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert String after" ); } ); -test( ".after(Function) returns Element", function() { +QUnit.test( ".after(Function) returns Element", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: YahooTry them out:", val = manipulationFunctionReturningObj; jQuery( "#yahoo" ).after( val( document.getElementById( "first" ) ) ); - equal( jQuery( "#en" ).text(), expected, "Insert element after" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert element after" ); } ); -test( ".after(Function) returns Array<Element>", function() { +QUnit.test( ".after(Function) returns Array<Element>", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: YahooTry them out:diveintomark", val = manipulationFunctionReturningObj; jQuery( "#yahoo" ).after( val( [ document.getElementById( "first" ), document.getElementById( "mark" ) ] ) ); - equal( jQuery( "#en" ).text(), expected, "Insert array of elements after" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert array of elements after" ); } ); -test( ".after(Function) returns jQuery", function() { +QUnit.test( ".after(Function) returns jQuery", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: YahooTry them out:Googlediveintomark", val = manipulationFunctionReturningObj; jQuery( "#yahoo" ).after( val( [ jQuery( "#first" ), jQuery( "#mark, #google" ) ] ) ); - equal( jQuery( "#en" ).text(), expected, "Insert array of jQuery objects after" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert array of jQuery objects after" ); } ); -test( ".after(disconnected node)", function() { +QUnit.test( ".after(disconnected node)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var set = jQuery( "<div/>" ).before( "<span>test</span>" ); - equal( set[ 0 ].nodeName.toLowerCase(), "div", "Insert after a disconnected node should be a no-op" ); - equal( set.length, 1, "Insert the element after the disconnected node should be a no-op" ); + assert.equal( set[ 0 ].nodeName.toLowerCase(), "div", "Insert after a disconnected node should be a no-op" ); + assert.equal( set.length, 1, "Insert the element after the disconnected node should be a no-op" ); } ); -test( "insertAfter(String)", function() { +QUnit.test( "insertAfter(String)", function( assert ) { - expect( 1 ) ; + assert.expect( 1 ) ; var expected = "This is a normal link: Yahoobuga"; jQuery( "<b>buga</b>" ).insertAfter( "#yahoo" ); - equal( jQuery( "#en" ).text(), expected, "Insert String after" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert String after" ); } ); -test( "insertAfter(Element)", function() { +QUnit.test( "insertAfter(Element)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: YahooTry them out:"; jQuery( document.getElementById( "first" ) ).insertAfter( "#yahoo" ); - equal( jQuery( "#en" ).text(), expected, "Insert element after" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert element after" ); } ); -test( "insertAfter(Array<Element>)", function() { +QUnit.test( "insertAfter(Array<Element>)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: YahooTry them out:diveintomark"; jQuery( [ document.getElementById( "first" ), document.getElementById( "mark" ) ] ).insertAfter( "#yahoo" ); - equal( jQuery( "#en" ).text(), expected, "Insert array of elements after" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert array of elements after" ); } ); -test( "insertAfter(jQuery)", function() { +QUnit.test( "insertAfter(jQuery)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var expected = "This is a normal link: YahoodiveintomarkTry them out:"; jQuery( "#mark, #first" ).insertAfter( "#yahoo" ); - equal( jQuery( "#en" ).text(), expected, "Insert jQuery after" ); + assert.equal( jQuery( "#en" ).text(), expected, "Insert jQuery after" ); } ); -function testReplaceWith( val ) { +function testReplaceWith( val, assert ) { var tmp, y, child, child2, set, non_existent, $div, expected = 29; - expect( expected ); + assert.expect( expected ); jQuery( "#yahoo" ).replaceWith( val( "<b id='replace'>buga</b>" ) ); - ok( jQuery( "#replace" )[ 0 ], "Replace element with element from string" ); - ok( !jQuery( "#yahoo" )[ 0 ], "Verify that original element is gone, after string" ); + assert.ok( jQuery( "#replace" )[ 0 ], "Replace element with element from string" ); + assert.ok( !jQuery( "#yahoo" )[ 0 ], "Verify that original element is gone, after string" ); jQuery( "#anchor2" ).replaceWith( val( document.getElementById( "first" ) ) ); - ok( jQuery( "#first" )[ 0 ], "Replace element with element" ); - ok( !jQuery( "#anchor2" )[ 0 ], "Verify that original element is gone, after element" ); + assert.ok( jQuery( "#first" )[ 0 ], "Replace element with element" ); + assert.ok( !jQuery( "#anchor2" )[ 0 ], "Verify that original element is gone, after element" ); jQuery( "#qunit-fixture" ).append( "<div id='bar'><div id='baz'></div></div>" ); jQuery( "#baz" ).replaceWith( val( "Baz" ) ); - equal( jQuery( "#bar" ).text(), "Baz", "Replace element with text" ); - ok( !jQuery( "#baz" )[ 0 ], "Verify that original element is gone, after element" ); + assert.equal( jQuery( "#bar" ).text(), "Baz", "Replace element with text" ); + assert.ok( !jQuery( "#baz" )[ 0 ], "Verify that original element is gone, after element" ); jQuery( "#bar" ).replaceWith( "<div id='yahoo'></div>", "...", "<div id='baz'></div>" ); - deepEqual( jQuery( "#yahoo, #baz" ).get(), q( "yahoo", "baz" ), "Replace element with multiple arguments (#13722)" ); - strictEqual( jQuery( "#yahoo" )[ 0 ].nextSibling, jQuery( "#baz" )[ 0 ].previousSibling, "Argument order preserved" ); - deepEqual( jQuery( "#bar" ).get(), [], "Verify that original element is gone, after multiple arguments" ); + assert.deepEqual( jQuery( "#yahoo, #baz" ).get(), q( "yahoo", "baz" ), "Replace element with multiple arguments (#13722)" ); + assert.strictEqual( jQuery( "#yahoo" )[ 0 ].nextSibling, jQuery( "#baz" )[ 0 ].previousSibling, "Argument order preserved" ); + assert.deepEqual( jQuery( "#bar" ).get(), [], "Verify that original element is gone, after multiple arguments" ); jQuery( "#google" ).replaceWith( val( [ document.getElementById( "first" ), document.getElementById( "mark" ) ] ) ); - deepEqual( jQuery( "#mark, #first" ).get(), q( "first", "mark" ), "Replace element with array of elements" ); - ok( !jQuery( "#google" )[ 0 ], "Verify that original element is gone, after array of elements" ); + assert.deepEqual( jQuery( "#mark, #first" ).get(), q( "first", "mark" ), "Replace element with array of elements" ); + assert.ok( !jQuery( "#google" )[ 0 ], "Verify that original element is gone, after array of elements" ); jQuery( "#groups" ).replaceWith( val( jQuery( "#mark, #first" ) ) ); - deepEqual( jQuery( "#mark, #first" ).get(), q( "first", "mark" ), "Replace element with jQuery collection" ); - ok( !jQuery( "#groups" )[ 0 ], "Verify that original element is gone, after jQuery collection" ); + assert.deepEqual( jQuery( "#mark, #first" ).get(), q( "first", "mark" ), "Replace element with jQuery collection" ); + assert.ok( !jQuery( "#groups" )[ 0 ], "Verify that original element is gone, after jQuery collection" ); jQuery( "#mark, #first" ).replaceWith( val( "<span class='replacement'></span><span class='replacement'></span>" ) ); - equal( jQuery( "#qunit-fixture .replacement" ).length, 4, "Replace multiple elements (#12449)" ); - deepEqual( jQuery( "#mark, #first" ).get(), [], "Verify that original elements are gone, after replace multiple" ); + assert.equal( jQuery( "#qunit-fixture .replacement" ).length, 4, "Replace multiple elements (#12449)" ); + assert.deepEqual( jQuery( "#mark, #first" ).get(), [], "Verify that original elements are gone, after replace multiple" ); tmp = jQuery( "<b>content</b>" )[ 0 ]; jQuery( "#anchor1" ).contents().replaceWith( val( tmp ) ); - deepEqual( jQuery( "#anchor1" ).contents().get(), [ tmp ], "Replace text node with element" ); + assert.deepEqual( jQuery( "#anchor1" ).contents().get(), [ tmp ], "Replace text node with element" ); tmp = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ).on( "click", function() { - ok( true, "Newly bound click run." ); + assert.ok( true, "Newly bound click run." ); } ); y = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ).on( "click", function() { - ok( false, "Previously bound click run." ); + assert.ok( false, "Previously bound click run." ); } ); child = y.append( "<b>test</b>" ).find( "b" ).on( "click", function() { - ok( true, "Child bound click run." ); + assert.ok( true, "Child bound click run." ); return false; } ); @@ -1256,10 +1256,10 @@ function testReplaceWith( val ) { child.trigger( "click" ); // Shouldn't be run y = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ).on( "click", function() { - ok( false, "Previously bound click run." ); + assert.ok( false, "Previously bound click run." ); } ); child2 = y.append( "<u>test</u>" ).find( "u" ).on( "click", function() { - ok( true, "Child 2 bound click run." ); + assert.ok( true, "Child 2 bound click run." ); return false; } ); @@ -1268,23 +1268,23 @@ function testReplaceWith( val ) { child2.trigger( "click" ); set = jQuery( "<div/>" ).replaceWith( val( "<span>test</span>" ) ); - equal( set[ 0 ].nodeName.toLowerCase(), "div", "No effect on a disconnected node." ); - equal( set.length, 1, "No effect on a disconnected node." ); - equal( set[ 0 ].childNodes.length, 0, "No effect on a disconnected node." ); + assert.equal( set[ 0 ].nodeName.toLowerCase(), "div", "No effect on a disconnected node." ); + assert.equal( set.length, 1, "No effect on a disconnected node." ); + assert.equal( set[ 0 ].childNodes.length, 0, "No effect on a disconnected node." ); child = jQuery( "#qunit-fixture" ).children().first(); $div = jQuery( "<div class='pathological'/>" ).insertBefore( child ); $div.replaceWith( $div ); - deepEqual( jQuery( ".pathological", "#qunit-fixture" ).get(), $div.get(), + assert.deepEqual( jQuery( ".pathological", "#qunit-fixture" ).get(), $div.get(), "Self-replacement" ); $div.replaceWith( child ); - deepEqual( jQuery( "#qunit-fixture" ).children().first().get(), child.get(), + assert.deepEqual( jQuery( "#qunit-fixture" ).children().first().get(), child.get(), "Replacement with following sibling (#13810)" ); - deepEqual( jQuery( ".pathological", "#qunit-fixture" ).get(), [], + assert.deepEqual( jQuery( ".pathological", "#qunit-fixture" ).get(), [], "Replacement with following sibling (context removed)" ); non_existent = jQuery( "#does-not-exist" ).replaceWith( val( "<b>should not throw an error</b>" ) ); - equal( non_existent.length, 0, "Length of non existent element." ); + assert.equal( non_existent.length, 0, "Length of non existent element." ); $div = jQuery( "<div class='replacewith'></div>" ).appendTo( "#qunit-fixture" ); $div.replaceWith( val( "<div class='replacewith'></div><script>" + @@ -1292,43 +1292,43 @@ function testReplaceWith( val ) { "</script>" ) ); jQuery( "#qunit-fixture" ).append( "<div id='replaceWith'></div>" ); - equal( jQuery( "#qunit-fixture" ).find( "div[id=replaceWith]" ).length, 1, "Make sure only one div exists." ); + assert.equal( jQuery( "#qunit-fixture" ).find( "div[id=replaceWith]" ).length, 1, "Make sure only one div exists." ); jQuery( "#replaceWith" ).replaceWith( val( "<div id='replaceWith'></div>" ) ); - equal( jQuery( "#qunit-fixture" ).find( "div[id=replaceWith]" ).length, 1, "Make sure only one div exists after replacement." ); + assert.equal( jQuery( "#qunit-fixture" ).find( "div[id=replaceWith]" ).length, 1, "Make sure only one div exists after replacement." ); jQuery( "#replaceWith" ).replaceWith( val( "<div id='replaceWith'></div>" ) ); - equal( jQuery( "#qunit-fixture" ).find( "div[id=replaceWith]" ).length, 1, "Make sure only one div exists after subsequent replacement." ); + assert.equal( jQuery( "#qunit-fixture" ).find( "div[id=replaceWith]" ).length, 1, "Make sure only one div exists after subsequent replacement." ); return expected; } -test( "replaceWith(String|Element|Array<Element>|jQuery)", function() { - testReplaceWith( manipulationBareObj ); +QUnit.test( "replaceWith(String|Element|Array<Element>|jQuery)", function( assert ) { + testReplaceWith( manipulationBareObj, assert ); } ); -test( "replaceWith(Function)", function() { - expect( testReplaceWith( manipulationFunctionReturningObj ) + 1 ); +QUnit.test( "replaceWith(Function)", function( assert ) { + assert.expect( testReplaceWith( manipulationFunctionReturningObj, assert ) + 1 ); var y = jQuery( "#foo" )[ 0 ]; jQuery( y ).replaceWith( function() { - equal( this, y, "Make sure the context is coming in correctly." ); + assert.equal( this, y, "Make sure the context is coming in correctly." ); } ); } ); -test( "replaceWith(string) for more than one element", function() { +QUnit.test( "replaceWith(string) for more than one element", function( assert ) { - expect( 3 ); + assert.expect( 3 ); - equal( jQuery( "#foo p" ).length, 3, "ensuring that test data has not changed" ); + assert.equal( jQuery( "#foo p" ).length, 3, "ensuring that test data has not changed" ); jQuery( "#foo p" ).replaceWith( "<span>bar</span>" ); - equal( jQuery( "#foo span" ).length, 3, "verify that all the three original element have been replaced" ); - equal( jQuery( "#foo p" ).length, 0, "verify that all the three original element have been replaced" ); + assert.equal( jQuery( "#foo span" ).length, 3, "verify that all the three original element have been replaced" ); + assert.equal( jQuery( "#foo p" ).length, 0, "verify that all the three original element have been replaced" ); } ); -test( "Empty replaceWith (trac-13401; trac-13596; gh-2204)", function() { +QUnit.test( "Empty replaceWith (trac-13401; trac-13596; gh-2204)", function( assert ) { - expect( 25 ); + assert.expect( 25 ); var $el = jQuery( "<div/><div/>" ).html( "<p>0</p>" ), expectedHTML = $el.html(), @@ -1344,126 +1344,126 @@ test( "Empty replaceWith (trac-13401; trac-13596; gh-2204)", function() { jQuery.each( tests, function( label, input ) { $el.html( "<a/>" ).children().replaceWith( input ); - strictEqual( $el.html(), "", "replaceWith(" + label + ")" ); + assert.strictEqual( $el.html(), "", "replaceWith(" + label + ")" ); $el.html( "<b/>" ).children().replaceWith( function() { return input; } ); - strictEqual( $el.html(), "", "replaceWith(function returning " + label + ")" ); + assert.strictEqual( $el.html(), "", "replaceWith(function returning " + label + ")" ); $el.html( "<i/>" ).children().replaceWith( function( i ) { i; return input; } ); - strictEqual( $el.html(), "", "replaceWith(other function returning " + label + ")" ); + assert.strictEqual( $el.html(), "", "replaceWith(other function returning " + label + ")" ); $el.html( "<p/>" ).children().replaceWith( function( i ) { return i ? input : jQuery( this ).html( i + "" ); } ); - strictEqual( $el.eq( 0 ).html(), expectedHTML, + assert.strictEqual( $el.eq( 0 ).html(), expectedHTML, "replaceWith(function conditionally returning context)" ); - strictEqual( $el.eq( 1 ).html(), "", + assert.strictEqual( $el.eq( 1 ).html(), "", "replaceWith(function conditionally returning " + label + ")" ); } ); } ); -test( "replaceAll(String)", function() { +QUnit.test( "replaceAll(String)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); jQuery( "<b id='replace'>buga</b>" ).replaceAll( "#yahoo" ); - ok( jQuery( "#replace" )[ 0 ], "Replace element with string" ); - ok( !jQuery( "#yahoo" )[ 0 ], "Verify that original element is gone, after string" ); + assert.ok( jQuery( "#replace" )[ 0 ], "Replace element with string" ); + assert.ok( !jQuery( "#yahoo" )[ 0 ], "Verify that original element is gone, after string" ); } ); -test( "replaceAll(Element)", function() { +QUnit.test( "replaceAll(Element)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); jQuery( document.getElementById( "first" ) ).replaceAll( "#yahoo" ); - ok( jQuery( "#first" )[ 0 ], "Replace element with element" ); - ok( !jQuery( "#yahoo" )[ 0 ], "Verify that original element is gone, after element" ); + assert.ok( jQuery( "#first" )[ 0 ], "Replace element with element" ); + assert.ok( !jQuery( "#yahoo" )[ 0 ], "Verify that original element is gone, after element" ); } ); -test( "replaceAll(Array<Element>)", function() { +QUnit.test( "replaceAll(Array<Element>)", function( assert ) { - expect( 3 ); + assert.expect( 3 ); jQuery( [ document.getElementById( "first" ), document.getElementById( "mark" ) ] ).replaceAll( "#yahoo" ); - ok( jQuery( "#first" )[ 0 ], "Replace element with array of elements" ); - ok( jQuery( "#mark" )[ 0 ], "Replace element with array of elements" ); - ok( !jQuery( "#yahoo" )[ 0 ], "Verify that original element is gone, after array of elements" ); + assert.ok( jQuery( "#first" )[ 0 ], "Replace element with array of elements" ); + assert.ok( jQuery( "#mark" )[ 0 ], "Replace element with array of elements" ); + assert.ok( !jQuery( "#yahoo" )[ 0 ], "Verify that original element is gone, after array of elements" ); } ); -test( "replaceAll(jQuery)", function() { +QUnit.test( "replaceAll(jQuery)", function( assert ) { - expect( 3 ); + assert.expect( 3 ); jQuery( "#mark, #first" ).replaceAll( "#yahoo" ); - ok( jQuery( "#first" )[ 0 ], "Replace element with set of elements" ); - ok( jQuery( "#mark" )[ 0 ], "Replace element with set of elements" ); - ok( !jQuery( "#yahoo" )[ 0 ], "Verify that original element is gone, after set of elements" ); + assert.ok( jQuery( "#first" )[ 0 ], "Replace element with set of elements" ); + assert.ok( jQuery( "#mark" )[ 0 ], "Replace element with set of elements" ); + assert.ok( !jQuery( "#yahoo" )[ 0 ], "Verify that original element is gone, after set of elements" ); } ); -test( "jQuery.clone() (#8017)", function() { +QUnit.test( "jQuery.clone() (#8017)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); - ok( jQuery.clone && jQuery.isFunction( jQuery.clone ), "jQuery.clone() utility exists and is a function." ); + assert.ok( jQuery.clone && jQuery.isFunction( jQuery.clone ), "jQuery.clone() utility exists and is a function." ); var main = jQuery( "#qunit-fixture" )[ 0 ], clone = jQuery.clone( main ); - equal( main.childNodes.length, clone.childNodes.length, "Simple child length to ensure a large dom tree copies correctly" ); + assert.equal( main.childNodes.length, clone.childNodes.length, "Simple child length to ensure a large dom tree copies correctly" ); } ); -test( "append to multiple elements (#8070)", function() { +QUnit.test( "append to multiple elements (#8070)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var selects = jQuery( "<select class='test8070'></select><select class='test8070'></select>" ).appendTo( "#qunit-fixture" ); selects.append( "<OPTION>1</OPTION><OPTION>2</OPTION>" ); - equal( selects[ 0 ].childNodes.length, 2, "First select got two nodes" ); - equal( selects[ 1 ].childNodes.length, 2, "Second select got two nodes" ); + assert.equal( selects[ 0 ].childNodes.length, 2, "First select got two nodes" ); + assert.equal( selects[ 1 ].childNodes.length, 2, "Second select got two nodes" ); } ); -test( "table manipulation", function() { - expect( 2 ); +QUnit.test( "table manipulation", function( assert ) { + assert.expect( 2 ); var table = jQuery( "<table style='font-size:16px'></table>" ).appendTo( "#qunit-fixture" ).empty(), height = table[ 0 ].offsetHeight; table.append( "<tr><td>DATA</td></tr>" ); - ok( table[ 0 ].offsetHeight - height >= 15, "appended rows are visible" ); + assert.ok( table[ 0 ].offsetHeight - height >= 15, "appended rows are visible" ); table.empty(); height = table[ 0 ].offsetHeight; table.prepend( "<tr><td>DATA</td></tr>" ); - ok( table[ 0 ].offsetHeight - height >= 15, "prepended rows are visible" ); + assert.ok( table[ 0 ].offsetHeight - height >= 15, "prepended rows are visible" ); } ); -test( "clone()", function() { +QUnit.test( "clone()", function( assert ) { - expect( 45 ); + assert.expect( 45 ); var div, clone, form, body; - equal( jQuery( "#en" ).text(), "This is a normal link: Yahoo", "Assert text for #en" ); - equal( jQuery( "#first" ).append( jQuery( "#yahoo" ).clone() ).text(), "Try them out:Yahoo", "Check for clone" ); - equal( jQuery( "#en" ).text(), "This is a normal link: Yahoo", "Reassert text for #en" ); + assert.equal( jQuery( "#en" ).text(), "This is a normal link: Yahoo", "Assert text for #en" ); + assert.equal( jQuery( "#first" ).append( jQuery( "#yahoo" ).clone() ).text(), "Try them out:Yahoo", "Check for clone" ); + assert.equal( jQuery( "#en" ).text(), "This is a normal link: Yahoo", "Reassert text for #en" ); jQuery.each( "table thead tbody tfoot tr td div button ul ol li select option textarea iframe".split( " " ), function( i, nodeName ) { - equal( jQuery( "<" + nodeName + "/>" ).clone()[ 0 ].nodeName.toLowerCase(), nodeName, "Clone a " + nodeName ); + assert.equal( jQuery( "<" + nodeName + "/>" ).clone()[ 0 ].nodeName.toLowerCase(), nodeName, "Clone a " + nodeName ); } ); - equal( jQuery( "<input type='checkbox' />" ).clone()[ 0 ].nodeName.toLowerCase(), "input", "Clone a <input type='checkbox' />" ); + assert.equal( jQuery( "<input type='checkbox' />" ).clone()[ 0 ].nodeName.toLowerCase(), "input", "Clone a <input type='checkbox' />" ); // Check cloning non-elements - equal( jQuery( "#nonnodes" ).contents().clone().length, 3, "Check node,textnode,comment clone works (some browsers delete comments on clone)" ); + assert.equal( jQuery( "#nonnodes" ).contents().clone().length, 3, "Check node,textnode,comment clone works (some browsers delete comments on clone)" ); // Verify that clones of clones can keep event listeners div = jQuery( "<div><ul><li>test</li></ul></div>" ).on( "click", function() { - ok( true, "Bound event still exists." ); + assert.ok( true, "Bound event still exists." ); } ); clone = div.clone( true ); div.remove(); div = clone.clone( true ); clone.remove(); - equal( div.length, 1, "One element cloned" ); - equal( div[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" ); + assert.equal( div.length, 1, "One element cloned" ); + assert.equal( div[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" ); div.trigger( "click" ); // Manually clean up detached elements @@ -1472,12 +1472,12 @@ test( "clone()", function() { // Verify that cloned children can keep event listeners div = jQuery( "<div/>" ).append( [ document.createElement( "table" ), document.createElement( "table" ) ] ); div.find( "table" ).on( "click", function() { - ok( true, "Bound event still exists." ); + assert.ok( true, "Bound event still exists." ); } ); clone = div.clone( true ); - equal( clone.length, 1, "One element cloned" ); - equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" ); + assert.equal( clone.length, 1, "One element cloned" ); + assert.equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" ); clone.find( "table" ).trigger( "click" ); // Manually clean up detached elements @@ -1486,7 +1486,7 @@ test( "clone()", function() { // Make sure that doing .clone() doesn't clone event listeners div = jQuery( "<div><ul><li>test</li></ul></div>" ).on( "click", function() { - ok( false, "Bound event still exists after .clone()." ); + assert.ok( false, "Bound event still exists after .clone()." ); } ); clone = div.clone(); @@ -1500,9 +1500,9 @@ test( "clone()", function() { div = jQuery( "<div/>" ).html( "<embed height='355' width='425' src='http://www.youtube.com/v/3KANI2dpXLw&hl=en'></embed>" ); clone = div.clone( true ); - equal( clone.length, 1, "One element cloned" ); - equal( clone.html(), div.html(), "Element contents cloned" ); - equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" ); + assert.equal( clone.length, 1, "One element cloned" ); + assert.equal( clone.html(), div.html(), "Element contents cloned" ); + assert.equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" ); // this is technically an invalid object, but because of the special // classid instantiation it is the only kind that IE has trouble with, @@ -1510,14 +1510,14 @@ test( "clone()", function() { div = jQuery( "<div/>" ).html( "<object height='355' width='425' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'> <param name='movie' value='http://www.youtube.com/v/3KANI2dpXLw&hl=en'> <param name='wmode' value='transparent'> </object>" ); clone = div.clone( true ); - equal( clone.length, 1, "One element cloned" ); - equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" ); + assert.equal( clone.length, 1, "One element cloned" ); + assert.equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" ); div = div.find( "object" ); clone = clone.find( "object" ); // oldIE adds extra attributes and <param> elements, so just test for existence of the defined set jQuery.each( [ "height", "width", "classid" ], function( i, attr ) { - equal( clone.attr( attr ), div.attr( attr ), "<object> attribute cloned: " + attr ); + assert.equal( clone.attr( attr ), div.attr( attr ), "<object> attribute cloned: " + attr ); } ); ( function() { var params = {}; @@ -1529,7 +1529,7 @@ test( "clone()", function() { div.find( "param" ).each( function( index, param ) { var key = param.attributes.name.nodeValue.toLowerCase(); - equal( params[ key ], param.attributes.value.nodeValue.toLowerCase(), "<param> cloned: " + key ); + assert.equal( params[ key ], param.attributes.value.nodeValue.toLowerCase(), "<param> cloned: " + key ); } ); } )(); @@ -1537,16 +1537,16 @@ test( "clone()", function() { div = jQuery( "<div/>" ).html( "<object height='355' width='425' type='application/x-shockwave-flash' data='http://www.youtube.com/v/3KANI2dpXLw&hl=en'> <param name='movie' value='http://www.youtube.com/v/3KANI2dpXLw&hl=en'> <param name='wmode' value='transparent'> </object>" ); clone = div.clone( true ); - equal( clone.length, 1, "One element cloned" ); - equal( clone.html(), div.html(), "Element contents cloned" ); - equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" ); + assert.equal( clone.length, 1, "One element cloned" ); + assert.equal( clone.html(), div.html(), "Element contents cloned" ); + assert.equal( clone[ 0 ].nodeName.toUpperCase(), "DIV", "DIV element cloned" ); div = jQuery( "<div/>" ).data( { "a": true } ); clone = div.clone( true ); - equal( clone.data( "a" ), true, "Data cloned." ); + assert.equal( clone.data( "a" ), true, "Data cloned." ); clone.data( "a", false ); - equal( clone.data( "a" ), false, "Ensure cloned element data object was correctly modified" ); - equal( div.data( "a" ), true, "Ensure cloned element data object is copied, not referenced" ); + assert.equal( clone.data( "a" ), false, "Ensure cloned element data object was correctly modified" ); + assert.equal( div.data( "a" ), true, "Ensure cloned element data object is copied, not referenced" ); // manually clean up detached elements div.remove(); @@ -1559,64 +1559,64 @@ test( "clone()", function() { div.appendChild( document.createTextNode( "test" ) ); form.appendChild( div ); - equal( jQuery( form ).clone().children().length, 1, "Make sure we just get the form back." ); + assert.equal( jQuery( form ).clone().children().length, 1, "Make sure we just get the form back." ); body = jQuery( "body" ).clone(); - equal( body.children()[ 0 ].id, "qunit", "Make sure cloning body works" ); + assert.equal( body.children()[ 0 ].id, "qunit", "Make sure cloning body works" ); body.remove(); } ); -test( "clone(script type=non-javascript) (#11359)", function() { +QUnit.test( "clone(script type=non-javascript) (#11359)", function( assert ) { - expect( 3 ); + assert.expect( 3 ); var src = jQuery( "<script type='text/filler'>Lorem ipsum dolor sit amet</script><q><script type='text/filler'>consectetur adipiscing elit</script></q>" ), dest = src.clone(); - equal( dest[ 0 ].text, "Lorem ipsum dolor sit amet", "Cloning preserves script text" ); - equal( dest.last().html(), src.last().html(), "Cloning preserves nested script text" ); - ok( /^\s*<scr.pt\s+type=['"]?text\/filler['"]?\s*>consectetur adipiscing elit<\/scr.pt>\s*$/i.test( dest.last().html() ), "Cloning preserves nested script text" ); + assert.equal( dest[ 0 ].text, "Lorem ipsum dolor sit amet", "Cloning preserves script text" ); + assert.equal( dest.last().html(), src.last().html(), "Cloning preserves nested script text" ); + assert.ok( /^\s*<scr.pt\s+type=['"]?text\/filler['"]?\s*>consectetur adipiscing elit<\/scr.pt>\s*$/i.test( dest.last().html() ), "Cloning preserves nested script text" ); dest.remove(); } ); -test( "clone(form element) (Bug #3879, #6655)", function() { +QUnit.test( "clone(form element) (Bug #3879, #6655)", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var clone, element; element = jQuery( "<select><option>Foo</option><option value='selected' selected>Bar</option></select>" ); - equal( element.clone().find( "option" ).filter( function() { return this.selected; } ).val(), "selected", "Selected option cloned correctly" ); + assert.equal( element.clone().find( "option" ).filter( function() { return this.selected; } ).val(), "selected", "Selected option cloned correctly" ); element = jQuery( "<input type='checkbox' value='foo'>" ).attr( "checked", "checked" ); clone = element.clone(); - equal( clone.is( ":checked" ), element.is( ":checked" ), "Checked input cloned correctly" ); - equal( clone[ 0 ].defaultValue, "foo", "Checked input defaultValue cloned correctly" ); + assert.equal( clone.is( ":checked" ), element.is( ":checked" ), "Checked input cloned correctly" ); + assert.equal( clone[ 0 ].defaultValue, "foo", "Checked input defaultValue cloned correctly" ); element = jQuery( "<input type='text' value='foo'>" ); clone = element.clone(); - equal( clone[ 0 ].defaultValue, "foo", "Text input defaultValue cloned correctly" ); + assert.equal( clone[ 0 ].defaultValue, "foo", "Text input defaultValue cloned correctly" ); element = jQuery( "<textarea>foo</textarea>" ); clone = element.clone(); - equal( clone[ 0 ].defaultValue, "foo", "Textarea defaultValue cloned correctly" ); + assert.equal( clone[ 0 ].defaultValue, "foo", "Textarea defaultValue cloned correctly" ); } ); -test( "clone(multiple selected options) (Bug #8129)", function() { +QUnit.test( "clone(multiple selected options) (Bug #8129)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var element = jQuery( "<select><option>Foo</option><option selected>Bar</option><option selected>Baz</option></select>" ); - equal( element.clone().find( "option:selected" ).length, element.find( "option:selected" ).length, "Multiple selected options cloned correctly" ); + assert.equal( element.clone().find( "option:selected" ).length, element.find( "option:selected" ).length, "Multiple selected options cloned correctly" ); } ); -test( "clone() on XML nodes", function() { +QUnit.test( "clone() on XML nodes", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var xml = createDashboardXML(), root = jQuery( xml.documentElement ).clone(), @@ -1625,33 +1625,33 @@ test( "clone() on XML nodes", function() { origTab.text( "origval" ); cloneTab.text( "cloneval" ); - equal( origTab.text(), "origval", "Check original XML node was correctly set" ); - equal( cloneTab.text(), "cloneval", "Check cloned XML node was correctly set" ); + assert.equal( origTab.text(), "origval", "Check original XML node was correctly set" ); + assert.equal( cloneTab.text(), "cloneval", "Check cloned XML node was correctly set" ); } ); -test( "clone() on local XML nodes with html5 nodename", function() { +QUnit.test( "clone() on local XML nodes with html5 nodename", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var $xmlDoc = jQuery( jQuery.parseXML( "<root><meter /></root>" ) ), $meter = $xmlDoc.find( "meter" ).clone(); - equal( $meter[ 0 ].nodeName, "meter", "Check if nodeName was not changed due to cloning" ); - equal( $meter[ 0 ].nodeType, 1, "Check if nodeType is not changed due to cloning" ); + assert.equal( $meter[ 0 ].nodeName, "meter", "Check if nodeName was not changed due to cloning" ); + assert.equal( $meter[ 0 ].nodeType, 1, "Check if nodeType is not changed due to cloning" ); } ); -test( "html(undefined)", function() { +QUnit.test( "html(undefined)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); - equal( jQuery( "#foo" ).html( "<i>test</i>" ).html( undefined ).html().toLowerCase(), "<i>test</i>", ".html(undefined) is chainable (#5571)" ); + assert.equal( jQuery( "#foo" ).html( "<i>test</i>" ).html( undefined ).html().toLowerCase(), "<i>test</i>", ".html(undefined) is chainable (#5571)" ); } ); -test( "html() on empty set", function() { +QUnit.test( "html() on empty set", function( assert ) { - expect( 1 ); + assert.expect( 1 ); - strictEqual( jQuery().html(), undefined, ".html() returns undefined for empty sets (#11962)" ); + assert.strictEqual( jQuery().html(), undefined, ".html() returns undefined for empty sets (#11962)" ); } ); function childNodeNames( node ) { @@ -1660,44 +1660,44 @@ function childNodeNames( node ) { } ).join( " " ); } -function testHtml( valueObj ) { - expect( 39 ); +function testHtml( valueObj, assert ) { + assert.expect( 39 ); var actual, expected, tmp, div = jQuery( "<div></div>" ), fixture = jQuery( "#qunit-fixture" ); div.html( valueObj( "<div id='parent_1'><div id='child_1'/></div><div id='parent_2'/>" ) ); - equal( div.children().length, 2, "Found children" ); - equal( div.children().children().length, 1, "Found grandchild" ); + assert.equal( div.children().length, 2, "Found children" ); + assert.equal( div.children().children().length, 1, "Found grandchild" ); actual = []; expected = []; tmp = jQuery( "<map/>" ).html( valueObj( "<area alt='area'/>" ) ).each( function() { expected.push( "AREA" ); actual.push( childNodeNames( this ) ); } ); - equal( expected.length, 1, "Expecting one parent" ); - deepEqual( actual, expected, "Found the inserted area element" ); + assert.equal( expected.length, 1, "Expecting one parent" ); + assert.deepEqual( actual, expected, "Found the inserted area element" ); - equal( div.html( valueObj( 5 ) ).html(), "5", "Setting a number as html" ); - equal( div.html( valueObj( 0 ) ).html(), "0", "Setting a zero as html" ); - equal( div.html( valueObj( Infinity ) ).html(), "Infinity", "Setting Infinity as html" ); - equal( div.html( valueObj( NaN ) ).html(), "", "Setting NaN as html" ); - equal( div.html( valueObj( 1e2 ) ).html(), "100", "Setting exponential number notation as html" ); + assert.equal( div.html( valueObj( 5 ) ).html(), "5", "Setting a number as html" ); + assert.equal( div.html( valueObj( 0 ) ).html(), "0", "Setting a zero as html" ); + assert.equal( div.html( valueObj( Infinity ) ).html(), "Infinity", "Setting Infinity as html" ); + assert.equal( div.html( valueObj( NaN ) ).html(), "", "Setting NaN as html" ); + assert.equal( div.html( valueObj( 1e2 ) ).html(), "100", "Setting exponential number notation as html" ); div.html( valueObj( " &" ) ); - equal( + assert.equal( div[ 0 ].innerHTML.replace( /\xA0/, " " ), " &", "Entities are passed through correctly" ); tmp = "<div>hello1</div>"; - equal( div.html( valueObj( tmp ) ).html().replace( />/g, ">" ), tmp, "Escaped html" ); + assert.equal( div.html( valueObj( tmp ) ).html().replace( />/g, ">" ), tmp, "Escaped html" ); tmp = "x" + tmp; - equal( div.html( valueObj( tmp ) ).html().replace( />/g, ">" ), tmp, "Escaped html, leading x" ); + assert.equal( div.html( valueObj( tmp ) ).html().replace( />/g, ">" ), tmp, "Escaped html, leading x" ); tmp = " " + tmp.slice( 1 ); - equal( div.html( valueObj( tmp ) ).html().replace( />/g, ">" ), tmp, "Escaped html, leading space" ); + assert.equal( div.html( valueObj( tmp ) ).html().replace( />/g, ">" ), tmp, "Escaped html, leading space" ); actual = []; expected = []; tmp = {}; jQuery( "#nonnodes" ).contents().html( valueObj( "<b>bold</b>" ) ).each( function() { @@ -1706,30 +1706,30 @@ function testHtml( valueObj ) { expected.push( this.nodeType === 1 ? "<b>bold</b>" : undefined ); actual.push( html ? html.toLowerCase() : html ); } ); - deepEqual( actual, expected, "Set containing element, text node, comment" ); - ok( tmp[ 1 ], "element" ); - ok( tmp[ 3 ], "text node" ); - ok( tmp[ 8 ], "comment" ); + assert.deepEqual( actual, expected, "Set containing element, text node, comment" ); + assert.ok( tmp[ 1 ], "element" ); + assert.ok( tmp[ 3 ], "text node" ); + assert.ok( tmp[ 8 ], "comment" ); actual = []; expected = []; fixture.children( "div" ).html( valueObj( "<b>test</b>" ) ).each( function() { expected.push( "B" ); actual.push( childNodeNames( this ) ); } ); - equal( expected.length, 7, "Expecting many parents" ); - deepEqual( actual, expected, "Correct childNodes after setting HTML" ); + assert.equal( expected.length, 7, "Expecting many parents" ); + assert.deepEqual( actual, expected, "Correct childNodes after setting HTML" ); actual = []; expected = []; fixture.html( valueObj( "<style>.foobar{color:green;}</style>" ) ).each( function() { expected.push( "STYLE" ); actual.push( childNodeNames( this ) ); } ); - equal( expected.length, 1, "Expecting one parent" ); - deepEqual( actual, expected, "Found the inserted style element" ); + assert.equal( expected.length, 1, "Expecting one parent" ); + assert.deepEqual( actual, expected, "Found the inserted style element" ); fixture.html( valueObj( "<select/>" ) ); jQuery( "#qunit-fixture select" ).html( valueObj( "<option>O1</option><option selected='selected'>O2</option><option>O3</option>" ) ); - equal( jQuery( "#qunit-fixture select" ).val(), "O2", "Selected option correct" ); + assert.equal( jQuery( "#qunit-fixture select" ).val(), "O2", "Selected option correct" ); tmp = fixture.html( valueObj( [ @@ -1745,9 +1745,9 @@ function testHtml( valueObj ) { "</div>" ].join( "" ) ) ).find( "script" ); - equal( tmp.length, 8, "All script tags remain." ); - equal( tmp[ 0 ].type, "something/else", "Non-evaluated type." ); - equal( tmp[ 1 ].type, "text/javascript", "Evaluated type." ); + assert.equal( tmp.length, 8, "All script tags remain." ); + assert.equal( tmp[ 0 ].type, "something/else", "Non-evaluated type." ); + assert.equal( tmp[ 1 ].type, "text/javascript", "Evaluated type." ); fixture.html( valueObj( "<script type='text/javascript'>ok( true, 'Injection of identical script' );</script>" ) ); fixture.html( valueObj( "<script type='text/javascript'>ok( true, 'Injection of identical script' );</script>" ) ); @@ -1765,35 +1765,35 @@ function testHtml( valueObj ) { ].join( "" ) ) ); } -test( "html(String|Number)", function() { - testHtml( manipulationBareObj ); +QUnit.test( "html(String|Number)", function( assert ) { + testHtml( manipulationBareObj, assert ); } ); -test( "html(Function)", function() { - testHtml( manipulationFunctionReturningObj ); +QUnit.test( "html(Function)", function( assert ) { + testHtml( manipulationFunctionReturningObj, assert ); } ); -test( "html( $.text() )", function() { +QUnit.test( "html( $.text() )", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var fixture = jQuery( "#qunit-fixture" ); fixture.html( fixture.text() ); - ok( /^[^<]*[^<\s][^<]*$/.test( fixture.html() ), "Replace html with text" ); + assert.ok( /^[^<]*[^<\s][^<]*$/.test( fixture.html() ), "Replace html with text" ); } ); -test( "html( fn ) returns $.text()", function() { +QUnit.test( "html( fn ) returns $.text()", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var fixture = jQuery( "#qunit-fixture" ); fixture.html( manipulationFunctionReturningObj( fixture.text() ) ); - ok( /^[^<]*[^<\s][^<]*$/.test( fixture.html() ), "Replace html with text" ); + assert.ok( /^[^<]*[^<\s][^<]*$/.test( fixture.html() ), "Replace html with text" ); } ); -test( "html(Function) with incoming value -- direct selection", function() { +QUnit.test( "html(Function) with incoming value -- direct selection", function( assert ) { - expect( 4 ); + assert.expect( 4 ); var els, actualhtml, pass; @@ -1803,7 +1803,7 @@ test( "html(Function) with incoming value -- direct selection", function() { } ); els.html( function( i, val ) { - equal( val, actualhtml[ i ], "Make sure the incoming value is correct." ); + assert.equal( val, actualhtml[ i ], "Make sure the incoming value is correct." ); return "<b>test</b>"; } ); @@ -1813,12 +1813,12 @@ test( "html(Function) with incoming value -- direct selection", function() { pass = false; } } ); - ok( pass, "Set HTML" ); + assert.ok( pass, "Set HTML" ); } ); -test( "html(Function) with incoming value -- jQuery.contents()", function() { +QUnit.test( "html(Function) with incoming value -- jQuery.contents()", function( assert ) { - expect( 14 ); + assert.expect( 14 ); var actualhtml, j, $div, $div2, insert; @@ -1828,50 +1828,50 @@ test( "html(Function) with incoming value -- jQuery.contents()", function() { } ); j.html( function( i, val ) { - equal( val, actualhtml[ i ], "Make sure the incoming value is correct." ); + assert.equal( val, actualhtml[ i ], "Make sure the incoming value is correct." ); return "<b>bold</b>"; } ); // Handle the case where no comment is in the document if ( j.length === 2 ) { - equal( null, null, "Make sure the incoming value is correct." ); + assert.equal( null, null, "Make sure the incoming value is correct." ); } - equal( j.html().replace( / xmlns="[^"]+"/g, "" ).toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" ); + assert.equal( j.html().replace( / xmlns="[^"]+"/g, "" ).toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" ); $div = jQuery( "<div />" ); - equal( $div.html( function( i, val ) { - equal( val, "", "Make sure the incoming value is correct." ); + assert.equal( $div.html( function( i, val ) { + assert.equal( val, "", "Make sure the incoming value is correct." ); return 5; } ).html(), "5", "Setting a number as html" ); - equal( $div.html( function( i, val ) { - equal( val, "5", "Make sure the incoming value is correct." ); + assert.equal( $div.html( function( i, val ) { + assert.equal( val, "5", "Make sure the incoming value is correct." ); return 0; } ).html(), "0", "Setting a zero as html" ); $div2 = jQuery( "<div/>" ); insert = "<div>hello1</div>"; - equal( $div2.html( function( i, val ) { - equal( val, "", "Make sure the incoming value is correct." ); + assert.equal( $div2.html( function( i, val ) { + assert.equal( val, "", "Make sure the incoming value is correct." ); return insert; } ).html().replace( />/g, ">" ), insert, "Verify escaped insertion." ); - equal( $div2.html( function( i, val ) { - equal( val.replace( />/g, ">" ), insert, "Make sure the incoming value is correct." ); + assert.equal( $div2.html( function( i, val ) { + assert.equal( val.replace( />/g, ">" ), insert, "Make sure the incoming value is correct." ); return "x" + insert; } ).html().replace( />/g, ">" ), "x" + insert, "Verify escaped insertion." ); - equal( $div2.html( function( i, val ) { - equal( val.replace( />/g, ">" ), "x" + insert, "Make sure the incoming value is correct." ); + assert.equal( $div2.html( function( i, val ) { + assert.equal( val.replace( />/g, ">" ), "x" + insert, "Make sure the incoming value is correct." ); return " " + insert; } ).html().replace( />/g, ">" ), " " + insert, "Verify escaped insertion." ); } ); -test( "clone()/html() don't expose jQuery/Sizzle expandos (#12858)", function() { +QUnit.test( "clone()/html() don't expose jQuery/Sizzle expandos (#12858)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var $content = jQuery( "<div><b><i>text</i></b></div>" ).appendTo( "#qunit-fixture" ), expected = /^<b><i>text<\/i><\/b>$/i; @@ -1885,59 +1885,59 @@ test( "clone()/html() don't expose jQuery/Sizzle expandos (#12858)", function() $content.find( "*" ).data( "test", true ); } - ok( expected.test( $content.clone( false )[ 0 ].innerHTML ), "clone()" ); - ok( expected.test( $content.html() ), "html()" ); + assert.ok( expected.test( $content.clone( false )[ 0 ].innerHTML ), "clone()" ); + assert.ok( expected.test( $content.html() ), "html()" ); } ); -test( "remove() no filters", function() { +QUnit.test( "remove() no filters", function( assert ) { - expect( 3 ); + assert.expect( 3 ); var first = jQuery( "#ap" ).children().first(); first.data( "foo", "bar" ); jQuery( "#ap" ).children().remove(); - ok( jQuery( "#ap" ).text().length > 10, "Check text is not removed" ); - equal( jQuery( "#ap" ).children().length, 0, "Check remove" ); + assert.ok( jQuery( "#ap" ).text().length > 10, "Check text is not removed" ); + assert.equal( jQuery( "#ap" ).children().length, 0, "Check remove" ); - equal( first.data( "foo" ), null, "first data" ); + assert.equal( first.data( "foo" ), null, "first data" ); } ); -test( "remove() with filters", function() { +QUnit.test( "remove() with filters", function( assert ) { - expect( 8 ); + assert.expect( 8 ); var markup, div; jQuery( "#ap" ).children().remove( "a" ); - ok( jQuery( "#ap" ).text().length > 10, "Check text is not removed" ); - equal( jQuery( "#ap" ).children().length, 1, "Check filtered remove" ); + assert.ok( jQuery( "#ap" ).text().length > 10, "Check text is not removed" ); + assert.equal( jQuery( "#ap" ).children().length, 1, "Check filtered remove" ); jQuery( "#ap" ).children().remove( "a, code" ); - equal( jQuery( "#ap" ).children().length, 0, "Check multi-filtered remove" ); + assert.equal( jQuery( "#ap" ).children().length, 0, "Check multi-filtered remove" ); // Positional and relative selectors markup = "<div><span>1</span><span>2</span><span>3</span><span>4</span></div>"; div = jQuery( markup ); div.children().remove( "span:nth-child(2n)" ); - equal( div.text(), "13", "relative selector in remove" ); + assert.equal( div.text(), "13", "relative selector in remove" ); div = jQuery( markup ); div.children().remove( "span:first" ); - equal( div.text(), "234", "positional selector in remove" ); + assert.equal( div.text(), "234", "positional selector in remove" ); div = jQuery( markup ); div.children().remove( "span:last" ); - equal( div.text(), "123", "positional selector in remove" ); + assert.equal( div.text(), "123", "positional selector in remove" ); // using contents will get comments regular, text, and comment nodes // Handle the case where no comment is in the document - ok( jQuery( "#nonnodes" ).contents().length >= 2, "Check node,textnode,comment remove works" ); + assert.ok( jQuery( "#nonnodes" ).contents().length >= 2, "Check node,textnode,comment remove works" ); jQuery( "#nonnodes" ).contents().remove(); - equal( jQuery( "#nonnodes" ).contents().length, 0, "Check node,textnode,comment remove works" ); + assert.equal( jQuery( "#nonnodes" ).contents().length, 0, "Check node,textnode,comment remove works" ); } ); -test( "remove() event cleaning ", function() { - expect( 1 ); +QUnit.test( "remove() event cleaning ", function( assert ) { + assert.expect( 1 ); var count, first, cleanUp; @@ -1947,14 +1947,14 @@ test( "remove() event cleaning ", function() { count++; } ).remove().appendTo( "#qunit-fixture" ).trigger( "click" ); - strictEqual( 0, count, "Event handler has been removed" ); + assert.strictEqual( 0, count, "Event handler has been removed" ); // Clean up detached data cleanUp.remove(); } ); -test( "remove() in document order #13779", function() { - expect( 1 ); +QUnit.test( "remove() in document order #13779", function( assert ) { + assert.expect( 1 ); var last, cleanData = jQuery.cleanData; @@ -1974,61 +1974,61 @@ test( "remove() in document order #13779", function() { jQuery( ".removal-fixture" ).remove(); - equal( last, 3, "The removal fixtures were removed in document order" ); + assert.equal( last, 3, "The removal fixtures were removed in document order" ); jQuery.cleanData = cleanData; } ); -test( "detach() no filters", function() { +QUnit.test( "detach() no filters", function( assert ) { - expect( 3 ); + assert.expect( 3 ); var first = jQuery( "#ap" ).children().first(); first.data( "foo", "bar" ); jQuery( "#ap" ).children().detach(); - ok( jQuery( "#ap" ).text().length > 10, "Check text is not removed" ); - equal( jQuery( "#ap" ).children().length, 0, "Check remove" ); + assert.ok( jQuery( "#ap" ).text().length > 10, "Check text is not removed" ); + assert.equal( jQuery( "#ap" ).children().length, 0, "Check remove" ); - equal( first.data( "foo" ), "bar" ); + assert.equal( first.data( "foo" ), "bar" ); first.remove(); } ); -test( "detach() with filters", function() { +QUnit.test( "detach() with filters", function( assert ) { - expect( 8 ); + assert.expect( 8 ); var markup, div; jQuery( "#ap" ).children().detach( "a" ); - ok( jQuery( "#ap" ).text().length > 10, "Check text is not removed" ); - equal( jQuery( "#ap" ).children().length, 1, "Check filtered remove" ); + assert.ok( jQuery( "#ap" ).text().length > 10, "Check text is not removed" ); + assert.equal( jQuery( "#ap" ).children().length, 1, "Check filtered remove" ); jQuery( "#ap" ).children().detach( "a, code" ); - equal( jQuery( "#ap" ).children().length, 0, "Check multi-filtered remove" ); + assert.equal( jQuery( "#ap" ).children().length, 0, "Check multi-filtered remove" ); // Positional and relative selectors markup = "<div><span>1</span><span>2</span><span>3</span><span>4</span></div>"; div = jQuery( markup ); div.children().detach( "span:nth-child(2n)" ); - equal( div.text(), "13", "relative selector in detach" ); + assert.equal( div.text(), "13", "relative selector in detach" ); div = jQuery( markup ); div.children().detach( "span:first" ); - equal( div.text(), "234", "positional selector in detach" ); + assert.equal( div.text(), "234", "positional selector in detach" ); div = jQuery( markup ); div.children().detach( "span:last" ); - equal( div.text(), "123", "positional selector in detach" ); + assert.equal( div.text(), "123", "positional selector in detach" ); // using contents will get comments regular, text, and comment nodes // Handle the case where no comment is in the document - ok( jQuery( "#nonnodes" ).contents().length >= 2, "Check node,textnode,comment remove works" ); + assert.ok( jQuery( "#nonnodes" ).contents().length >= 2, "Check node,textnode,comment remove works" ); jQuery( "#nonnodes" ).contents().detach(); - equal( jQuery( "#nonnodes" ).contents().length, 0, "Check node,textnode,comment remove works" ); + assert.equal( jQuery( "#nonnodes" ).contents().length, 0, "Check node,textnode,comment remove works" ); } ); -test( "detach() event cleaning ", function() { - expect( 1 ); +QUnit.test( "detach() event cleaning ", function( assert ) { + assert.expect( 1 ); var count, first, cleanUp; @@ -2038,34 +2038,34 @@ test( "detach() event cleaning ", function() { count++; } ).detach().appendTo( "#qunit-fixture" ).trigger( "click" ); - strictEqual( 1, count, "Event handler has not been removed" ); + assert.strictEqual( 1, count, "Event handler has not been removed" ); // Clean up detached data cleanUp.remove(); } ); -test( "empty()", function() { +QUnit.test( "empty()", function( assert ) { - expect( 6 ); + assert.expect( 6 ); - equal( jQuery( "#ap" ).children().empty().text().length, 0, "Check text is removed" ); - equal( jQuery( "#ap" ).children().length, 4, "Check elements are not removed" ); + assert.equal( jQuery( "#ap" ).children().empty().text().length, 0, "Check text is removed" ); + assert.equal( jQuery( "#ap" ).children().length, 4, "Check elements are not removed" ); // using contents will get comments regular, text, and comment nodes var j = jQuery( "#nonnodes" ).contents(); j.empty(); - equal( j.html(), "", "Check node,textnode,comment empty works" ); + assert.equal( j.html(), "", "Check node,textnode,comment empty works" ); // Ensure oldIE empties selects (#12336) - notEqual( jQuery( "#select1" ).find( "option" ).length, 0, "Have some initial options" ); + assert.notEqual( jQuery( "#select1" ).find( "option" ).length, 0, "Have some initial options" ); jQuery( "#select1" ).empty(); - equal( jQuery( "#select1" ).find( "option" ).length, 0, "No more option elements found" ); - equal( jQuery( "#select1" )[ 0 ].options.length, 0, "options.length cleared as well" ); + assert.equal( jQuery( "#select1" ).find( "option" ).length, 0, "No more option elements found" ); + assert.equal( jQuery( "#select1" )[ 0 ].options.length, 0, "options.length cleared as well" ); } ); -test( "jQuery.cleanData", function() { +QUnit.test( "jQuery.cleanData", function( assert ) { - expect( 14 ); + assert.expect( 14 ); var type, pos, div, child; @@ -2120,69 +2120,69 @@ test( "jQuery.cleanData", function() { function getDiv() { var div = jQuery( "<div class='outer'><div class='inner'></div></div>" ).on( "click", function() { - ok( true, type + " " + pos + " Click event fired." ); + assert.ok( true, type + " " + pos + " Click event fired." ); } ).on( "focus", function() { - ok( true, type + " " + pos + " Focus event fired." ); + assert.ok( true, type + " " + pos + " Focus event fired." ); } ).find( "div" ).on( "click", function() { - ok( false, type + " " + pos + " Click event fired." ); + assert.ok( false, type + " " + pos + " Click event fired." ); } ).on( "focus", function() { - ok( false, type + " " + pos + " Focus event fired." ); + assert.ok( false, type + " " + pos + " Focus event fired." ); } ).end().appendTo( "body" ); div[ 0 ].detachEvent = div[ 0 ].removeEventListener = function( t ) { - ok( true, type + " Outer " + t + " event unbound" ); + assert.ok( true, type + " Outer " + t + " event unbound" ); }; div[ 0 ].firstChild.detachEvent = div[ 0 ].firstChild.removeEventListener = function( t ) { - ok( true, type + " Inner " + t + " event unbound" ); + assert.ok( true, type + " Inner " + t + " event unbound" ); }; return div; } } ); -test( "jQuery.cleanData eliminates all private data (gh-2127)", function() { - expect( 3 ); +QUnit.test( "jQuery.cleanData eliminates all private data (gh-2127)", function( assert ) { + assert.expect( 3 ); var div = jQuery( "<div/>" ).appendTo( "#qunit-fixture" ); jQuery._data( div[ 0 ], "gh-2127", "testing" ); - ok( !jQuery.isEmptyObject( jQuery._data( div[ 0 ] ) ), "Ensure some private data exists" ); + assert.ok( !jQuery.isEmptyObject( jQuery._data( div[ 0 ] ) ), "Ensure some private data exists" ); div.remove(); - ok( !jQuery.hasData( div[ 0 ] ), "Removed element hasData should return false" ); + assert.ok( !jQuery.hasData( div[ 0 ] ), "Removed element hasData should return false" ); - ok( jQuery.isEmptyObject( jQuery._data( div[ 0 ] ) ), + assert.ok( jQuery.isEmptyObject( jQuery._data( div[ 0 ] ) ), "Private data is empty after node is removed" ); div.remove(); } ); -test( "jQuery.cleanData eliminates all public data", function() { - expect( 2 ); +QUnit.test( "jQuery.cleanData eliminates all public data", function( assert ) { + assert.expect( 2 ); var key, div = jQuery( "<div/>" ); div.data( "some", "data" ); - ok( !jQuery.isEmptyObject( jQuery.data( div[ 0 ] ) ), "Ensure some public data exists" ); + assert.ok( !jQuery.isEmptyObject( jQuery.data( div[ 0 ] ) ), "Ensure some public data exists" ); div.remove(); - ok( !jQuery.hasData( div[ 0 ] ), "Removed element hasData should return false" ); + assert.ok( !jQuery.hasData( div[ 0 ] ), "Removed element hasData should return false" ); // Make sure the expando is gone for ( key in div[ 0 ] ) { if ( /^jQuery/.test( key ) && jQuery[ key ] !== undefined ) { - ok( false, "Expando was not removed when there was no more data" ); + assert.ok( false, "Expando was not removed when there was no more data" ); } } } ); -test( "domManip plain-text caching (trac-6779)", function() { +QUnit.test( "domManip plain-text caching (trac-6779)", function( assert ) { - expect( 1 ); + assert.expect( 1 ); // DOM manipulation fails if added text matches an Object method var i, @@ -2195,13 +2195,13 @@ test( "domManip plain-text caching (trac-6779)", function() { } catch ( e ) {} } - equal( $f.text(), bad.join( "" ), "Cached strings that match Object properties" ); + assert.equal( $f.text(), bad.join( "" ), "Cached strings that match Object properties" ); $f.remove(); } ); -test( "domManip executes scripts containing html comments or CDATA (trac-9221)", function() { +QUnit.test( "domManip executes scripts containing html comments or CDATA (trac-9221)", function( assert ) { - expect( 3 ); + assert.expect( 3 ); jQuery( [ "<script type='text/javascript'>", @@ -2231,27 +2231,27 @@ test( "domManip executes scripts containing html comments or CDATA (trac-9221)", testIframeWithCallback( "domManip tolerates window-valued document[0] in IE9/10 (trac-12266)", "manipulation/iframe-denied.html", - function( test ) { - expect( 1 ); - ok( test.status, test.description ); + function( test, assert ) { + assert.expect( 1 ); + assert.ok( test.status, test.description ); } ); -test( "jQuery.clone - no exceptions for object elements #9587", function() { +QUnit.test( "jQuery.clone - no exceptions for object elements #9587", function( assert ) { - expect( 1 ); + assert.expect( 1 ); try { jQuery( "#no-clone-exception" ).clone(); - ok( true, "cloned with no exceptions" ); + assert.ok( true, "cloned with no exceptions" ); } catch ( e ) { - ok( false, e.message ); + assert.ok( false, e.message ); } } ); -test( "Cloned, detached HTML5 elems (#10667,10670)", function() { +QUnit.test( "Cloned, detached HTML5 elems (#10667,10670)", function( assert ) { - expect( 7 ); + assert.expect( 7 ); var $clone, $section = jQuery( "<section>" ).appendTo( "#qunit-fixture" ); @@ -2263,17 +2263,17 @@ test( "Cloned, detached HTML5 elems (#10667,10670)", function() { if ( $clone[ 0 ].outerHTML && !jQuery.support.opacity ) { // This branch tests cloning nodes by reading the outerHTML, used only in IE<=8 - equal( $clone[ 0 ].outerHTML, "<section></section>", "detached clone outerHTML matches '<section></section>'" ); + assert.equal( $clone[ 0 ].outerHTML, "<section></section>", "detached clone outerHTML matches '<section></section>'" ); } else { // This branch tests a known behaviour in modern browsers that should never fail. // Included for expected test count symmetry (expecting 1) - equal( $clone[ 0 ].nodeName, "SECTION", "detached clone nodeName matches 'SECTION' in modern browsers" ); + assert.equal( $clone[ 0 ].nodeName, "SECTION", "detached clone nodeName matches 'SECTION' in modern browsers" ); } // Bind an event $section.on( "click", function() { - ok( true, "clone fired event" ); + assert.ok( true, "clone fired event" ); } ); // Second clone (will have an event bound) @@ -2289,7 +2289,7 @@ test( "Cloned, detached HTML5 elems (#10667,10670)", function() { // Third clone (will have child node and text) $clone = $section.clone( true ); - equal( $clone.find( "p" ).text(), "Hello", "Assert text in child of clone" ); + assert.equal( $clone.find( "p" ).text(), "Hello", "Assert text in child of clone" ); // Trigger an event from the third clone $clone.trigger( "click" ); @@ -2304,8 +2304,8 @@ test( "Cloned, detached HTML5 elems (#10667,10670)", function() { // Fourth clone (will have newly added attributes) $clone = $section.clone( true ); - equal( $clone.attr( "class" ), $section.attr( "class" ), "clone and element have same class attribute" ); - equal( $clone.attr( "title" ), $section.attr( "title" ), "clone and element have same title attribute" ); + assert.equal( $clone.attr( "class" ), $section.attr( "class" ), "clone and element have same class attribute" ); + assert.equal( $clone.attr( "title" ), $section.attr( "title" ), "clone and element have same title attribute" ); // Remove the original $section.remove(); @@ -2324,9 +2324,9 @@ test( "Cloned, detached HTML5 elems (#10667,10670)", function() { $clone.off( "click" ); } ); -test( "Guard against exceptions when clearing safeChildNodes", function() { +QUnit.test( "Guard against exceptions when clearing safeChildNodes", function( assert ) { - expect( 1 ); + assert.expect( 1 ); var div; @@ -2334,30 +2334,30 @@ test( "Guard against exceptions when clearing safeChildNodes", function() { div = jQuery( "<div/><hr/><code/><b/>" ); } catch ( e ) {} - ok( div && div.jquery, "Created nodes safely, guarded against exceptions on safeChildNodes[ -1 ]" ); + assert.ok( div && div.jquery, "Created nodes safely, guarded against exceptions on safeChildNodes[ -1 ]" ); } ); -test( "Ensure oldIE creates a new set on appendTo (#8894)", function() { +QUnit.test( "Ensure oldIE creates a new set on appendTo (#8894)", function( assert ) { - expect( 5 ); + assert.expect( 5 ); - strictEqual( jQuery( "<div/>" ).clone().addClass( "test" ).appendTo( "<div/>" ).end().end().hasClass( "test" ), false, "Check jQuery.fn.appendTo after jQuery.clone" ); - strictEqual( jQuery( "<div/>" ).find( "p" ).end().addClass( "test" ).appendTo( "<div/>" ).end().end().hasClass( "test" ), false, "Check jQuery.fn.appendTo after jQuery.fn.find" ); - strictEqual( jQuery( "<div/>" ).text( "test" ).addClass( "test" ).appendTo( "<div/>" ).end().end().hasClass( "test" ), false, "Check jQuery.fn.appendTo after jQuery.fn.text" ); - strictEqual( jQuery( "<bdi/>" ).clone().addClass( "test" ).appendTo( "<div/>" ).end().end().hasClass( "test" ), false, "Check jQuery.fn.appendTo after clone html5 element" ); - strictEqual( jQuery( "<p/>" ).appendTo( "<div/>" ).end().length, jQuery( "<p>test</p>" ).appendTo( "<div/>" ).end().length, "Elements created with createElement and with createDocumentFragment should be treated alike" ); + assert.strictEqual( jQuery( "<div/>" ).clone().addClass( "test" ).appendTo( "<div/>" ).end().end().hasClass( "test" ), false, "Check jQuery.fn.appendTo after jQuery.clone" ); + assert.strictEqual( jQuery( "<div/>" ).find( "p" ).end().addClass( "test" ).appendTo( "<div/>" ).end().end().hasClass( "test" ), false, "Check jQuery.fn.appendTo after jQuery.fn.find" ); + assert.strictEqual( jQuery( "<div/>" ).text( "test" ).addClass( "test" ).appendTo( "<div/>" ).end().end().hasClass( "test" ), false, "Check jQuery.fn.appendTo after jQuery.fn.text" ); + assert.strictEqual( jQuery( "<bdi/>" ).clone().addClass( "test" ).appendTo( "<div/>" ).end().end().hasClass( "test" ), false, "Check jQuery.fn.appendTo after clone html5 element" ); + assert.strictEqual( jQuery( "<p/>" ).appendTo( "<div/>" ).end().length, jQuery( "<p>test</p>" ).appendTo( "<div/>" ).end().length, "Elements created with createElement and with createDocumentFragment should be treated alike" ); } ); -asyncTest( "html() - script exceptions bubble (#11743)", 2, function() { +QUnit.asyncTest( "html() - script exceptions bubble (#11743)", 2, function( assert ) { // Support: Android 2.3 only // Android 2.3 doesn't fire the window.onerror handler, just accept the reality there. if ( /android 2\.3/i.test( navigator.userAgent ) ) { - ok( true, "Test skipped, Android 2.3 doesn't fire window.onerror for " + + assert.ok( true, "Test skipped, Android 2.3 doesn't fire window.onerror for " + "errors in dynamically included scripts" ); - ok( true, "Test skipped, Android 2.3 doesn't fire window.onerror for " + + assert.ok( true, "Test skipped, Android 2.3 doesn't fire window.onerror for " + "errors in dynamically included scripts" ); - start(); + QUnit.start(); return; } @@ -2366,60 +2366,60 @@ asyncTest( "html() - script exceptions bubble (#11743)", 2, function() { setTimeout( function() { window.onerror = onerror; - start(); + QUnit.start(); }, 1000 ); window.onerror = function() { - ok( true, "Exception thrown" ); + assert.ok( true, "Exception thrown" ); if ( jQuery.ajax ) { window.onerror = function() { - ok( true, "Exception thrown in remote script" ); + assert.ok( true, "Exception thrown in remote script" ); }; jQuery( "#qunit-fixture" ).html( "<script src='data/badcall.js'></script>" ); - ok( true, "Exception ignored" ); + assert.ok( true, "Exception ignored" ); } else { - ok( true, "No jQuery.ajax" ); - ok( true, "No jQuery.ajax" ); + assert.ok( true, "No jQuery.ajax" ); + assert.ok( true, "No jQuery.ajax" ); } }; jQuery( "#qunit-fixture" ).html( "<script>undefined();</script>" ); } ); -test( "checked state is cloned with clone()", function() { +QUnit.test( "checked state is cloned with clone()", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var elem = jQuery.parseHTML( "<input type='checkbox' checked='checked'/>" )[ 0 ]; elem.checked = false; - equal( jQuery( elem ).clone().attr( "id", "clone" )[ 0 ].checked, false, "Checked false state correctly cloned" ); + assert.equal( jQuery( elem ).clone().attr( "id", "clone" )[ 0 ].checked, false, "Checked false state correctly cloned" ); elem = jQuery.parseHTML( "<input type='checkbox'/>" )[ 0 ]; elem.checked = true; - equal( jQuery( elem ).clone().attr( "id", "clone" )[ 0 ].checked, true, "Checked true state correctly cloned" ); + assert.equal( jQuery( elem ).clone().attr( "id", "clone" )[ 0 ].checked, true, "Checked true state correctly cloned" ); } ); -test( "manipulate mixed jQuery and text (#12384, #12346)", function() { +QUnit.test( "manipulate mixed jQuery and text (#12384, #12346)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var div = jQuery( "<div>a</div>" ).append( " ", jQuery( "<span>b</span>" ), " ", jQuery( "<span>c</span>" ) ), nbsp = String.fromCharCode( 160 ); - equal( div.text(), "a" + nbsp + "b" + nbsp + "c", "Appending mixed jQuery with text nodes" ); + assert.equal( div.text(), "a" + nbsp + "b" + nbsp + "c", "Appending mixed jQuery with text nodes" ); div = jQuery( "<div><div></div></div>" ) .find( "div" ) .after( "<p>a</p>", "<p>b</p>" ) .parent(); - equal( div.find( "*" ).length, 3, "added 2 paragraphs after inner div" ); + assert.equal( div.find( "*" ).length, 3, "added 2 paragraphs after inner div" ); } ); -test( "script evaluation (#11795)", function() { +QUnit.test( "script evaluation (#11795)", function( assert ) { - expect( 13 ); + assert.expect( 13 ); var scriptsIn, scriptsOut, fixture = jQuery( "#qunit-fixture" ).empty(), @@ -2450,30 +2450,30 @@ test( "script evaluation (#11795)", function() { objGlobal.ok = isOk; scriptsOut = fixture.append( scriptsIn ).find( "script" ); - equal( scriptsOut[ 0 ].type, "something/else", "Non-evaluated type." ); - equal( scriptsOut[ 1 ].type, "text/javascript", "Evaluated type." ); - deepEqual( scriptsOut.get(), fixture.find( "script" ).get(), "All script tags remain." ); + assert.equal( scriptsOut[ 0 ].type, "something/else", "Non-evaluated type." ); + assert.equal( scriptsOut[ 1 ].type, "text/javascript", "Evaluated type." ); + assert.deepEqual( scriptsOut.get(), fixture.find( "script" ).get(), "All script tags remain." ); objGlobal.ok = notOk; scriptsOut = scriptsOut.add( scriptsOut.clone() ).appendTo( fixture.find( "div" ) ); - deepEqual( fixture.find( "div script" ).get(), scriptsOut.get(), "Scripts cloned without reevaluation" ); + assert.deepEqual( fixture.find( "div script" ).get(), scriptsOut.get(), "Scripts cloned without reevaluation" ); fixture.append( scriptsOut.detach() ); - deepEqual( fixture.children( "script" ).get(), scriptsOut.get(), "Scripts detached without reevaluation" ); + assert.deepEqual( fixture.children( "script" ).get(), scriptsOut.get(), "Scripts detached without reevaluation" ); objGlobal.ok = isOk; if ( jQuery.ajax ) { Globals.register( "testBar" ); jQuery( "#qunit-fixture" ).append( "<script src='" + url( "data/testbar.php" ) + "'/>" ); - strictEqual( window[ "testBar" ], "bar", "Global script evaluation" ); + assert.strictEqual( window[ "testBar" ], "bar", "Global script evaluation" ); } else { - ok( true, "No jQuery.ajax" ); - ok( true, "No jQuery.ajax" ); + assert.ok( true, "No jQuery.ajax" ); + assert.ok( true, "No jQuery.ajax" ); } } ); -test( "jQuery._evalUrl (#12838)", function() { +QUnit.test( "jQuery._evalUrl (#12838)", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var message, expectedArgument, ajax = jQuery.ajax, @@ -2482,17 +2482,17 @@ test( "jQuery._evalUrl (#12838)", function() { message = "jQuery.ajax implementation"; expectedArgument = 1; jQuery.ajax = function( input ) { - equal( ( input.url || input ).slice( -1 ), expectedArgument, message ); + assert.equal( ( input.url || input ).slice( -1 ), expectedArgument, message ); expectedArgument++; }; jQuery( "#qunit-fixture" ).append( "<script src='1'/><script src='2'/>" ); - equal( expectedArgument, 3, "synchronous execution" ); + assert.equal( expectedArgument, 3, "synchronous execution" ); message = "custom implementation"; expectedArgument = 3; jQuery._evalUrl = jQuery.ajax; jQuery.ajax = function( options ) { - strictEqual( options, {}, "Unexpected call to jQuery.ajax" ); + assert.strictEqual( options, {}, "Unexpected call to jQuery.ajax" ); }; jQuery( "#qunit-fixture" ).append( "<script src='3'/><script src='4'/>" ); @@ -2500,7 +2500,7 @@ test( "jQuery._evalUrl (#12838)", function() { jQuery._evalUrl = evalUrl; } ); -test( "jQuery.htmlPrefilter (gh-1747)", function( assert ) { +QUnit.test( "jQuery.htmlPrefilter (gh-1747)", function( assert ) { assert.expect( 5 ); @@ -2540,9 +2540,9 @@ test( "jQuery.htmlPrefilter (gh-1747)", function( assert ) { }, 100 ); } ); -test( "insertAfter, insertBefore, etc do not work when destination is original element. Element is removed (#4087)", function() { +QUnit.test( "insertAfter, insertBefore, etc do not work when destination is original element. Element is removed (#4087)", function( assert ) { - expect( 10 ); + assert.expect( 10 ); var elems; @@ -2561,11 +2561,11 @@ test( "insertAfter, insertBefore, etc do not work when destination is original e // complex case based on http://jsfiddle.net/pbramos/gZ7vB/ jQuery( "#test4087-complex div" )[ name ]( "#test4087-complex li:last-child div:last-child" ); - equal( jQuery( "#test4087-complex li:last-child div" ).length, name === "replaceAll" ? 1 : 2, name + " a node to itself, complex case." ); + assert.equal( jQuery( "#test4087-complex li:last-child div" ).length, name === "replaceAll" ? 1 : 2, name + " a node to itself, complex case." ); // simple case jQuery( ".test4087-1" )[ name ]( ".test4087-1" ); - equal( jQuery( ".test4087-1" ).length, 1, name + " a node to itself, simple case." ); + assert.equal( jQuery( ".test4087-1" ).length, 1, name + " a node to itself, simple case." ); // clean for next test jQuery( "#test4087-complex" ).remove(); @@ -2574,30 +2574,30 @@ test( "insertAfter, insertBefore, etc do not work when destination is original e } ); } ); -test( "Index for function argument should be received (#13094)", function() { - expect( 2 ); +QUnit.test( "Index for function argument should be received (#13094)", function( assert ) { + assert.expect( 2 ); var i = 0; jQuery( "<div/><div/>" ).before( function( index ) { - equal( index, i++, "Index should be correct" ); + assert.equal( index, i++, "Index should be correct" ); } ); } ); -test( "Make sure jQuery.fn.remove can work on elements in documentFragment", function() { - expect( 1 ); +QUnit.test( "Make sure jQuery.fn.remove can work on elements in documentFragment", function( assert ) { + assert.expect( 1 ); var fragment = document.createDocumentFragment(), div = fragment.appendChild( document.createElement( "div" ) ); jQuery( div ).remove(); - equal( fragment.childNodes.length, 0, "div element was removed from documentFragment" ); + assert.equal( fragment.childNodes.length, 0, "div element was removed from documentFragment" ); } ); -test( "Make sure tr element will be appended to tbody element of table when present", function() { - expect( 1 ); +QUnit.test( "Make sure tr element will be appended to tbody element of table when present", function( assert ) { + assert.expect( 1 ); var html, table = document.createElement( "table" ); @@ -2610,11 +2610,11 @@ test( "Make sure tr element will be appended to tbody element of table when pres // Lowercase and replace spaces to remove possible browser inconsistencies html = table.innerHTML.toLowerCase().replace( /\s/g, "" ); - strictEqual( html, "<tbody><tr><td>test</td></tr></tbody>" ); + assert.strictEqual( html, "<tbody><tr><td>test</td></tr></tbody>" ); } ); -test( "Make sure tr elements will be appended to tbody element of table when present", function() { - expect( 1 ); +QUnit.test( "Make sure tr elements will be appended to tbody element of table when present", function( assert ) { + assert.expect( 1 ); var html, table = document.createElement( "table" ); @@ -2627,11 +2627,11 @@ test( "Make sure tr elements will be appended to tbody element of table when pre // Lowercase and replace spaces to remove possible browser inconsistencies html = table.innerHTML.toLowerCase().replace( /\s/g, "" ); - strictEqual( html, "<tbody><tr><td>1</td></tr><tr><td>2</td></tr></tbody>" ); + assert.strictEqual( html, "<tbody><tr><td>1</td></tr><tr><td>2</td></tr></tbody>" ); } ); -test( "Make sure tfoot element will not be appended to tbody element of table when present", function() { - expect( 1 ); +QUnit.test( "Make sure tfoot element will not be appended to tbody element of table when present", function( assert ) { + assert.expect( 1 ); var html, table = document.createElement( "table" ); @@ -2644,11 +2644,11 @@ test( "Make sure tfoot element will not be appended to tbody element of table wh // Lowercase and replace spaces to remove possible browser inconsistencies html = table.innerHTML.toLowerCase().replace( /\s/g, "" ); - strictEqual( html, "<tbody></tbody><tfoot></tfoot>" ); + assert.strictEqual( html, "<tbody></tbody><tfoot></tfoot>" ); } ); -test( "Make sure document fragment will be appended to tbody element of table when present", function() { - expect( 1 ); +QUnit.test( "Make sure document fragment will be appended to tbody element of table when present", function( assert ) { + assert.expect( 1 ); var html, fragment = document.createDocumentFragment(), @@ -2668,11 +2668,11 @@ test( "Make sure document fragment will be appended to tbody element of table wh // Lowercase and replace spaces to remove possible browser inconsistencies html = table.innerHTML.toLowerCase().replace( /\s/g, "" ); - strictEqual( html, "<tbody><tr><td>test</td></tr></tbody>" ); + assert.strictEqual( html, "<tbody><tr><td>test</td></tr></tbody>" ); } ); -test( "Make sure col element is appended correctly", function() { - expect( 1 ); +QUnit.test( "Make sure col element is appended correctly", function( assert ) { + assert.expect( 1 ); var table = jQuery( "<table cellpadding='0'><tr><td style='padding:0'>test</td></tr></table>" ); @@ -2680,10 +2680,10 @@ test( "Make sure col element is appended correctly", function() { jQuery( "<col width='150'/>" ).prependTo( table ); - strictEqual( table.find( "td" ).width(), 150 ); + assert.strictEqual( table.find( "td" ).width(), 150 ); } ); -asyncTest( "Insert script with data-URI (gh-1887)", 1, function() { +QUnit.asyncTest( "Insert script with data-URI (gh-1887)", 1, function( assert ) { Globals.register( "testFoo" ); Globals.register( "testSrcFoo" ); @@ -2698,12 +2698,12 @@ asyncTest( "Insert script with data-URI (gh-1887)", 1, function() { setTimeout( function() { if ( window[ "testSrcFoo" ] === "foo" ) { - strictEqual( window[ "testFoo" ], window[ "testSrcFoo" ], "data-URI script executed" ); + assert.strictEqual( window[ "testFoo" ], window[ "testSrcFoo" ], "data-URI script executed" ); } else { - ok( true, "data-URI script is not supported by this environment" ); + assert.ok( true, "data-URI script is not supported by this environment" ); } - start(); + QUnit.start(); }, 100 ); } ); diff --git a/test/unit/offset.js b/test/unit/offset.js index 7575a001e..11633b6a7 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -24,7 +24,7 @@ var supportsScroll, supportsFixedPosition, checkFixed.remove(); }; -module( "offset", { setup: function() { +QUnit.module( "offset", { setup: function() { if ( typeof checkSupport === "function" ) { checkSupport(); } @@ -43,26 +43,26 @@ module( "offset", { setup: function() { the iframe window and the "jQuery" symbol is used to access any static methods. */ -test( "empty set", function() { - expect( 2 ); - strictEqual( jQuery().offset(), undefined, "offset() returns undefined for empty set (#11962)" ); - strictEqual( jQuery().position(), undefined, "position() returns undefined for empty set (#11962)" ); +QUnit.test( "empty set", function( assert ) { + assert.expect( 2 ); + assert.strictEqual( jQuery().offset(), undefined, "offset() returns undefined for empty set (#11962)" ); + assert.strictEqual( jQuery().position(), undefined, "position() returns undefined for empty set (#11962)" ); } ); -test( "disconnected element", function() { - expect( 2 ); +QUnit.test( "disconnected element", function( assert ) { + assert.expect( 2 ); var result = jQuery( document.createElement( "div" ) ).offset(); // These tests are solely for master/compat consistency // Retrieving offset on disconnected/hidden elements is not officially // valid input, but will return zeros for back-compat - equal( result.top, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" ); - equal( result.left, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" ); + assert.equal( result.top, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" ); + assert.equal( result.left, 0, "Retrieving offset on disconnected elements returns zeros (gh-2310)" ); } ); -test( "hidden (display: none) element", function() { - expect( 2 ); +QUnit.test( "hidden (display: none) element", function( assert ) { + assert.expect( 2 ); var node = jQuery( "<div style='display: none' />" ).appendTo( "#qunit-fixture" ), result = node.offset(); @@ -72,12 +72,12 @@ test( "hidden (display: none) element", function() { // These tests are solely for master/compat consistency // Retrieving offset on disconnected/hidden elements is not officially // valid input, but will return zeros for back-compat - equal( result.top, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" ); - equal( result.left, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" ); + assert.equal( result.top, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" ); + assert.equal( result.left, 0, "Retrieving offset on hidden elements returns zeros (gh-2310)" ); } ); -testIframe( "offset/absolute", "absolute", function( $, iframe ) { - expect( 4 ); +testIframe( "offset/absolute", "absolute", function( $, iframe, document, assert ) { + assert.expect( 4 ); var doc = iframe.document, tests; @@ -87,8 +87,8 @@ testIframe( "offset/absolute", "absolute", function( $, iframe ) { { "id": "#absolute-1", "top": 1, "left": 1 } ]; jQuery.each( tests, function() { - equal( jQuery( this[ "id" ], doc ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" ); - equal( jQuery( this[ "id" ], doc ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" ); + assert.equal( jQuery( this[ "id" ], doc ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" ); + assert.equal( jQuery( this[ "id" ], doc ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" ); } ); // get position @@ -96,13 +96,13 @@ testIframe( "offset/absolute", "absolute", function( $, iframe ) { { "id": "#absolute-1", "top": 0, "left": 0 } ]; jQuery.each( tests, function() { - equal( jQuery( this[ "id" ], doc ).position().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').position().top" ); - equal( jQuery( this[ "id" ], doc ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" ); + assert.equal( jQuery( this[ "id" ], doc ).position().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').position().top" ); + assert.equal( jQuery( this[ "id" ], doc ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" ); } ); } ); -testIframe( "offset/absolute", "absolute", function( $ ) { - expect( 178 ); +testIframe( "offset/absolute", "absolute", function( $, window, document, assert ) { + assert.expect( 178 ); var tests, offset; @@ -114,8 +114,8 @@ testIframe( "offset/absolute", "absolute", function( $ ) { { "id": "#absolute-2", "top": 20, "left": 20 } ]; jQuery.each( tests, function() { - equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" ); } ); // get position @@ -126,14 +126,14 @@ testIframe( "offset/absolute", "absolute", function( $ ) { { "id": "#absolute-2", "top": 19, "left": 19 } ]; jQuery.each( tests, function() { - equal( $( this[ "id" ] ).position().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').position().top" ); - equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" ); + assert.equal( $( this[ "id" ] ).position().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').position().top" ); + assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" ); } ); // test #5781 offset = $( "#positionTest" ).offset( { "top": 10, "left": 10 } ).offset(); - equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." ); - equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." ); + assert.equal( offset.top, 10, "Setting offset on element with position absolute but 'auto' values." ); + assert.equal( offset.left, 10, "Setting offset on element with position absolute but 'auto' values." ); // set offset tests = [ @@ -156,24 +156,24 @@ testIframe( "offset/absolute", "absolute", function( $ ) { ]; jQuery.each( tests, function() { $( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ] } ); - equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" ); var top = this[ "top" ], left = this[ "left" ]; $( this[ "id" ] ).offset( function( i, val ) { - equal( val.top, top, "Verify incoming top position." ); - equal( val.left, left, "Verify incoming top position." ); + assert.equal( val.top, top, "Verify incoming top position." ); + assert.equal( val.left, left, "Verify incoming top position." ); return { "top": top + 1, "left": left + 1 }; } ); - equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + " })" ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + " })" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + " })" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + " })" ); $( this[ "id" ] ) .offset( { "left": this[ "left" ] + 2 } ) .offset( { "top": this[ "top" ] + 2 } ); - equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 2, "Setting one property at a time." ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 2, "Setting one property at a time." ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 2, "Setting one property at a time." ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 2, "Setting one property at a time." ); $( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ], "using": function( props ) { $( this ).css( { @@ -181,13 +181,13 @@ testIframe( "offset/absolute", "absolute", function( $ ) { "left": props.left + 1 } ); } } ); - equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" ); } ); } ); -testIframe( "offset/relative", "relative", function( $ ) { - expect( 60 ); +testIframe( "offset/relative", "relative", function( $, window, document, assert ) { + assert.expect( 60 ); var tests; @@ -198,8 +198,8 @@ testIframe( "offset/relative", "relative", function( $ ) { { "id": "#relative-2", "top": 142, "left": 27 } ]; jQuery.each( tests, function() { - equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" ); } ); // get position @@ -209,8 +209,8 @@ testIframe( "offset/relative", "relative", function( $ ) { { "id": "#relative-2", "top": 141, "left": 26 } ]; jQuery.each( tests, function() { - equal( $( this[ "id" ] ).position().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').position().top" ); - equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" ); + assert.equal( $( this[ "id" ] ).position().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').position().top" ); + assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').position().left" ); } ); // set offset @@ -230,8 +230,8 @@ testIframe( "offset/relative", "relative", function( $ ) { ]; jQuery.each( tests, function() { $( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ] } ); - equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" ); $( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ], "using": function( props ) { $( this ).css( { @@ -239,13 +239,13 @@ testIframe( "offset/relative", "relative", function( $ ) { "left": props.left + 1 } ); } } ); - equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" ); } ); } ); -testIframe( "offset/static", "static", function( $ ) { - expect( 80 ); +testIframe( "offset/static", "static", function( $, window, document, assert ) { + assert.expect( 80 ); var tests; @@ -257,8 +257,8 @@ testIframe( "offset/static", "static", function( $ ) { { "id": "#static-2", "top": 122, left: 7 } ]; jQuery.each( tests, function() { - equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset().top" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset().left" ); } ); // get position @@ -269,8 +269,8 @@ testIframe( "offset/static", "static", function( $ ) { { "id": "#static-2", "top": 121, "left": 6 } ]; jQuery.each( tests, function() { - equal( $( this[ "id" ] ).position().top, this[ "top" ], "jQuery('" + this[ "top" ] + "').position().top" ); - equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "left" ] + "').position().left" ); + assert.equal( $( this[ "id" ] ).position().top, this[ "top" ], "jQuery('" + this[ "top" ] + "').position().top" ); + assert.equal( $( this[ "id" ] ).position().left, this[ "left" ], "jQuery('" + this[ "left" ] + "').position().left" ); } ); // set offset @@ -294,8 +294,8 @@ testIframe( "offset/static", "static", function( $ ) { ]; jQuery.each( tests, function() { $( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ] } ); - equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" ); $( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ], "using": function( props ) { $( this ).css( { @@ -303,13 +303,13 @@ testIframe( "offset/static", "static", function( $ ) { "left": props.left + 1 } ); } } ); - equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" ); } ); } ); -testIframe( "offset/fixed", "fixed", function( $ ) { - expect( 34 ); +testIframe( "offset/fixed", "fixed", function( $, window, document, assert ) { + assert.expect( 34 ); var tests, $noTopLeft; @@ -332,23 +332,23 @@ testIframe( "offset/fixed", "fixed", function( $ ) { jQuery.each( tests, function() { if ( !window.supportsScroll ) { - ok( true, "Browser doesn't support scroll position." ); - ok( true, "Browser doesn't support scroll position." ); - ok( true, "Browser doesn't support scroll position." ); - ok( true, "Browser doesn't support scroll position." ); + assert.ok( true, "Browser doesn't support scroll position." ); + assert.ok( true, "Browser doesn't support scroll position." ); + assert.ok( true, "Browser doesn't support scroll position." ); + assert.ok( true, "Browser doesn't support scroll position." ); } else if ( window.supportsFixedPosition ) { - equal( $( this[ "id" ] ).offset().top, this[ "offsetTop" ], "jQuery('" + this[ "id" ] + "').offset().top" ); - equal( $( this[ "id" ] ).position().top, this[ "positionTop" ], "jQuery('" + this[ "id" ] + "').position().top" ); - equal( $( this[ "id" ] ).offset().left, this[ "offsetLeft" ], "jQuery('" + this[ "id" ] + "').offset().left" ); - equal( $( this[ "id" ] ).position().left, this[ "positionLeft" ], "jQuery('" + this[ "id" ] + "').position().left" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "offsetTop" ], "jQuery('" + this[ "id" ] + "').offset().top" ); + assert.equal( $( this[ "id" ] ).position().top, this[ "positionTop" ], "jQuery('" + this[ "id" ] + "').position().top" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "offsetLeft" ], "jQuery('" + this[ "id" ] + "').offset().left" ); + assert.equal( $( this[ "id" ] ).position().left, this[ "positionLeft" ], "jQuery('" + this[ "id" ] + "').position().left" ); } else { // need to have same number of assertions - ok( true, "Fixed position is not supported" ); - ok( true, "Fixed position is not supported" ); - ok( true, "Fixed position is not supported" ); - ok( true, "Fixed position is not supported" ); + assert.ok( true, "Fixed position is not supported" ); + assert.ok( true, "Fixed position is not supported" ); + assert.ok( true, "Fixed position is not supported" ); + assert.ok( true, "Fixed position is not supported" ); } } ); @@ -364,8 +364,8 @@ testIframe( "offset/fixed", "fixed", function( $ ) { jQuery.each( tests, function() { if ( window.supportsFixedPosition ) { $( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ] } ); - equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ], "jQuery('" + this[ "id" ] + "').offset({ top: " + this[ "top" ] + " })" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ], "jQuery('" + this[ "id" ] + "').offset({ left: " + this[ "left" ] + " })" ); $( this[ "id" ] ).offset( { "top": this[ "top" ], "left": this[ "left" ], "using": function( props ) { $( this ).css( { @@ -373,178 +373,178 @@ testIframe( "offset/fixed", "fixed", function( $ ) { "left": props.left + 1 } ); } } ); - equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" ); - equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" ); + assert.equal( $( this[ "id" ] ).offset().top, this[ "top" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ top: " + ( this[ "top" ] + 1 ) + ", using: fn })" ); + assert.equal( $( this[ "id" ] ).offset().left, this[ "left" ] + 1, "jQuery('" + this[ "id" ] + "').offset({ left: " + ( this[ "left" ] + 1 ) + ", using: fn })" ); } else { // need to have same number of assertions - ok( true, "Fixed position is not supported" ); - ok( true, "Fixed position is not supported" ); - ok( true, "Fixed position is not supported" ); - ok( true, "Fixed position is not supported" ); + assert.ok( true, "Fixed position is not supported" ); + assert.ok( true, "Fixed position is not supported" ); + assert.ok( true, "Fixed position is not supported" ); + assert.ok( true, "Fixed position is not supported" ); } } ); // Bug 8316 $noTopLeft = $( "#fixed-no-top-left" ); if ( window.supportsFixedPosition ) { - equal( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" ); - equal( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" ); + assert.equal( $noTopLeft.offset().top, 1007, "Check offset top for fixed element with no top set" ); + assert.equal( $noTopLeft.offset().left, 1007, "Check offset left for fixed element with no left set" ); } else { // need to have same number of assertions - ok( true, "Fixed position is not supported" ); - ok( true, "Fixed position is not supported" ); + assert.ok( true, "Fixed position is not supported" ); + assert.ok( true, "Fixed position is not supported" ); } } ); -testIframe( "offset/table", "table", function( $ ) { - expect( 4 ); +testIframe( "offset/table", "table", function( $, window, document, assert ) { + assert.expect( 4 ); - equal( $( "#table-1" ).offset().top, 6, "jQuery('#table-1').offset().top" ); - equal( $( "#table-1" ).offset().left, 6, "jQuery('#table-1').offset().left" ); + assert.equal( $( "#table-1" ).offset().top, 6, "jQuery('#table-1').offset().top" ); + assert.equal( $( "#table-1" ).offset().left, 6, "jQuery('#table-1').offset().left" ); - equal( $( "#th-1" ).offset().top, 10, "jQuery('#th-1').offset().top" ); - equal( $( "#th-1" ).offset().left, 10, "jQuery('#th-1').offset().left" ); + assert.equal( $( "#th-1" ).offset().top, 10, "jQuery('#th-1').offset().top" ); + assert.equal( $( "#th-1" ).offset().left, 10, "jQuery('#th-1').offset().left" ); } ); -testIframe( "offset/scroll", "scroll", function( $, win ) { - expect( 30 ); +testIframe( "offset/scroll", "scroll", function( $, win, doc, assert ) { + assert.expect( 30 ); // If we're going to bastardize the tests, let's just DO it var ie = /msie 8/i.test( navigator.userAgent ); if ( ie ) { - ok( true, "TestSwarm's iframe has hosed this test in oldIE, we surrender" ); + assert.ok( true, "TestSwarm's iframe has hosed this test in oldIE, we surrender" ); } else { - equal( $( "#scroll-1" ).offset().top, 7, "jQuery('#scroll-1').offset().top" ); + assert.equal( $( "#scroll-1" ).offset().top, 7, "jQuery('#scroll-1').offset().top" ); } - equal( $( "#scroll-1" ).offset().left, 7, "jQuery('#scroll-1').offset().left" ); + assert.equal( $( "#scroll-1" ).offset().left, 7, "jQuery('#scroll-1').offset().left" ); if ( ie ) { - ok( true, "TestSwarm's iframe has hosed this test in oldIE, we surrender" ); + assert.ok( true, "TestSwarm's iframe has hosed this test in oldIE, we surrender" ); } else { - equal( $( "#scroll-1-1" ).offset().top, 11, "jQuery('#scroll-1-1').offset().top" ); + assert.equal( $( "#scroll-1-1" ).offset().top, 11, "jQuery('#scroll-1-1').offset().top" ); } - equal( $( "#scroll-1-1" ).offset().left, 11, "jQuery('#scroll-1-1').offset().left" ); + assert.equal( $( "#scroll-1-1" ).offset().left, 11, "jQuery('#scroll-1-1').offset().left" ); // These tests are solely for master/compat consistency // Retrieving offset on disconnected/hidden elements is not officially // valid input, but will return zeros for back-compat - equal( $( "#hidden" ).offset().top, 0, "Hidden elements do not subtract scroll" ); - equal( $( "#hidden" ).offset().left, 0, "Hidden elements do not subtract scroll" ); + assert.equal( $( "#hidden" ).offset().top, 0, "Hidden elements do not subtract scroll" ); + assert.equal( $( "#hidden" ).offset().left, 0, "Hidden elements do not subtract scroll" ); // scroll offset tests .scrollTop/Left - equal( $( "#scroll-1" ).scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" ); - equal( $( "#scroll-1" ).scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" ); + assert.equal( $( "#scroll-1" ).scrollTop(), 5, "jQuery('#scroll-1').scrollTop()" ); + assert.equal( $( "#scroll-1" ).scrollLeft(), 5, "jQuery('#scroll-1').scrollLeft()" ); - equal( $( "#scroll-1-1" ).scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" ); - equal( $( "#scroll-1-1" ).scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" ); + assert.equal( $( "#scroll-1-1" ).scrollTop(), 0, "jQuery('#scroll-1-1').scrollTop()" ); + assert.equal( $( "#scroll-1-1" ).scrollLeft(), 0, "jQuery('#scroll-1-1').scrollLeft()" ); // scroll method chaining - equal( $( "#scroll-1" ).scrollTop( undefined ).scrollTop(), 5, ".scrollTop(undefined) is chainable (#5571)" ); - equal( $( "#scroll-1" ).scrollLeft( undefined ).scrollLeft(), 5, ".scrollLeft(undefined) is chainable (#5571)" ); + assert.equal( $( "#scroll-1" ).scrollTop( undefined ).scrollTop(), 5, ".scrollTop(undefined) is chainable (#5571)" ); + assert.equal( $( "#scroll-1" ).scrollLeft( undefined ).scrollLeft(), 5, ".scrollLeft(undefined) is chainable (#5571)" ); win.name = "test"; if ( !window.supportsScroll ) { - ok( true, "Browser doesn't support scroll position." ); - ok( true, "Browser doesn't support scroll position." ); + assert.ok( true, "Browser doesn't support scroll position." ); + assert.ok( true, "Browser doesn't support scroll position." ); - ok( true, "Browser doesn't support scroll position." ); - ok( true, "Browser doesn't support scroll position." ); + assert.ok( true, "Browser doesn't support scroll position." ); + assert.ok( true, "Browser doesn't support scroll position." ); } else { - equal( $( win ).scrollTop(), 1000, "jQuery(window).scrollTop()" ); - equal( $( win ).scrollLeft(), 1000, "jQuery(window).scrollLeft()" ); + assert.equal( $( win ).scrollTop(), 1000, "jQuery(window).scrollTop()" ); + assert.equal( $( win ).scrollLeft(), 1000, "jQuery(window).scrollLeft()" ); - equal( $( win.document ).scrollTop(), 1000, "jQuery(document).scrollTop()" ); - equal( $( win.document ).scrollLeft(), 1000, "jQuery(document).scrollLeft()" ); + assert.equal( $( win.document ).scrollTop(), 1000, "jQuery(document).scrollTop()" ); + assert.equal( $( win.document ).scrollLeft(), 1000, "jQuery(document).scrollLeft()" ); } // test jQuery using parent window/document // jQuery reference here is in the iframe window.scrollTo( 0, 0 ); - equal( $( window ).scrollTop(), 0, "jQuery(window).scrollTop() other window" ); - equal( $( window ).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" ); - equal( $( document ).scrollTop(), 0, "jQuery(window).scrollTop() other document" ); - equal( $( document ).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" ); + assert.equal( $( window ).scrollTop(), 0, "jQuery(window).scrollTop() other window" ); + assert.equal( $( window ).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" ); + assert.equal( $( document ).scrollTop(), 0, "jQuery(window).scrollTop() other document" ); + assert.equal( $( document ).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" ); // Tests scrollTop/Left with empty jquery objects - notEqual( $().scrollTop( 100 ), null, "jQuery().scrollTop(100) testing setter on empty jquery object" ); - notEqual( $().scrollLeft( 100 ), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" ); - notEqual( $().scrollTop( null ), null, "jQuery().scrollTop(null) testing setter on empty jquery object" ); - notEqual( $().scrollLeft( null ), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" ); - strictEqual( $().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" ); - strictEqual( $().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" ); + assert.notEqual( $().scrollTop( 100 ), null, "jQuery().scrollTop(100) testing setter on empty jquery object" ); + assert.notEqual( $().scrollLeft( 100 ), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" ); + assert.notEqual( $().scrollTop( null ), null, "jQuery().scrollTop(null) testing setter on empty jquery object" ); + assert.notEqual( $().scrollLeft( null ), null, "jQuery().scrollLeft(null) testing setter on empty jquery object" ); + assert.strictEqual( $().scrollTop(), null, "jQuery().scrollTop(100) testing setter on empty jquery object" ); + assert.strictEqual( $().scrollLeft(), null, "jQuery().scrollLeft(100) testing setter on empty jquery object" ); // Tests position after parent scrolling (#15239) $( "#scroll-1" ).scrollTop( 0 ); $( "#scroll-1" ).scrollLeft( 0 ); - equal( $( "#scroll-1-1" ).position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" ); - equal( $( "#scroll-1-1" ).position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" ); + assert.equal( $( "#scroll-1-1" ).position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" ); + assert.equal( $( "#scroll-1-1" ).position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" ); $( "#scroll-1" ).scrollTop( 5 ); $( "#scroll-1" ).scrollLeft( 5 ); - equal( $( "#scroll-1-1" ).position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" ); - equal( $( "#scroll-1-1" ).position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" ); + assert.equal( $( "#scroll-1-1" ).position().top, 6, "jQuery('#scroll-1-1').position().top unaffected by parent scrolling" ); + assert.equal( $( "#scroll-1-1" ).position().left, 6, "jQuery('#scroll-1-1').position().left unaffected by parent scrolling" ); } ); -testIframe( "offset/body", "body", function( $ ) { - expect( 4 ); +testIframe( "offset/body", "body", function( $, window, document, assert ) { + assert.expect( 4 ); - equal( $( "body" ).offset().top, 1, "jQuery('#body').offset().top" ); - equal( $( "body" ).offset().left, 1, "jQuery('#body').offset().left" ); - equal( $( "#firstElement" ).position().left, 5, "$('#firstElement').position().left" ); - equal( $( "#firstElement" ).position().top, 5, "$('#firstElement').position().top" ); + assert.equal( $( "body" ).offset().top, 1, "jQuery('#body').offset().top" ); + assert.equal( $( "body" ).offset().left, 1, "jQuery('#body').offset().left" ); + assert.equal( $( "#firstElement" ).position().left, 5, "$('#firstElement').position().left" ); + assert.equal( $( "#firstElement" ).position().top, 5, "$('#firstElement').position().top" ); } ); -test( "chaining", function() { - expect( 3 ); +QUnit.test( "chaining", function( assert ) { + assert.expect( 3 ); var coords = { "top": 1, "left": 1 }; - equal( jQuery( "#absolute-1" ).offset( coords ).jquery, jQuery.fn.jquery, "offset(coords) returns jQuery object" ); - equal( jQuery( "#non-existent" ).offset( coords ).jquery, jQuery.fn.jquery, "offset(coords) with empty jQuery set returns jQuery object" ); - equal( jQuery( "#absolute-1" ).offset( undefined ).jquery, jQuery.fn.jquery, "offset(undefined) returns jQuery object (#5571)" ); + assert.equal( jQuery( "#absolute-1" ).offset( coords ).jquery, jQuery.fn.jquery, "offset(coords) returns jQuery object" ); + assert.equal( jQuery( "#non-existent" ).offset( coords ).jquery, jQuery.fn.jquery, "offset(coords) with empty jQuery set returns jQuery object" ); + assert.equal( jQuery( "#absolute-1" ).offset( undefined ).jquery, jQuery.fn.jquery, "offset(undefined) returns jQuery object (#5571)" ); } ); -test( "offsetParent", function() { - expect( 13 ); +QUnit.test( "offsetParent", function( assert ) { + assert.expect( 13 ); var body, header, div, area; body = jQuery( "body" ).offsetParent(); - equal( body.length, 1, "Only one offsetParent found." ); - equal( body[ 0 ], document.documentElement, "The html element is the offsetParent of the body." ); + assert.equal( body.length, 1, "Only one offsetParent found." ); + assert.equal( body[ 0 ], document.documentElement, "The html element is the offsetParent of the body." ); header = jQuery( "#qunit" ).offsetParent(); - equal( header.length, 1, "Only one offsetParent found." ); - equal( header[ 0 ], document.documentElement, "The html element is the offsetParent of #qunit." ); + assert.equal( header.length, 1, "Only one offsetParent found." ); + assert.equal( header[ 0 ], document.documentElement, "The html element is the offsetParent of #qunit." ); div = jQuery( "#nothiddendivchild" ).offsetParent(); - equal( div.length, 1, "Only one offsetParent found." ); - equal( div[ 0 ], document.getElementById( "qunit-fixture" ), "The #qunit-fixture is the offsetParent of #nothiddendivchild." ); + assert.equal( div.length, 1, "Only one offsetParent found." ); + assert.equal( div[ 0 ], document.getElementById( "qunit-fixture" ), "The #qunit-fixture is the offsetParent of #nothiddendivchild." ); jQuery( "#nothiddendiv" ).css( "position", "relative" ); div = jQuery( "#nothiddendivchild" ).offsetParent(); - equal( div.length, 1, "Only one offsetParent found." ); - equal( div[ 0 ], jQuery( "#nothiddendiv" )[ 0 ], "The div is the offsetParent." ); + assert.equal( div.length, 1, "Only one offsetParent found." ); + assert.equal( div[ 0 ], jQuery( "#nothiddendiv" )[ 0 ], "The div is the offsetParent." ); div = jQuery( "body, #nothiddendivchild" ).offsetParent(); - equal( div.length, 2, "Two offsetParent found." ); - equal( div[ 0 ], document.documentElement, "The html element is the offsetParent of the body." ); - equal( div[ 1 ], jQuery( "#nothiddendiv" )[ 0 ], "The div is the offsetParent." ); + assert.equal( div.length, 2, "Two offsetParent found." ); + assert.equal( div[ 0 ], document.documentElement, "The html element is the offsetParent of the body." ); + assert.equal( div[ 1 ], jQuery( "#nothiddendiv" )[ 0 ], "The div is the offsetParent." ); area = jQuery( "#imgmap area" ).offsetParent(); - equal( area[ 0 ], document.documentElement, "The html element is the offsetParent of the body." ); + assert.equal( area[ 0 ], document.documentElement, "The html element is the offsetParent of the body." ); div = jQuery( "<div>" ).css( { "position": "absolute" } ).appendTo( "body" ); - equal( div.offsetParent()[ 0 ], document.documentElement, "Absolutely positioned div returns html as offset parent, see #12139" ); + assert.equal( div.offsetParent()[ 0 ], document.documentElement, "Absolutely positioned div returns html as offset parent, see #12139" ); div.remove(); } ); -test( "fractions (see #7730 and #7885)", function() { - expect( 2 ); +QUnit.test( "fractions (see #7730 and #7885)", function( assert ) { + assert.expect( 2 ); jQuery( "body" ).append( "<div id='fractions'/>" ); @@ -564,14 +564,14 @@ test( "fractions (see #7730 and #7885)", function() { result = div.offset(); - equal( result.top, expected.top, "Check top" ); - equal( result.left, expected.left, "Check left" ); + assert.equal( result.top, expected.top, "Check top" ); + assert.equal( result.left, expected.left, "Check left" ); div.remove(); } ); -test( "iframe scrollTop/Left (see gh-1945)", function() { - expect( 2 ); +QUnit.test( "iframe scrollTop/Left (see gh-1945)", function( assert ) { + assert.expect( 2 ); var ifDoc = jQuery( "#iframe" )[ 0 ].contentDocument; @@ -581,8 +581,8 @@ test( "iframe scrollTop/Left (see gh-1945)", function() { if ( /iphone os/i.test( navigator.userAgent ) || /android 2\.3/i.test( navigator.userAgent ) || /android 4\.0/i.test( navigator.userAgent ) ) { - equal( true, true, "Can't scroll iframes in this environment" ); - equal( true, true, "Can't scroll iframes in this environment" ); + assert.equal( true, true, "Can't scroll iframes in this environment" ); + assert.equal( true, true, "Can't scroll iframes in this environment" ); } else { @@ -599,8 +599,8 @@ test( "iframe scrollTop/Left (see gh-1945)", function() { jQuery( ifDoc ).scrollTop( 200 ); jQuery( ifDoc ).scrollLeft( 500 ); - equal( jQuery( ifDoc ).scrollTop(), 200, "$($('#iframe')[0].contentDocument).scrollTop()" ); - equal( jQuery( ifDoc ).scrollLeft(), 500, "$($('#iframe')[0].contentDocument).scrollLeft()" ); + assert.equal( jQuery( ifDoc ).scrollTop(), 200, "$($('#iframe')[0].contentDocument).scrollTop()" ); + assert.equal( jQuery( ifDoc ).scrollLeft(), 500, "$($('#iframe')[0].contentDocument).scrollLeft()" ); } } ); diff --git a/test/unit/queue.js b/test/unit/queue.js index 50a630fb4..7ce85cb35 100644 --- a/test/unit/queue.js +++ b/test/unit/queue.js @@ -1,147 +1,147 @@ -module( "queue", { teardown: moduleTeardown } ); +QUnit.module( "queue", { teardown: moduleTeardown } ); -test( "queue() with other types", function() { - expect( 14 ); +QUnit.test( "queue() with other types", function( assert ) { + assert.expect( 14 ); - stop(); + QUnit.stop(); var $div = jQuery( {} ), counter = 0; $div.promise( "foo" ).done( function() { - equal( counter, 0, "Deferred for collection with no queue is automatically resolved" ); + assert.equal( counter, 0, "Deferred for collection with no queue is automatically resolved" ); } ); $div .queue( "foo", function() { - equal( ++counter, 1, "Dequeuing" ); + assert.equal( ++counter, 1, "Dequeuing" ); jQuery.dequeue( this, "foo" ); } ) .queue( "foo", function() { - equal( ++counter, 2, "Dequeuing" ); + assert.equal( ++counter, 2, "Dequeuing" ); jQuery( this ).dequeue( "foo" ); } ) .queue( "foo", function() { - equal( ++counter, 3, "Dequeuing" ); + assert.equal( ++counter, 3, "Dequeuing" ); } ) .queue( "foo", function() { - equal( ++counter, 4, "Dequeuing" ); + assert.equal( ++counter, 4, "Dequeuing" ); } ); $div.promise( "foo" ).done( function() { - equal( counter, 4, "Testing previous call to dequeue in deferred" ); - start(); + assert.equal( counter, 4, "Testing previous call to dequeue in deferred" ); + QUnit.start(); } ); - equal( $div.queue( "foo" ).length, 4, "Testing queue length" ); + assert.equal( $div.queue( "foo" ).length, 4, "Testing queue length" ); - equal( $div.queue( "foo", undefined ).queue( "foo" ).length, 4, ".queue('name',undefined) does nothing but is chainable (#5571)" ); + assert.equal( $div.queue( "foo", undefined ).queue( "foo" ).length, 4, ".queue('name',undefined) does nothing but is chainable (#5571)" ); $div.dequeue( "foo" ); - equal( counter, 3, "Testing previous call to dequeue" ); - equal( $div.queue( "foo" ).length, 1, "Testing queue length" ); + assert.equal( counter, 3, "Testing previous call to dequeue" ); + assert.equal( $div.queue( "foo" ).length, 1, "Testing queue length" ); $div.dequeue( "foo" ); - equal( counter, 4, "Testing previous call to dequeue" ); - equal( $div.queue( "foo" ).length, 0, "Testing queue length" ); + assert.equal( counter, 4, "Testing previous call to dequeue" ); + assert.equal( $div.queue( "foo" ).length, 0, "Testing queue length" ); $div.dequeue( "foo" ); - equal( counter, 4, "Testing previous call to dequeue" ); - equal( $div.queue( "foo" ).length, 0, "Testing queue length" ); + assert.equal( counter, 4, "Testing previous call to dequeue" ); + assert.equal( $div.queue( "foo" ).length, 0, "Testing queue length" ); } ); -test( "queue(name) passes in the next item in the queue as a parameter", function() { - expect( 2 ); +QUnit.test( "queue(name) passes in the next item in the queue as a parameter", function( assert ) { + assert.expect( 2 ); var div = jQuery( {} ), counter = 0; div.queue( "foo", function( next ) { - equal( ++counter, 1, "Dequeueing" ); + assert.equal( ++counter, 1, "Dequeueing" ); next(); } ).queue( "foo", function( next ) { - equal( ++counter, 2, "Next was called" ); + assert.equal( ++counter, 2, "Next was called" ); next(); } ).queue( "bar", function() { - equal( ++counter, 3, "Other queues are not triggered by next()" ); + assert.equal( ++counter, 3, "Other queues are not triggered by next()" ); } ); div.dequeue( "foo" ); } ); -test( "queue() passes in the next item in the queue as a parameter to fx queues", function() { - expect( 3 ); - stop(); +QUnit.test( "queue() passes in the next item in the queue as a parameter to fx queues", function( assert ) { + assert.expect( 3 ); + QUnit.stop(); var div = jQuery( {} ), counter = 0; div.queue( function( next ) { - equal( ++counter, 1, "Dequeueing" ); + assert.equal( ++counter, 1, "Dequeueing" ); setTimeout( function() { next(); }, 500 ); } ).queue( function( next ) { - equal( ++counter, 2, "Next was called" ); + assert.equal( ++counter, 2, "Next was called" ); next(); } ).queue( "bar", function() { - equal( ++counter, 3, "Other queues are not triggered by next()" ); + assert.equal( ++counter, 3, "Other queues are not triggered by next()" ); } ); jQuery.when( div.promise( "fx" ), div ).done( function() { - equal( counter, 2, "Deferreds resolved" ); - start(); + assert.equal( counter, 2, "Deferreds resolved" ); + QUnit.start(); } ); } ); -test( "callbacks keep their place in the queue", function() { - expect( 5 ); - stop(); +QUnit.test( "callbacks keep their place in the queue", function( assert ) { + assert.expect( 5 ); + QUnit.stop(); var div = jQuery( "<div>" ), counter = 0; div.queue( function( next ) { - equal( ++counter, 1, "Queue/callback order: first called" ); + assert.equal( ++counter, 1, "Queue/callback order: first called" ); setTimeout( next, 200 ); } ).delay( 100 ).queue( function( next ) { - equal( ++counter, 2, "Queue/callback order: second called" ); + assert.equal( ++counter, 2, "Queue/callback order: second called" ); jQuery( this ).delay( 100 ).queue( function( next ) { - equal( ++counter, 4, "Queue/callback order: fourth called" ); + assert.equal( ++counter, 4, "Queue/callback order: fourth called" ); next(); } ); next(); } ).queue( function( next ) { - equal( ++counter, 3, "Queue/callback order: third called" ); + assert.equal( ++counter, 3, "Queue/callback order: third called" ); next(); } ); div.promise( "fx" ).done( function() { - equal( counter, 4, "Deferreds resolved" ); - start(); + assert.equal( counter, 4, "Deferreds resolved" ); + QUnit.start(); } ); } ); -test( "delay()", function() { - expect( 2 ); - stop(); +QUnit.test( "delay()", function( assert ) { + assert.expect( 2 ); + QUnit.stop(); var foo = jQuery( {} ), run = 0; foo.delay( 100 ).queue( function() { run = 1; - ok( true, "The function was dequeued." ); - start(); + assert.ok( true, "The function was dequeued." ); + QUnit.start(); } ); - equal( run, 0, "The delay delayed the next function from running." ); + assert.equal( run, 0, "The delay delayed the next function from running." ); } ); -test( "clearQueue(name) clears the queue", function() { - expect( 2 ); +QUnit.test( "clearQueue(name) clears the queue", function( assert ) { + assert.expect( 2 ); - stop(); + QUnit.stop(); var div = jQuery( {} ), counter = 0; @@ -155,17 +155,17 @@ test( "clearQueue(name) clears the queue", function() { } ); div.promise( "foo" ).done( function() { - ok( true, "dequeue resolves the deferred" ); - start(); + assert.ok( true, "dequeue resolves the deferred" ); + QUnit.start(); } ); div.dequeue( "foo" ); - equal( counter, 1, "the queue was cleared" ); + assert.equal( counter, 1, "the queue was cleared" ); } ); -test( "clearQueue() clears the fx queue", function() { - expect( 1 ); +QUnit.test( "clearQueue() clears the fx queue", function( assert ) { + assert.expect( 1 ); var div = jQuery( {} ), counter = 0; @@ -178,52 +178,52 @@ test( "clearQueue() clears the fx queue", function() { counter++; } ); - equal( counter, 1, "the queue was cleared" ); + assert.equal( counter, 1, "the queue was cleared" ); div.removeData(); } ); -asyncTest( "fn.promise() - called when fx queue is empty", 3, function() { +QUnit.asyncTest( "fn.promise() - called when fx queue is empty", 3, function( assert ) { var foo = jQuery( "#foo" ).clone().addBack(), promised = false; foo.queue( function( next ) { // called twice! - ok( !promised, "Promised hasn't been called" ); + assert.ok( !promised, "Promised hasn't been called" ); setTimeout( next, 10 ); } ); foo.promise().done( function() { - ok( promised = true, "Promised" ); - start(); + assert.ok( promised = true, "Promised" ); + QUnit.start(); } ); } ); -asyncTest( "fn.promise( \"queue\" ) - called whenever last queue function is dequeued", 5, function() { +QUnit.asyncTest( "fn.promise( \"queue\" ) - called whenever last queue function is dequeued", 5, function( assert ) { var foo = jQuery( "#foo" ), test; foo.promise( "queue" ).done( function() { - strictEqual( test, undefined, "called immediately when queue was already empty" ); + assert.strictEqual( test, undefined, "called immediately when queue was already empty" ); } ); test = 1; foo.queue( "queue", function( next ) { - strictEqual( test++, 1, "step one" ); + assert.strictEqual( test++, 1, "step one" ); setTimeout( next, 0 ); } ).queue( "queue", function( next ) { - strictEqual( test++, 2, "step two" ); + assert.strictEqual( test++, 2, "step two" ); setTimeout( function() { next(); - strictEqual( test++, 4, "step four" ); - start(); + assert.strictEqual( test++, 4, "step four" ); + QUnit.start(); }, 10 ); } ).promise( "queue" ).done( function() { - strictEqual( test++, 3, "step three" ); + assert.strictEqual( test++, 3, "step three" ); } ); foo.dequeue( "queue" ); } ); -asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete before resolving", 2, function() { +QUnit.asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete before resolving", 2, function( assert ) { var foo = jQuery( "#foo" ), test = 1; @@ -233,43 +233,43 @@ asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete before res duration: 1, queue: "queue", complete: function() { - strictEqual( test++, 1, "step one" ); + assert.strictEqual( test++, 1, "step one" ); } } ).dequeue( "queue" ); foo.promise( "queue" ).done( function() { - strictEqual( test++, 2, "step two" ); - start(); + assert.strictEqual( test++, 2, "step two" ); + QUnit.start(); } ); } ); -test( ".promise(obj)", function() { - expect( 2 ); +QUnit.test( ".promise(obj)", function( assert ) { + assert.expect( 2 ); var obj = {}, promise = jQuery( "#foo" ).promise( "promise", obj ); - ok( jQuery.isFunction( promise.promise ), ".promise(type, obj) returns a promise" ); - strictEqual( promise, obj, ".promise(type, obj) returns obj" ); + assert.ok( jQuery.isFunction( promise.promise ), ".promise(type, obj) returns a promise" ); + assert.strictEqual( promise, obj, ".promise(type, obj) returns obj" ); } ); if ( jQuery.fn.stop ) { - test( "delay() can be stopped", function() { - expect( 3 ); - stop(); + QUnit.test( "delay() can be stopped", function( assert ) { + assert.expect( 3 ); + QUnit.stop(); var done = {}; jQuery( {} ) .queue( "alternate", function( next ) { done.alt1 = true; - ok( true, "This first function was dequeued" ); + assert.ok( true, "This first function was dequeued" ); next(); } ) .delay( 1000, "alternate" ) .queue( "alternate", function() { done.alt2 = true; - ok( true, "The function was dequeued immediately, the delay was stopped" ); + assert.ok( true, "The function was dequeued immediately, the delay was stopped" ); } ) .dequeue( "alternate" ) @@ -280,33 +280,33 @@ if ( jQuery.fn.stop ) { .delay( 1 ) .queue( function() { done.default1 = true; - ok( false, "This queue should never run" ); + assert.ok( false, "This queue should never run" ); } ) // stop( clearQueue ) should clear the queue .stop( true, false ); - deepEqual( done, { alt1: true, alt2: true }, "Queue ran the proper functions" ); + assert.deepEqual( done, { alt1: true, alt2: true }, "Queue ran the proper functions" ); setTimeout( function() { - start(); + QUnit.start(); }, 1500 ); } ); - asyncTest( "queue stop hooks", 2, function() { + QUnit.asyncTest( "queue stop hooks", 2, function( assert ) { var foo = jQuery( "#foo" ); foo.queue( function( next, hooks ) { hooks.stop = function( gotoEnd ) { - equal( !!gotoEnd, false, "Stopped without gotoEnd" ); + assert.equal( !!gotoEnd, false, "Stopped without gotoEnd" ); }; } ); foo.stop(); foo.queue( function( next, hooks ) { hooks.stop = function( gotoEnd ) { - equal( gotoEnd, true, "Stopped with gotoEnd" ); - start(); + assert.equal( gotoEnd, true, "Stopped with gotoEnd" ); + QUnit.start(); }; } ); diff --git a/test/unit/ready.js b/test/unit/ready.js index ee39dec9d..9c7ce74ff 100644 --- a/test/unit/ready.js +++ b/test/unit/ready.js @@ -1,4 +1,4 @@ -module( "event" ); +QUnit.module( "event" ); ( function() { var notYetReady, noEarlyExecution, @@ -7,11 +7,11 @@ module( "event" ); notYetReady = !jQuery.isReady; - test( "jQuery.isReady", function() { - expect( 2 ); + QUnit.test( "jQuery.isReady", function( assert ) { + assert.expect( 2 ); - equal( notYetReady, true, "jQuery.isReady should not be true before DOM ready" ); - equal( jQuery.isReady, true, "jQuery.isReady should be true once DOM is ready" ); + assert.equal( notYetReady, true, "jQuery.isReady should not be true before DOM ready" ); + assert.equal( jQuery.isReady, true, "jQuery.isReady should be true once DOM is ready" ); } ); // Create an event handler. @@ -37,20 +37,20 @@ module( "event" ); noEarlyExecution = order.length === 0; // This assumes that QUnit tests are run on DOM ready! - test( "jQuery ready", function() { - expect( 8 ); + QUnit.test( "jQuery ready", function( assert ) { + assert.expect( 8 ); - ok( noEarlyExecution, + assert.ok( noEarlyExecution, "Handlers bound to DOM ready should not execute before DOM ready" ); // Ensure execution order. - deepEqual( order, [ "a", "b", "c", "d" ], + assert.deepEqual( order, [ "a", "b", "c", "d" ], "Bound DOM ready handlers should execute in on-order" ); // Ensure handler argument is correct. - equal( args.a, jQuery, + assert.equal( args.a, jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery" ); - equal( args.b, jQuery, + assert.equal( args.b, jQuery, "Argument passed to fn in jQuery(document).ready( fn ) should be jQuery" ); order = []; @@ -58,12 +58,12 @@ module( "event" ); // Now that the ready event has fired, again bind to the ready event // in every possible way. These event handlers should execute immediately. jQuery( makeHandler( "g" ) ); - equal( order.pop(), "g", "Event handler should execute immediately" ); - equal( args.g, jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery" ); + assert.equal( order.pop(), "g", "Event handler should execute immediately" ); + assert.equal( args.g, jQuery, "Argument passed to fn in jQuery( fn ) should be jQuery" ); jQuery( document ).ready( makeHandler( "h" ) ); - equal( order.pop(), "h", "Event handler should execute immediately" ); - equal( args.h, jQuery, + assert.equal( order.pop(), "h", "Event handler should execute immediately" ); + assert.equal( args.h, jQuery, "Argument passed to fn in jQuery(document).ready( fn ) should be jQuery" ); } ); diff --git a/test/unit/selector.js b/test/unit/selector.js index c9afeb0dc..1c15a3df8 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -1,28 +1,28 @@ -module( "selector", { teardown: moduleTeardown } ); +QUnit.module( "selector", { teardown: moduleTeardown } ); /** * This test page is for selector tests that require jQuery in order to do the selection */ -test( "element - jQuery only", function() { - expect( 7 ); +QUnit.test( "element - jQuery only", function( assert ) { + assert.expect( 7 ); var fixture = document.getElementById( "qunit-fixture" ); - deepEqual( jQuery( "p", fixture ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a Node context." ); - deepEqual( jQuery( "p", "#qunit-fixture" ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a selector context." ); - deepEqual( jQuery( "p", jQuery( "#qunit-fixture" ) ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a jQuery object context." ); - deepEqual( jQuery( "#qunit-fixture" ).find( "p" ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a context via .find()." ); + assert.deepEqual( jQuery( "p", fixture ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a Node context." ); + assert.deepEqual( jQuery( "p", "#qunit-fixture" ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a selector context." ); + assert.deepEqual( jQuery( "p", jQuery( "#qunit-fixture" ) ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a jQuery object context." ); + assert.deepEqual( jQuery( "#qunit-fixture" ).find( "p" ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "Finding elements with a context via .find()." ); - ok( jQuery( "#length" ).length, "<input name=\"length\"> cannot be found under IE, see #945" ); - ok( jQuery( "#lengthtest input" ).length, "<input name=\"length\"> cannot be found under IE, see #945" ); + assert.ok( jQuery( "#length" ).length, "<input name=\"length\"> cannot be found under IE, see #945" ); + assert.ok( jQuery( "#lengthtest input" ).length, "<input name=\"length\"> cannot be found under IE, see #945" ); // #7533 - equal( jQuery( "<div id=\"A'B~C.D[E]\"><p>foo</p></div>" ).find( "p" ).length, 1, "Find where context root is a node and has an ID with CSS3 meta characters" ); + assert.equal( jQuery( "<div id=\"A'B~C.D[E]\"><p>foo</p></div>" ).find( "p" ).length, 1, "Find where context root is a node and has an ID with CSS3 meta characters" ); } ); -test( "id", function() { - expect( 26 ); +QUnit.test( "id", function( assert ) { + assert.expect( 26 ); var a; @@ -63,17 +63,17 @@ test( "id", function() { t( "ID with weird characters in it", "#name\\+value", [ "name+value" ] ); } ); -test( "class - jQuery only", function() { - expect( 4 ); +QUnit.test( "class - jQuery only", function( assert ) { + assert.expect( 4 ); - deepEqual( jQuery( ".blog", document.getElementsByTagName( "p" ) ).get(), q( "mark", "simon" ), "Finding elements with a context." ); - deepEqual( jQuery( ".blog", "p" ).get(), q( "mark", "simon" ), "Finding elements with a context." ); - deepEqual( jQuery( ".blog", jQuery( "p" ) ).get(), q( "mark", "simon" ), "Finding elements with a context." ); - deepEqual( jQuery( "p" ).find( ".blog" ).get(), q( "mark", "simon" ), "Finding elements with a context." ); + assert.deepEqual( jQuery( ".blog", document.getElementsByTagName( "p" ) ).get(), q( "mark", "simon" ), "Finding elements with a context." ); + assert.deepEqual( jQuery( ".blog", "p" ).get(), q( "mark", "simon" ), "Finding elements with a context." ); + assert.deepEqual( jQuery( ".blog", jQuery( "p" ) ).get(), q( "mark", "simon" ), "Finding elements with a context." ); + assert.deepEqual( jQuery( "p" ).find( ".blog" ).get(), q( "mark", "simon" ), "Finding elements with a context." ); } ); -test( "name", function() { - expect( 5 ); +QUnit.test( "name", function( assert ) { + assert.expect( 5 ); var form; @@ -84,24 +84,24 @@ test( "name", function() { t( "Name selector for grouped input", "input[name='types[]']", [ "types_all", "types_anime", "types_movie" ] ); form = jQuery( "<form><input name='id'/></form>" ).appendTo( "body" ); - equal( jQuery( "input", form[ 0 ] ).length, 1, "Make sure that rooted queries on forms (with possible expandos) work." ); + assert.equal( jQuery( "input", form[ 0 ] ).length, 1, "Make sure that rooted queries on forms (with possible expandos) work." ); form.remove(); } ); -test( "selectors with comma", function() { - expect( 4 ); +QUnit.test( "selectors with comma", function( assert ) { + assert.expect( 4 ); var fixture = jQuery( "<div><h2><span/></h2><div><p><span/></p><p/></div></div>" ); - equal( fixture.find( "h2, div p" ).filter( "p" ).length, 2, "has to find two <p>" ); - equal( fixture.find( "h2, div p" ).filter( "h2" ).length, 1, "has to find one <h2>" ); - equal( fixture.find( "h2 , div p" ).filter( "p" ).length, 2, "has to find two <p>" ); - equal( fixture.find( "h2 , div p" ).filter( "h2" ).length, 1, "has to find one <h2>" ); + assert.equal( fixture.find( "h2, div p" ).filter( "p" ).length, 2, "has to find two <p>" ); + assert.equal( fixture.find( "h2, div p" ).filter( "h2" ).length, 1, "has to find one <h2>" ); + assert.equal( fixture.find( "h2 , div p" ).filter( "p" ).length, 2, "has to find two <p>" ); + assert.equal( fixture.find( "h2 , div p" ).filter( "h2" ).length, 1, "has to find one <h2>" ); } ); -test( "child and adjacent", function() { - expect( 27 ); +QUnit.test( "child and adjacent", function( assert ) { + assert.expect( 27 ); var nothiddendiv; @@ -127,10 +127,10 @@ test( "child and adjacent", function() { t( "Multiple sibling combinators doesn't miss general siblings", "#siblingTest > em:first-child + em ~ span", [ "siblingspan" ] ); t( "Combinators are not skipped when mixing general and specific", "#siblingTest > em:contains('x') + em ~ span", [] ); - equal( jQuery( "#listWithTabIndex" ).length, 1, "Parent div for next test is found via ID (#8310)" ); - equal( jQuery( "#listWithTabIndex li:eq(2) ~ li" ).length, 1, "Find by general sibling combinator (#8310)" ); - equal( jQuery( "#__sizzle__" ).length, 0, "Make sure the temporary id assigned by sizzle is cleared out (#8310)" ); - equal( jQuery( "#listWithTabIndex" ).length, 1, "Parent div for previous test is still found via ID (#8310)" ); + assert.equal( jQuery( "#listWithTabIndex" ).length, 1, "Parent div for next test is found via ID (#8310)" ); + assert.equal( jQuery( "#listWithTabIndex li:eq(2) ~ li" ).length, 1, "Find by general sibling combinator (#8310)" ); + assert.equal( jQuery( "#__sizzle__" ).length, 0, "Make sure the temporary id assigned by sizzle is cleared out (#8310)" ); + assert.equal( jQuery( "#listWithTabIndex" ).length, 1, "Parent div for previous test is still found via ID (#8310)" ); t( "Verify deep class selector", "div.blah > p > a", [] ); @@ -141,8 +141,8 @@ test( "child and adjacent", function() { t( "Non-existant ancestors", ".fototab > .thumbnails > a", [] ); } ); -test( "attributes", function() { - expect( 54 ); +QUnit.test( "attributes", function( assert ) { + assert.expect( 54 ); var attrbad, div, withScript; @@ -221,7 +221,7 @@ test( "attributes", function() { t( "input[type=search]", "#form input[type=search]", [ "search" ] ); withScript = supportjQuery( "<div><span><script src=''/></span></div>" ); - ok( withScript.find( "#moretests script[src]" ).has( "script" ), "script[src] (jQuery #13777)" ); + assert.ok( withScript.find( "#moretests script[src]" ).has( "script" ), "script[src] (jQuery #13777)" ); div = document.getElementById( "foo" ); t( "Object.prototype property \"constructor\" (negative)", "[constructor]", [] ); @@ -234,159 +234,163 @@ test( "attributes", function() { t( "Value attribute is retrieved correctly", "input[value=Test]", [ "text1", "text2" ] ); // #12600 - ok( + assert.ok( jQuery( "<select value='12600'><option value='option' selected='selected'></option><option value=''></option></select>" ) .prop( "value", "option" ) .is( ":input[value='12600']" ), ":input[value=foo] selects select by attribute" ); - ok( jQuery( "<input type='text' value='12600'/>" ).prop( "value", "option" ).is( ":input[value='12600']" ), + assert.ok( jQuery( "<input type='text' value='12600'/>" ).prop( "value", "option" ).is( ":input[value='12600']" ), ":input[value=foo] selects text input by attribute" ); // #11115 - ok( jQuery( "<input type='checkbox' checked='checked'/>" ).prop( "checked", false ).is( "[checked]" ), + assert.ok( jQuery( "<input type='checkbox' checked='checked'/>" ).prop( "checked", false ).is( "[checked]" ), "[checked] selects by attribute (positive)" ); - ok( !jQuery( "<input type='checkbox'/>" ).prop( "checked", true ).is( "[checked]" ), + assert.ok( !jQuery( "<input type='checkbox'/>" ).prop( "checked", true ).is( "[checked]" ), "[checked] selects by attribute (negative)" ); } ); -test( "disconnected nodes", function() { - expect( 1 ); +QUnit.test( "disconnected nodes", function( assert ) { + assert.expect( 1 ); var $div = jQuery( "<div/>" ); - equal( $div.is( "div" ), true, "Make sure .is('nodeName') works on disconnected nodes." ); + assert.equal( $div.is( "div" ), true, "Make sure .is('nodeName') works on disconnected nodes." ); } ); -test( "disconnected nodes - jQuery only", function() { - expect( 3 ); +QUnit.test( "disconnected nodes - jQuery only", function( assert ) { + assert.expect( 3 ); var $opt = jQuery( "<option></option>" ).attr( "value", "whipit" ).appendTo( "#qunit-fixture" ).detach(); - equal( $opt.val(), "whipit", "option value" ); - equal( $opt.is( ":selected" ), false, "unselected option" ); + assert.equal( $opt.val(), "whipit", "option value" ); + assert.equal( $opt.is( ":selected" ), false, "unselected option" ); $opt.prop( "selected", true ); - equal( $opt.is( ":selected" ), true, "selected option" ); + assert.equal( $opt.is( ":selected" ), true, "selected option" ); } ); -testIframe( "selector/html5_selector", "attributes - jQuery.attr", function( jQuery, window, document ) { - expect( 37 ); - - /** - * Returns an array of elements with the given IDs - * q & t are added here for the iFrame's context - */ - function q() { - var r = [], - i = 0; - - for ( ; i < arguments.length; i++ ) { - r.push( document.getElementById( arguments[ i ] ) ); +testIframe( + "selector/html5_selector", + "attributes - jQuery.attr", + function( jQuery, window, document, assert ) { + assert.expect( 37 ); + + /** + * Returns an array of elements with the given IDs + * q & t are added here for the iFrame's context + */ + function q() { + var r = [], + i = 0; + + for ( ; i < arguments.length; i++ ) { + r.push( document.getElementById( arguments[ i ] ) ); + } + return r; } - return r; - } - /** - * Asserts that a select matches the given IDs - * @example t("Check for something", "//[a]", ["foo", "baar"]); - * @param {String} a - Assertion name - * @param {String} b - Sizzle selector - * @param {Array} c - Array of ids to construct what is expected - */ - function t( a, b, c ) { - var f = jQuery( b ).get(), - s = "", - i = 0; - - for ( ; i < f.length; i++ ) { - s += ( s && "," ) + "'" + f[ i ].id + "'"; + /** + * Asserts that a select matches the given IDs + * @example t("Check for something", "//[a]", ["foo", "baar"]); + * @param {String} a - Assertion name + * @param {String} b - Sizzle selector + * @param {Array} c - Array of ids to construct what is expected + */ + function t( a, b, c ) { + var f = jQuery( b ).get(), + s = "", + i = 0; + + for ( ; i < f.length; i++ ) { + s += ( s && "," ) + "'" + f[ i ].id + "'"; + } + + assert.deepEqual( f, q.apply( q, c ), a + " (" + b + ")" ); } - deepEqual( f, q.apply( q, c ), a + " (" + b + ")" ); + // ====== All known boolean attributes, including html5 booleans ====== + // autobuffer, autofocus, autoplay, async, checked, + // compact, controls, declare, defer, disabled, + // formnovalidate, hidden, indeterminate (property only), + // ismap, itemscope, loop, multiple, muted, nohref, noresize, + // noshade, nowrap, novalidate, open, pubdate, readonly, required, + // reversed, scoped, seamless, selected, truespeed, visible (skipping visible attribute, which is on a barprop object) + + t( "Attribute Exists", "[autobuffer]", [ "video1" ] ); + t( "Attribute Exists", "[autofocus]", [ "text1" ] ); + t( "Attribute Exists", "[autoplay]", [ "video1" ] ); + t( "Attribute Exists", "[async]", [ "script1" ] ); + t( "Attribute Exists", "[checked]", [ "check1" ] ); + t( "Attribute Exists", "[compact]", [ "dl" ] ); + t( "Attribute Exists", "[controls]", [ "video1" ] ); + t( "Attribute Exists", "[declare]", [ "object1" ] ); + t( "Attribute Exists", "[defer]", [ "script1" ] ); + t( "Attribute Exists", "[disabled]", [ "check1" ] ); + t( "Attribute Exists", "[formnovalidate]", [ "form1" ] ); + t( "Attribute Exists", "[hidden]", [ "div1" ] ); + t( "Attribute Exists", "[indeterminate]", [] ); + t( "Attribute Exists", "[ismap]", [ "img1" ] ); + t( "Attribute Exists", "[itemscope]", [ "div1" ] ); + t( "Attribute Exists", "[loop]", [ "video1" ] ); + t( "Attribute Exists", "[multiple]", [ "select1" ] ); + t( "Attribute Exists", "[muted]", [ "audio1" ] ); + t( "Attribute Exists", "[nohref]", [ "area1" ] ); + t( "Attribute Exists", "[noresize]", [ "textarea1" ] ); + t( "Attribute Exists", "[noshade]", [ "hr1" ] ); + t( "Attribute Exists", "[nowrap]", [ "td1", "div1" ] ); + t( "Attribute Exists", "[novalidate]", [ "form1" ] ); + t( "Attribute Exists", "[open]", [ "details1" ] ); + t( "Attribute Exists", "[pubdate]", [ "article1" ] ); + t( "Attribute Exists", "[readonly]", [ "text1" ] ); + t( "Attribute Exists", "[required]", [ "text1" ] ); + t( "Attribute Exists", "[reversed]", [ "ol1" ] ); + t( "Attribute Exists", "[scoped]", [ "style1" ] ); + t( "Attribute Exists", "[seamless]", [ "iframe1" ] ); + t( "Attribute Exists", "[selected]", [ "option1" ] ); + t( "Attribute Exists", "[truespeed]", [ "marquee1" ] ); + + // Enumerated attributes (these are not boolean content attributes) + jQuery.expandedEach = jQuery.each; + jQuery.expandedEach( [ "draggable", "contenteditable", "aria-disabled" ], function( i, val ) { + t( "Enumerated attribute", "[" + val + "]", [ "div1" ] ); + } ); + t( "Enumerated attribute", "[spellcheck]", [ "span1" ] ); + + // t( "tabindex selector does not retrieve all elements in IE6/7(#8473)", "form, [tabindex]", ["form1", "text1"] ); // sigh, FF12 QSA mistakenly includes video elements even though they have no tabindex attribute (see https://bugzilla.mozilla.org/show_bug.cgi?id=618737) + t( "Improperly named form elements do not interfere with form selections (#9570)", "form[name='formName']", [ "form1" ] ); } +); - // ====== All known boolean attributes, including html5 booleans ====== - // autobuffer, autofocus, autoplay, async, checked, - // compact, controls, declare, defer, disabled, - // formnovalidate, hidden, indeterminate (property only), - // ismap, itemscope, loop, multiple, muted, nohref, noresize, - // noshade, nowrap, novalidate, open, pubdate, readonly, required, - // reversed, scoped, seamless, selected, truespeed, visible (skipping visible attribute, which is on a barprop object) - - t( "Attribute Exists", "[autobuffer]", [ "video1" ] ); - t( "Attribute Exists", "[autofocus]", [ "text1" ] ); - t( "Attribute Exists", "[autoplay]", [ "video1" ] ); - t( "Attribute Exists", "[async]", [ "script1" ] ); - t( "Attribute Exists", "[checked]", [ "check1" ] ); - t( "Attribute Exists", "[compact]", [ "dl" ] ); - t( "Attribute Exists", "[controls]", [ "video1" ] ); - t( "Attribute Exists", "[declare]", [ "object1" ] ); - t( "Attribute Exists", "[defer]", [ "script1" ] ); - t( "Attribute Exists", "[disabled]", [ "check1" ] ); - t( "Attribute Exists", "[formnovalidate]", [ "form1" ] ); - t( "Attribute Exists", "[hidden]", [ "div1" ] ); - t( "Attribute Exists", "[indeterminate]", [] ); - t( "Attribute Exists", "[ismap]", [ "img1" ] ); - t( "Attribute Exists", "[itemscope]", [ "div1" ] ); - t( "Attribute Exists", "[loop]", [ "video1" ] ); - t( "Attribute Exists", "[multiple]", [ "select1" ] ); - t( "Attribute Exists", "[muted]", [ "audio1" ] ); - t( "Attribute Exists", "[nohref]", [ "area1" ] ); - t( "Attribute Exists", "[noresize]", [ "textarea1" ] ); - t( "Attribute Exists", "[noshade]", [ "hr1" ] ); - t( "Attribute Exists", "[nowrap]", [ "td1", "div1" ] ); - t( "Attribute Exists", "[novalidate]", [ "form1" ] ); - t( "Attribute Exists", "[open]", [ "details1" ] ); - t( "Attribute Exists", "[pubdate]", [ "article1" ] ); - t( "Attribute Exists", "[readonly]", [ "text1" ] ); - t( "Attribute Exists", "[required]", [ "text1" ] ); - t( "Attribute Exists", "[reversed]", [ "ol1" ] ); - t( "Attribute Exists", "[scoped]", [ "style1" ] ); - t( "Attribute Exists", "[seamless]", [ "iframe1" ] ); - t( "Attribute Exists", "[selected]", [ "option1" ] ); - t( "Attribute Exists", "[truespeed]", [ "marquee1" ] ); - - // Enumerated attributes (these are not boolean content attributes) - jQuery.expandedEach = jQuery.each; - jQuery.expandedEach( [ "draggable", "contenteditable", "aria-disabled" ], function( i, val ) { - t( "Enumerated attribute", "[" + val + "]", [ "div1" ] ); - } ); - t( "Enumerated attribute", "[spellcheck]", [ "span1" ] ); - - // t( "tabindex selector does not retrieve all elements in IE6/7(#8473)", "form, [tabindex]", ["form1", "text1"] ); // sigh, FF12 QSA mistakenly includes video elements even though they have no tabindex attribute (see https://bugzilla.mozilla.org/show_bug.cgi?id=618737) - t( "Improperly named form elements do not interfere with form selections (#9570)", "form[name='formName']", [ "form1" ] ); -} ); - -test( "jQuery.contains", function() { - expect( 16 ); +QUnit.test( "jQuery.contains", function( assert ) { + assert.expect( 16 ); var container = document.getElementById( "nonnodes" ), element = container.firstChild, text = element.nextSibling, nonContained = container.nextSibling, detached = document.createElement( "a" ); - ok( element && element.nodeType === 1, "preliminary: found element" ); - ok( text && text.nodeType === 3, "preliminary: found text" ); - ok( nonContained, "preliminary: found non-descendant" ); - ok( jQuery.contains( container, element ), "child" ); - ok( jQuery.contains( container.parentNode, element ), "grandchild" ); - ok( jQuery.contains( container, text ), "text child" ); - ok( jQuery.contains( container.parentNode, text ), "text grandchild" ); - ok( !jQuery.contains( container, container ), "self" ); - ok( !jQuery.contains( element, container ), "parent" ); - ok( !jQuery.contains( container, nonContained ), "non-descendant" ); - ok( !jQuery.contains( container, document ), "document" ); - ok( !jQuery.contains( container, document.documentElement ), "documentElement (negative)" ); - ok( !jQuery.contains( container, null ), "Passing null does not throw an error" ); - ok( jQuery.contains( document, document.documentElement ), "documentElement (positive)" ); - ok( jQuery.contains( document, element ), "document container (positive)" ); - ok( !jQuery.contains( document, detached ), "document container (negative)" ); + assert.ok( element && element.nodeType === 1, "preliminary: found element" ); + assert.ok( text && text.nodeType === 3, "preliminary: found text" ); + assert.ok( nonContained, "preliminary: found non-descendant" ); + assert.ok( jQuery.contains( container, element ), "child" ); + assert.ok( jQuery.contains( container.parentNode, element ), "grandchild" ); + assert.ok( jQuery.contains( container, text ), "text child" ); + assert.ok( jQuery.contains( container.parentNode, text ), "text grandchild" ); + assert.ok( !jQuery.contains( container, container ), "self" ); + assert.ok( !jQuery.contains( element, container ), "parent" ); + assert.ok( !jQuery.contains( container, nonContained ), "non-descendant" ); + assert.ok( !jQuery.contains( container, document ), "document" ); + assert.ok( !jQuery.contains( container, document.documentElement ), "documentElement (negative)" ); + assert.ok( !jQuery.contains( container, null ), "Passing null does not throw an error" ); + assert.ok( jQuery.contains( document, document.documentElement ), "documentElement (positive)" ); + assert.ok( jQuery.contains( document, element ), "document container (positive)" ); + assert.ok( !jQuery.contains( document, detached ), "document container (negative)" ); } ); -test( "jQuery.uniqueSort", function() { - expect( 15 ); +QUnit.test( "jQuery.uniqueSort", function( assert ) { + assert.expect( 15 ); function Arrayish( arr ) { var i = this.length = arr.length; @@ -459,24 +463,28 @@ test( "jQuery.uniqueSort", function() { jQuery.each( tests, function( label, test ) { var length = test.length || test.input.length; - deepEqual( jQuery.uniqueSort( test.input ).slice( 0, length ), test.expected, label + " (array)" ); - deepEqual( jQuery.uniqueSort( new Arrayish( test.input ) ).slice( 0, length ), test.expected, label + " (quasi-array)" ); + assert.deepEqual( jQuery.uniqueSort( test.input ).slice( 0, length ), test.expected, label + " (array)" ); + assert.deepEqual( jQuery.uniqueSort( new Arrayish( test.input ) ).slice( 0, length ), test.expected, label + " (quasi-array)" ); } ); - strictEqual( jQuery.unique, jQuery.uniqueSort, "jQuery.unique() is an alias for jQuery.uniqueSort()" ); + assert.strictEqual( jQuery.unique, jQuery.uniqueSort, "jQuery.unique() is an alias for jQuery.uniqueSort()" ); } ); -testIframe( "selector/sizzle_cache", "Sizzle cache collides with multiple Sizzles on a page", function( jQuery, window, document ) { - var $cached = window[ "$cached" ]; - - expect( 4 ); - notStrictEqual( jQuery, $cached, "Loaded two engines" ); - deepEqual( $cached( ".test a" ).get(), [ document.getElementById( "collision" ) ], "Select collision anchor with first sizzle" ); - equal( jQuery( ".evil a" ).length, 0, "Select nothing with second sizzle" ); - equal( jQuery( ".evil a" ).length, 0, "Select nothing again with second sizzle" ); -} ); +testIframe( + "selector/sizzle_cache", + "Sizzle cache collides with multiple Sizzles on a page", + function( jQuery, window, document, assert ) { + var $cached = window[ "$cached" ]; + + assert.expect( 4 ); + assert.notStrictEqual( jQuery, $cached, "Loaded two engines" ); + assert.deepEqual( $cached( ".test a" ).get(), [ document.getElementById( "collision" ) ], "Select collision anchor with first sizzle" ); + assert.equal( jQuery( ".evil a" ).length, 0, "Select nothing with second sizzle" ); + assert.equal( jQuery( ".evil a" ).length, 0, "Select nothing again with second sizzle" ); + } +); -asyncTest( "Iframe dispatch should not affect jQuery (#13936)", 1, function() { +QUnit.asyncTest( "Iframe dispatch should not affect jQuery (#13936)", 1, function( assert ) { var loaded = false, thrown = false, iframe = document.getElementById( "iframe" ), @@ -493,12 +501,12 @@ asyncTest( "Iframe dispatch should not affect jQuery (#13936)", 1, function() { } if ( loaded ) { - strictEqual( thrown, false, "No error thrown from post-reload jQuery call" ); + assert.strictEqual( thrown, false, "No error thrown from post-reload jQuery call" ); // clean up jQuery( iframe ).off(); - start(); + QUnit.start(); } else { loaded = true; form.submit(); diff --git a/test/unit/serialize.js b/test/unit/serialize.js index d3def19a1..047861530 100644 --- a/test/unit/serialize.js +++ b/test/unit/serialize.js @@ -1,43 +1,43 @@ -module( "serialize", { teardown: moduleTeardown } ); +QUnit.module( "serialize", { teardown: moduleTeardown } ); -test( "jQuery.param()", function() { - expect( 22 ); +QUnit.test( "jQuery.param()", function( assert ) { + assert.expect( 22 ); var params, settings; - equal( !( jQuery.ajaxSettings && jQuery.ajaxSettings.traditional ), true, "traditional flag, falsy by default" ); + assert.equal( !( jQuery.ajaxSettings && jQuery.ajaxSettings.traditional ), true, "traditional flag, falsy by default" ); params = { "foo":"bar", "baz":42, "quux":"All your base are belong to us" }; - equal( jQuery.param( params ), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" ); + assert.equal( jQuery.param( params ), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" ); params = { "string":"foo","null":null,"undefined":undefined }; - equal( jQuery.param( params ), "string=foo&null=&undefined=", "handle nulls and undefineds properly" ); + assert.equal( jQuery.param( params ), "string=foo&null=&undefined=", "handle nulls and undefineds properly" ); params = { "someName": [ 1, 2, 3 ], "regularThing": "blah" }; - equal( jQuery.param( params ), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" ); + assert.equal( jQuery.param( params ), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" ); params = { "foo": [ "a", "b", "c" ] }; - equal( jQuery.param( params ), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" ); + assert.equal( jQuery.param( params ), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" ); params = { "foo": [ "baz", 42, "All your base are belong to us" ] }; - equal( jQuery.param( params ), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" ); + assert.equal( jQuery.param( params ), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" ); params = { "foo": { "bar": "baz", "beep": 42, "quux": "All your base are belong to us" } }; - equal( jQuery.param( params ), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); + assert.equal( jQuery.param( params ), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); params = { a:[ 1,2 ], b:{ c:3, d:[ 4,5 ], e:{ x:[ 6 ], y:7, z:[ 8,9 ] }, f:true, g:false, h:undefined }, i:[ 10,11 ], j:true, k:false, l:[ undefined,0 ], m:"cowboy hat?" }; - equal( decodeURIComponent( jQuery.param( params ) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure" ); + assert.equal( decodeURIComponent( jQuery.param( params ) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure" ); params = { "a": [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { "b": [ 7, [ 8, 9 ], [ { "c": 10, "d": 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { "e": { "f": { "g": [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] }; - equal( decodeURIComponent( jQuery.param( params ) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" ); + assert.equal( decodeURIComponent( jQuery.param( params ) ), "a[]=0&a[1][]=1&a[1][]=2&a[2][]=3&a[2][1][]=4&a[2][1][]=5&a[2][2][]=6&a[3][b][]=7&a[3][b][1][]=8&a[3][b][1][]=9&a[3][b][2][0][c]=10&a[3][b][2][0][d]=11&a[3][b][3][0][]=12&a[3][b][4][0][0][]=13&a[3][b][5][e][f][g][]=14&a[3][b][5][e][f][g][1][]=15&a[3][b][]=16&a[]=17", "nested arrays" ); params = { "a":[ 1,2 ], "b":{ "c":3, "d":[ 4,5 ], "e":{ "x":[ 6 ], "y":7, "z":[ 8,9 ] }, "f":true, "g":false, "h":undefined }, "i":[ 10,11 ], "j":true, "k":false, "l":[ undefined,0 ], "m":"cowboy hat?" }; - equal( jQuery.param( params, true ), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" ); + assert.equal( jQuery.param( params, true ), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" ); - equal( decodeURIComponent( jQuery.param( { "a": [ 1,2,3 ], "b[]": [ 4,5,6 ], "c[d]": [ 7,8,9 ], "e": { "f": [ 10 ], "g": [ 11,12 ], "h": 13 } } ) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." ); + assert.equal( decodeURIComponent( jQuery.param( { "a": [ 1,2,3 ], "b[]": [ 4,5,6 ], "c[d]": [ 7,8,9 ], "e": { "f": [ 10 ], "g": [ 11,12 ], "h": 13 } } ) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." ); // #7945 - equal( jQuery.param( { "jquery": "1.4.2" } ), "jquery=1.4.2", "Check that object with a jQuery property get serialized correctly" ); + assert.equal( jQuery.param( { "jquery": "1.4.2" } ), "jquery=1.4.2", "Check that object with a jQuery property get serialized correctly" ); settings = { traditional: true }; @@ -48,34 +48,34 @@ test( "jQuery.param()", function() { } params = { "foo":"bar", "baz":42, "quux":"All your base are belong to us" }; - equal( jQuery.param( params ), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" ); + assert.equal( jQuery.param( params ), "foo=bar&baz=42&quux=All+your+base+are+belong+to+us", "simple" ); params = { "someName": [ 1, 2, 3 ], "regularThing": "blah" }; - equal( jQuery.param( params ), "someName=1&someName=2&someName=3®ularThing=blah", "with array" ); + assert.equal( jQuery.param( params ), "someName=1&someName=2&someName=3®ularThing=blah", "with array" ); params = { "foo": [ "a", "b", "c" ] }; - equal( jQuery.param( params ), "foo=a&foo=b&foo=c", "with array of strings" ); + assert.equal( jQuery.param( params ), "foo=a&foo=b&foo=c", "with array of strings" ); params = { "foo[]":[ "baz", 42, "All your base are belong to us" ] }; - equal( jQuery.param( params ), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" ); + assert.equal( jQuery.param( params ), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" ); params = { "foo[bar]":"baz", "foo[beep]":42, "foo[quux]":"All your base are belong to us" }; - equal( jQuery.param( params ), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); + assert.equal( jQuery.param( params ), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); params = { a:[ 1,2 ], b:{ c:3, d:[ 4,5 ], e:{ x:[ 6 ], y:7, z:[ 8,9 ] }, f:true, g:false, h:undefined }, i:[ 10,11 ], j:true, k:false, l:[ undefined,0 ], m:"cowboy hat?" }; - equal( jQuery.param( params ), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure" ); + assert.equal( jQuery.param( params ), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=&l=0&m=cowboy+hat%3F", "huge structure" ); params = { "a": [ 0, [ 1, 2 ], [ 3, [ 4, 5 ], [ 6 ] ], { "b": [ 7, [ 8, 9 ], [ { "c": 10, d: 11 } ], [ [ 12 ] ], [ [ [ 13 ] ] ], { "e": { "f": { "g": [ 14, [ 15 ] ] } } }, 16 ] }, 17 ] }; - equal( jQuery.param( params ), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" ); + assert.equal( jQuery.param( params ), "a=0&a=1%2C2&a=3%2C4%2C5%2C6&a=%5Bobject+Object%5D&a=17", "nested arrays (not possible when jQuery.param.traditional == true)" ); params = { a:[ 1,2 ], b:{ c:3, d:[ 4,5 ], e:{ x:[ 6 ], y:7, z:[ 8,9 ] }, f:true, g:false, h:undefined }, i:[ 10,11 ], j:true, k:false, l:[ undefined,0 ], m:"cowboy hat?" }; - equal( decodeURIComponent( jQuery.param( params, false ) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" ); + assert.equal( decodeURIComponent( jQuery.param( params, false ) ), "a[]=1&a[]=2&b[c]=3&b[d][]=4&b[d][]=5&b[e][x][]=6&b[e][y]=7&b[e][z][]=8&b[e][z][]=9&b[f]=true&b[g]=false&b[h]=&i[]=10&i[]=11&j=true&k=false&l[]=&l[]=0&m=cowboy+hat?", "huge structure, forced not traditional" ); params = { "param1": null }; - equal( jQuery.param( params, false ), "param1=", "Make sure that null params aren't traversed." ); + assert.equal( jQuery.param( params, false ), "param1=", "Make sure that null params aren't traversed." ); params = { "test": { "length": 3, "foo": "bar" } }; - equal( jQuery.param( params, false ), "test%5Blength%5D=3&test%5Bfoo%5D=bar", "Sub-object with a length property" ); + assert.equal( jQuery.param( params, false ), "test%5Blength%5D=3&test%5Bfoo%5D=bar", "Sub-object with a length property" ); if ( jQuery.ajaxSettings === settings ) { delete jQuery.ajaxSettings; @@ -84,8 +84,8 @@ test( "jQuery.param()", function() { } } ); -test( "jQuery.param() Constructed prop values", function() { - expect( 4 ); +QUnit.test( "jQuery.param() Constructed prop values", function( assert ) { + assert.expect( 4 ); /** @constructor */ function Record() { @@ -96,21 +96,21 @@ test( "jQuery.param() Constructed prop values", function() { MyNumber = Number, params = { "test": new MyString( "foo" ) }; - equal( jQuery.param( params, false ), "test=foo", "Do not mistake new String() for a plain object" ); + assert.equal( jQuery.param( params, false ), "test=foo", "Do not mistake new String() for a plain object" ); params = { "test": new MyNumber( 5 ) }; - equal( jQuery.param( params, false ), "test=5", "Do not mistake new Number() for a plain object" ); + assert.equal( jQuery.param( params, false ), "test=5", "Do not mistake new Number() for a plain object" ); params = { "test": new Date() }; - ok( jQuery.param( params, false ), "(Non empty string returned) Do not mistake new Date() for a plain object" ); + assert.ok( jQuery.param( params, false ), "(Non empty string returned) Do not mistake new Date() for a plain object" ); // should allow non-native constructed objects params = { "test": new Record() }; - equal( jQuery.param( params, false ), jQuery.param( { "test": { "prop": "val" } } ), "Allow non-native constructed objects" ); + assert.equal( jQuery.param( params, false ), jQuery.param( { "test": { "prop": "val" } } ), "Allow non-native constructed objects" ); } ); -test( "serialize()", function() { - expect( 6 ); +QUnit.test( "serialize()", function( assert ) { + assert.expect( 6 ); // Add html5 elements only for serialize because selector can't yet find them on non-html5 browsers jQuery( "#search" ).after( @@ -119,27 +119,27 @@ test( "serialize()", function() { "<input type='file' name='fileupload' />" ); - equal( jQuery( "#form" ).serialize(), + assert.equal( jQuery( "#form" ).serialize(), "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3", "Check form serialization as query string" ); - equal( jQuery( "input,select,textarea,button", "#form" ).serialize(), + assert.equal( jQuery( "input,select,textarea,button", "#form" ).serialize(), "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3", "Check input serialization as query string" ); - equal( jQuery( "#testForm" ).serialize(), + assert.equal( jQuery( "#testForm" ).serialize(), "T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", "Check form serialization as query string" ); - equal( jQuery( "input,select,textarea,button", "#testForm" ).serialize(), + assert.equal( jQuery( "input,select,textarea,button", "#testForm" ).serialize(), "T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", "Check input serialization as query string" ); - equal( jQuery( "#form, #testForm" ).serialize(), + assert.equal( jQuery( "#form, #testForm" ).serialize(), "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", "Multiple form serialization as query string" ); - equal( jQuery( "#form, #testForm :input" ).serialize(), + assert.equal( jQuery( "#form, #testForm :input" ).serialize(), "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", "Mixed form/input serialization as query string" ); jQuery( "#html5email, #html5number" ).remove(); diff --git a/test/unit/support.js b/test/unit/support.js index 80242257e..6d97fa6f8 100644 --- a/test/unit/support.js +++ b/test/unit/support.js @@ -1,4 +1,4 @@ -module( "support", { teardown: moduleTeardown } ); +QUnit.module( "support", { teardown: moduleTeardown } ); function getComputedSupport( support ) { var prop, @@ -17,48 +17,56 @@ function getComputedSupport( support ) { var computedSupport = getComputedSupport( jQuery.support ); -test( "zoom of doom (#13089)", function() { - expect( 1 ); +QUnit.test( "zoom of doom (#13089)", function( assert ) { + assert.expect( 1 ); - ok( !document.body.style.zoom, "No zoom added to the body" ); + assert.ok( !document.body.style.zoom, "No zoom added to the body" ); } ); if ( jQuery.css ) { - testIframeWithCallback( "body background is not lost if set prior to loading jQuery (#9239)", "support/bodyBackground.html", function( color, support ) { - expect( 2 ); - var okValue = { - "#000000": true, - "rgb(0, 0, 0)": true - }; - ok( okValue[ color ], "color was not reset (" + color + ")" ); + testIframeWithCallback( + "body background is not lost if set prior to loading jQuery (#9239)", + "support/bodyBackground.html", + function( color, support, assert ) { + assert.expect( 2 ); + var okValue = { + "#000000": true, + "rgb(0, 0, 0)": true + }; + assert.ok( okValue[ color ], "color was not reset (" + color + ")" ); - stop(); + QUnit.stop(); - // Run doc ready tests as well - jQuery( function() { - deepEqual( jQuery.extend( {}, support ), computedSupport, "Same support properties" ); - start(); - } ); - } ); + // Run doc ready tests as well + jQuery( function() { + assert.deepEqual( jQuery.extend( {}, support ), computedSupport, "Same support properties" ); + QUnit.start(); + } ); + } + ); } -testIframeWithCallback( "A background on the testElement does not cause IE8 to crash (#9823)", "support/testElementCrash.html", function() { - expect( 1 ); - ok( true, "IE8 does not crash" ); -} ); +testIframeWithCallback( + "A background on the testElement does not cause IE8 to crash (#9823)", + "support/testElementCrash.html", function( assert ) { + assert.expect( 1 ); + assert.ok( true, "IE8 does not crash" ); + } +); // This test checks CSP only for browsers with "Content-Security-Policy" header support // i.e. no old WebKit or old Firefox -testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions", +testIframeWithCallback( + "Check CSP (https://developer.mozilla.org/en-US/docs/Security/CSP) restrictions", "support/csp.php", - function( support ) { - expect( 2 ); - deepEqual( jQuery.extend( {}, support ), computedSupport, "No violations of CSP polices" ); + function( support, assert ) { + assert.expect( 2 ); + assert.deepEqual( jQuery.extend( {}, support ), computedSupport, "No violations of CSP polices" ); - stop(); + QUnit.stop(); supportjQuery.get( "data/support/csp.log" ).done( function( data ) { - equal( data, "", "No log request should be sent" ); + assert.equal( data, "", "No log request should be sent" ); supportjQuery.get( "data/support/csp-clean.php" ).done( start ); } ); } @@ -470,7 +478,7 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec } if ( expected ) { - test( "Verify that the support tests resolve as expected per browser", function() { + QUnit.test( "Verify that the support tests resolve as expected per browser", function( assert ) { var i, prop, j = 0; @@ -478,15 +486,15 @@ testIframeWithCallback( "Check CSP (https://developer.mozilla.org/en-US/docs/Sec j++; } - expect( j ); + assert.expect( j ); for ( i in expected ) { if ( jQuery.ajax || i !== "ajax" && i !== "cors" ) { - equal( computedSupport[ i ], expected[ i ], + assert.equal( computedSupport[ i ], expected[ i ], "jQuery.support['" + i + "']: " + computedSupport[ i ] + ", expected['" + i + "']: " + expected[ i ] ); } else { - ok( true, "no ajax; skipping jQuery.support['" + i + "']" ); + assert.ok( true, "no ajax; skipping jQuery.support['" + i + "']" ); } } } ); diff --git a/test/unit/traversing.js b/test/unit/traversing.js index b5ccf6d35..5d30f85b1 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -1,30 +1,30 @@ -module( "traversing", { teardown: moduleTeardown } ); +QUnit.module( "traversing", { teardown: moduleTeardown } ); -test( "find(String)", function() { - expect( 1 ); - equal( jQuery( "#foo" ).find( ".blogTest" ).text(), "Yahoo", "Basic selector" ); +QUnit.test( "find(String)", function( assert ) { + assert.expect( 1 ); + assert.equal( jQuery( "#foo" ).find( ".blogTest" ).text(), "Yahoo", "Basic selector" ); } ); -test( "find(String) under non-elements", function() { - expect( 2 ); +QUnit.test( "find(String) under non-elements", function( assert ) { + assert.expect( 2 ); var j = jQuery( "#nonnodes" ).contents(); - equal( j.find( "div" ).length, 0, "Check node,textnode,comment to find zero divs" ); - equal( j.find( "div" ).addBack().length, 3, "Check node,textnode,comment to find zero divs, but preserves pushStack" ); + assert.equal( j.find( "div" ).length, 0, "Check node,textnode,comment to find zero divs" ); + assert.equal( j.find( "div" ).addBack().length, 3, "Check node,textnode,comment to find zero divs, but preserves pushStack" ); } ); -test( "find(leading combinator)", function() { - expect( 4 ); +QUnit.test( "find(leading combinator)", function( assert ) { + assert.expect( 4 ); - deepEqual( jQuery( "#qunit-fixture" ).find( "> div" ).get(), q( "foo", "nothiddendiv", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest", "fx-test-group" ), "find child elements" ); - deepEqual( jQuery( "#qunit-fixture" ).find( "> #foo, > #moretests" ).get(), q( "foo", "moretests" ), "find child elements" ); - deepEqual( jQuery( "#qunit-fixture" ).find( "> #foo > p" ).get(), q( "sndp", "en", "sap" ), "find child elements" ); + assert.deepEqual( jQuery( "#qunit-fixture" ).find( "> div" ).get(), q( "foo", "nothiddendiv", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest", "fx-test-group" ), "find child elements" ); + assert.deepEqual( jQuery( "#qunit-fixture" ).find( "> #foo, > #moretests" ).get(), q( "foo", "moretests" ), "find child elements" ); + assert.deepEqual( jQuery( "#qunit-fixture" ).find( "> #foo > p" ).get(), q( "sndp", "en", "sap" ), "find child elements" ); - deepEqual( jQuery( "#siblingTest, #siblingfirst" ).find( "+ *" ).get(), q( "siblingnext", "fx-test-group" ), "ensure document order" ); + assert.deepEqual( jQuery( "#siblingTest, #siblingfirst" ).find( "+ *" ).get(), q( "siblingnext", "fx-test-group" ), "ensure document order" ); } ); -test( "find(node|jQuery object)", function() { - expect( 13 ); +QUnit.test( "find(node|jQuery object)", function( assert ) { + assert.expect( 13 ); var $foo = jQuery( "#foo" ), $blog = jQuery( ".blogTest" ), @@ -33,55 +33,55 @@ test( "find(node|jQuery object)", function() { $twoMore = jQuery( "#ap" ).add( $blog ), $fooTwo = $foo.add( $blog ); - equal( $foo.find( $blog ).text(), "Yahoo", "Find with blog jQuery object" ); - equal( $foo.find( $blog[ 0 ] ).text(), "Yahoo", "Find with blog node" ); - equal( $foo.find( $first ).length, 0, "#first is not in #foo" ); - equal( $foo.find( $first[ 0 ] ).length, 0, "#first not in #foo (node)" ); - deepEqual( $foo.find( $two ).get(), $blog.get(), "Find returns only nodes within #foo" ); - deepEqual( $foo.find( $twoMore ).get(), $blog.get(), "...regardless of order" ); - ok( $fooTwo.find( $blog ).is( ".blogTest" ), "Blog is part of the collection, but also within foo" ); - ok( $fooTwo.find( $blog[ 0 ] ).is( ".blogTest" ), "Blog is part of the collection, but also within foo(node)" ); - - equal( $two.find( $foo ).length, 0, "Foo is not in two elements" ); - equal( $two.find( $foo[ 0 ] ).length, 0, "Foo is not in two elements(node)" ); - equal( $two.find( $first ).length, 0, "first is in the collection and not within two" ); - equal( $two.find( $first ).length, 0, "first is in the collection and not within two(node)" ); - - equal( $two.find( $foo[ 0 ] ).addBack().length, 2, "find preserves the pushStack, see #12009" ); -} ); - -test( "is(String|undefined)", function() { - expect( 23 ); - ok( jQuery( "#form" ).is( "form" ), "Check for element: A form must be a form" ); - ok( !jQuery( "#form" ).is( "div" ), "Check for element: A form is not a div" ); - ok( jQuery( "#mark" ).is( ".blog" ), "Check for class: Expected class 'blog'" ); - ok( !jQuery( "#mark" ).is( ".link" ), "Check for class: Did not expect class 'link'" ); - ok( jQuery( "#simon" ).is( ".blog.link" ), "Check for multiple classes: Expected classes 'blog' and 'link'" ); - ok( !jQuery( "#simon" ).is( ".blogTest" ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" ); - ok( jQuery( "#en" ).is( "[lang=\"en\"]" ), "Check for attribute: Expected attribute lang to be 'en'" ); - ok( !jQuery( "#en" ).is( "[lang=\"de\"]" ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" ); - ok( jQuery( "#text1" ).is( "[type=\"text\"]" ), "Check for attribute: Expected attribute type to be 'text'" ); - ok( !jQuery( "#text1" ).is( "[type=\"radio\"]" ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" ); - ok( jQuery( "#text2" ).is( ":disabled" ), "Check for pseudoclass: Expected to be disabled" ); - ok( !jQuery( "#text1" ).is( ":disabled" ), "Check for pseudoclass: Expected not disabled" ); - ok( jQuery( "#radio2" ).is( ":checked" ), "Check for pseudoclass: Expected to be checked" ); - ok( !jQuery( "#radio1" ).is( ":checked" ), "Check for pseudoclass: Expected not checked" ); - - ok( !jQuery( "#foo" ).is( 0 ), "Expected false for an invalid expression - 0" ); - ok( !jQuery( "#foo" ).is( null ), "Expected false for an invalid expression - null" ); - ok( !jQuery( "#foo" ).is( "" ), "Expected false for an invalid expression - \"\"" ); - ok( !jQuery( "#foo" ).is( undefined ), "Expected false for an invalid expression - undefined" ); - ok( !jQuery( "#foo" ).is( { plain: "object" } ), "Check passing invalid object" ); + assert.equal( $foo.find( $blog ).text(), "Yahoo", "Find with blog jQuery object" ); + assert.equal( $foo.find( $blog[ 0 ] ).text(), "Yahoo", "Find with blog node" ); + assert.equal( $foo.find( $first ).length, 0, "#first is not in #foo" ); + assert.equal( $foo.find( $first[ 0 ] ).length, 0, "#first not in #foo (node)" ); + assert.deepEqual( $foo.find( $two ).get(), $blog.get(), "Find returns only nodes within #foo" ); + assert.deepEqual( $foo.find( $twoMore ).get(), $blog.get(), "...regardless of order" ); + assert.ok( $fooTwo.find( $blog ).is( ".blogTest" ), "Blog is part of the collection, but also within foo" ); + assert.ok( $fooTwo.find( $blog[ 0 ] ).is( ".blogTest" ), "Blog is part of the collection, but also within foo(node)" ); + + assert.equal( $two.find( $foo ).length, 0, "Foo is not in two elements" ); + assert.equal( $two.find( $foo[ 0 ] ).length, 0, "Foo is not in two elements(node)" ); + assert.equal( $two.find( $first ).length, 0, "first is in the collection and not within two" ); + assert.equal( $two.find( $first ).length, 0, "first is in the collection and not within two(node)" ); + + assert.equal( $two.find( $foo[ 0 ] ).addBack().length, 2, "find preserves the pushStack, see #12009" ); +} ); + +QUnit.test( "is(String|undefined)", function( assert ) { + assert.expect( 23 ); + assert.ok( jQuery( "#form" ).is( "form" ), "Check for element: A form must be a form" ); + assert.ok( !jQuery( "#form" ).is( "div" ), "Check for element: A form is not a div" ); + assert.ok( jQuery( "#mark" ).is( ".blog" ), "Check for class: Expected class 'blog'" ); + assert.ok( !jQuery( "#mark" ).is( ".link" ), "Check for class: Did not expect class 'link'" ); + assert.ok( jQuery( "#simon" ).is( ".blog.link" ), "Check for multiple classes: Expected classes 'blog' and 'link'" ); + assert.ok( !jQuery( "#simon" ).is( ".blogTest" ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" ); + assert.ok( jQuery( "#en" ).is( "[lang=\"en\"]" ), "Check for attribute: Expected attribute lang to be 'en'" ); + assert.ok( !jQuery( "#en" ).is( "[lang=\"de\"]" ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" ); + assert.ok( jQuery( "#text1" ).is( "[type=\"text\"]" ), "Check for attribute: Expected attribute type to be 'text'" ); + assert.ok( !jQuery( "#text1" ).is( "[type=\"radio\"]" ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" ); + assert.ok( jQuery( "#text2" ).is( ":disabled" ), "Check for pseudoclass: Expected to be disabled" ); + assert.ok( !jQuery( "#text1" ).is( ":disabled" ), "Check for pseudoclass: Expected not disabled" ); + assert.ok( jQuery( "#radio2" ).is( ":checked" ), "Check for pseudoclass: Expected to be checked" ); + assert.ok( !jQuery( "#radio1" ).is( ":checked" ), "Check for pseudoclass: Expected not checked" ); + + assert.ok( !jQuery( "#foo" ).is( 0 ), "Expected false for an invalid expression - 0" ); + assert.ok( !jQuery( "#foo" ).is( null ), "Expected false for an invalid expression - null" ); + assert.ok( !jQuery( "#foo" ).is( "" ), "Expected false for an invalid expression - \"\"" ); + assert.ok( !jQuery( "#foo" ).is( undefined ), "Expected false for an invalid expression - undefined" ); + assert.ok( !jQuery( "#foo" ).is( { plain: "object" } ), "Check passing invalid object" ); // test is() with comma-separated expressions - ok( jQuery( "#en" ).is( "[lang=\"en\"],[lang=\"de\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" ); - ok( jQuery( "#en" ).is( "[lang=\"de\"],[lang=\"en\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" ); - ok( jQuery( "#en" ).is( "[lang=\"en\"] , [lang=\"de\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" ); - ok( jQuery( "#en" ).is( "[lang=\"de\"] , [lang=\"en\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" ); + assert.ok( jQuery( "#en" ).is( "[lang=\"en\"],[lang=\"de\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" ); + assert.ok( jQuery( "#en" ).is( "[lang=\"de\"],[lang=\"en\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" ); + assert.ok( jQuery( "#en" ).is( "[lang=\"en\"] , [lang=\"de\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" ); + assert.ok( jQuery( "#en" ).is( "[lang=\"de\"] , [lang=\"en\"]" ), "Comma-separated; Check for lang attribute: Expect en or de" ); } ); -test( "is() against non-elements (#10178)", function() { - expect( 14 ); +QUnit.test( "is() against non-elements (#10178)", function( assert ) { + assert.expect( 14 ); var label, i, test, collection = jQuery( document ), @@ -100,50 +100,50 @@ test( "is() against non-elements (#10178)", function() { collection[ 0 ] = nonelements[ label ]; for ( i = 0; i < tests.length; i++ ) { test = tests[ i ]; - ok( !collection.is( test ), label + " does not match \"" + test + "\"" ); + assert.ok( !collection.is( test ), label + " does not match \"" + test + "\"" ); } } } ); -test( "is(jQuery)", function() { - expect( 19 ); - ok( jQuery( "#form" ).is( jQuery( "form" ) ), "Check for element: A form is a form" ); - ok( !jQuery( "#form" ).is( jQuery( "div" ) ), "Check for element: A form is not a div" ); - ok( jQuery( "#mark" ).is( jQuery( ".blog" ) ), "Check for class: Expected class 'blog'" ); - ok( !jQuery( "#mark" ).is( jQuery( ".link" ) ), "Check for class: Did not expect class 'link'" ); - ok( jQuery( "#simon" ).is( jQuery( ".blog.link" ) ), "Check for multiple classes: Expected classes 'blog' and 'link'" ); - ok( !jQuery( "#simon" ).is( jQuery( ".blogTest" ) ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" ); - ok( jQuery( "#en" ).is( jQuery( "[lang=\"en\"]" ) ), "Check for attribute: Expected attribute lang to be 'en'" ); - ok( !jQuery( "#en" ).is( jQuery( "[lang=\"de\"]" ) ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" ); - ok( jQuery( "#text1" ).is( jQuery( "[type=\"text\"]" ) ), "Check for attribute: Expected attribute type to be 'text'" ); - ok( !jQuery( "#text1" ).is( jQuery( "[type=\"radio\"]" ) ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" ); - ok( !jQuery( "#text1" ).is( jQuery( "input:disabled" ) ), "Check for pseudoclass: Expected not disabled" ); - ok( jQuery( "#radio2" ).is( jQuery( "input:checked" ) ), "Check for pseudoclass: Expected to be checked" ); - ok( !jQuery( "#radio1" ).is( jQuery( "input:checked" ) ), "Check for pseudoclass: Expected not checked" ); +QUnit.test( "is(jQuery)", function( assert ) { + assert.expect( 19 ); + assert.ok( jQuery( "#form" ).is( jQuery( "form" ) ), "Check for element: A form is a form" ); + assert.ok( !jQuery( "#form" ).is( jQuery( "div" ) ), "Check for element: A form is not a div" ); + assert.ok( jQuery( "#mark" ).is( jQuery( ".blog" ) ), "Check for class: Expected class 'blog'" ); + assert.ok( !jQuery( "#mark" ).is( jQuery( ".link" ) ), "Check for class: Did not expect class 'link'" ); + assert.ok( jQuery( "#simon" ).is( jQuery( ".blog.link" ) ), "Check for multiple classes: Expected classes 'blog' and 'link'" ); + assert.ok( !jQuery( "#simon" ).is( jQuery( ".blogTest" ) ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" ); + assert.ok( jQuery( "#en" ).is( jQuery( "[lang=\"en\"]" ) ), "Check for attribute: Expected attribute lang to be 'en'" ); + assert.ok( !jQuery( "#en" ).is( jQuery( "[lang=\"de\"]" ) ), "Check for attribute: Expected attribute lang to be 'en', not 'de'" ); + assert.ok( jQuery( "#text1" ).is( jQuery( "[type=\"text\"]" ) ), "Check for attribute: Expected attribute type to be 'text'" ); + assert.ok( !jQuery( "#text1" ).is( jQuery( "[type=\"radio\"]" ) ), "Check for attribute: Expected attribute type to be 'text', not 'radio'" ); + assert.ok( !jQuery( "#text1" ).is( jQuery( "input:disabled" ) ), "Check for pseudoclass: Expected not disabled" ); + assert.ok( jQuery( "#radio2" ).is( jQuery( "input:checked" ) ), "Check for pseudoclass: Expected to be checked" ); + assert.ok( !jQuery( "#radio1" ).is( jQuery( "input:checked" ) ), "Check for pseudoclass: Expected not checked" ); // Some raw elements - ok( jQuery( "#form" ).is( jQuery( "#qunit-fixture form" )[ 0 ] ), "Check for element: A form is a form" ); - ok( !jQuery( "#form" ).is( jQuery( "div" )[ 0 ] ), "Check for element: A form is not a div" ); - ok( jQuery( "#mark" ).is( jQuery( ".blog" )[ 0 ] ), "Check for class: Expected class 'blog'" ); - ok( !jQuery( "#mark" ).is( jQuery( ".link" )[ 0 ] ), "Check for class: Did not expect class 'link'" ); - ok( jQuery( "#simon" ).is( jQuery( ".blog.link" )[ 0 ] ), "Check for multiple classes: Expected classes 'blog' and 'link'" ); - ok( !jQuery( "#simon" ).is( jQuery( ".blogTest" )[ 0 ] ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" ); + assert.ok( jQuery( "#form" ).is( jQuery( "#qunit-fixture form" )[ 0 ] ), "Check for element: A form is a form" ); + assert.ok( !jQuery( "#form" ).is( jQuery( "div" )[ 0 ] ), "Check for element: A form is not a div" ); + assert.ok( jQuery( "#mark" ).is( jQuery( ".blog" )[ 0 ] ), "Check for class: Expected class 'blog'" ); + assert.ok( !jQuery( "#mark" ).is( jQuery( ".link" )[ 0 ] ), "Check for class: Did not expect class 'link'" ); + assert.ok( jQuery( "#simon" ).is( jQuery( ".blog.link" )[ 0 ] ), "Check for multiple classes: Expected classes 'blog' and 'link'" ); + assert.ok( !jQuery( "#simon" ).is( jQuery( ".blogTest" )[ 0 ] ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" ); } ); -test( "is() with :has() selectors", function() { - expect( 6 ); +QUnit.test( "is() with :has() selectors", function( assert ) { + assert.expect( 6 ); - ok( jQuery( "#foo" ).is( ":has(p)" ), "Check for child: Expected a child 'p' element" ); - ok( !jQuery( "#foo" ).is( ":has(ul)" ), "Check for child: Did not expect 'ul' element" ); - ok( jQuery( "#foo" ).is( ":has(p):has(a):has(code)" ), "Check for childs: Expected 'p', 'a' and 'code' child elements" ); - ok( !jQuery( "#foo" ).is( ":has(p):has(a):has(code):has(ol)" ), "Check for childs: Expected 'p', 'a' and 'code' child elements, but no 'ol'" ); + assert.ok( jQuery( "#foo" ).is( ":has(p)" ), "Check for child: Expected a child 'p' element" ); + assert.ok( !jQuery( "#foo" ).is( ":has(ul)" ), "Check for child: Did not expect 'ul' element" ); + assert.ok( jQuery( "#foo" ).is( ":has(p):has(a):has(code)" ), "Check for childs: Expected 'p', 'a' and 'code' child elements" ); + assert.ok( !jQuery( "#foo" ).is( ":has(p):has(a):has(code):has(ol)" ), "Check for childs: Expected 'p', 'a' and 'code' child elements, but no 'ol'" ); - ok( jQuery( "#foo" ).is( jQuery( "div:has(p)" ) ), "Check for child: Expected a child 'p' element" ); - ok( !jQuery( "#foo" ).is( jQuery( "div:has(ul)" ) ), "Check for child: Did not expect 'ul' element" ); + assert.ok( jQuery( "#foo" ).is( jQuery( "div:has(p)" ) ), "Check for child: Expected a child 'p' element" ); + assert.ok( !jQuery( "#foo" ).is( jQuery( "div:has(ul)" ) ), "Check for child: Did not expect 'ul' element" ); } ); -test( "is() with positional selectors", function() { - expect( 27 ); +QUnit.test( "is() with positional selectors", function( assert ) { + assert.expect( 27 ); var posp = jQuery( @@ -151,7 +151,7 @@ test( "is() with positional selectors", function() { "<a class='seconda' href='#'><b>test</b></a><em></em></p>" ).appendTo( "#qunit-fixture" ), isit = function( sel, match, expect ) { - equal( + assert.equal( jQuery( sel ).is( match ), expect, "jQuery('" + sel + "').is('" + match + "')" @@ -186,104 +186,104 @@ test( "is() with positional selectors", function() { isit( "#posp em", "#posp a em:last", true ); isit( "#posp em", "#posp a em:eq(2)", false ); - ok( jQuery( "#option1b" ).is( "#select1 option:not(:first)" ), "POS inside of :not() (#10970)" ); + assert.ok( jQuery( "#option1b" ).is( "#select1 option:not(:first)" ), "POS inside of :not() (#10970)" ); - ok( jQuery( posp[ 0 ] ).is( "p:last" ), "context constructed from a single node (#13797)" ); - ok( !jQuery( posp[ 0 ] ).find( "#firsta" ).is( "a:first" ), "context derived from a single node (#13797)" ); + assert.ok( jQuery( posp[ 0 ] ).is( "p:last" ), "context constructed from a single node (#13797)" ); + assert.ok( !jQuery( posp[ 0 ] ).find( "#firsta" ).is( "a:first" ), "context derived from a single node (#13797)" ); } ); -test( "index()", function() { - expect( 2 ); +QUnit.test( "index()", function( assert ) { + assert.expect( 2 ); - equal( jQuery( "#text2" ).index(), 2, "Returns the index of a child amongst its siblings" ); + assert.equal( jQuery( "#text2" ).index(), 2, "Returns the index of a child amongst its siblings" ); - equal( jQuery( "<div/>" ).index(), -1, "Node without parent returns -1" ); + assert.equal( jQuery( "<div/>" ).index(), -1, "Node without parent returns -1" ); } ); -test( "index(Object|String|undefined)", function() { - expect( 16 ); +QUnit.test( "index(Object|String|undefined)", function( assert ) { + assert.expect( 16 ); var elements = jQuery( [ window, document ] ), inputElements = jQuery( "#radio1,#radio2,#check1,#check2" ); // Passing a node - equal( elements.index( window ), 0, "Check for index of elements" ); - equal( elements.index( document ), 1, "Check for index of elements" ); - equal( inputElements.index( document.getElementById( "radio1" ) ), 0, "Check for index of elements" ); - equal( inputElements.index( document.getElementById( "radio2" ) ), 1, "Check for index of elements" ); - equal( inputElements.index( document.getElementById( "check1" ) ), 2, "Check for index of elements" ); - equal( inputElements.index( document.getElementById( "check2" ) ), 3, "Check for index of elements" ); - equal( inputElements.index( window ), -1, "Check for not found index" ); - equal( inputElements.index( document ), -1, "Check for not found index" ); + assert.equal( elements.index( window ), 0, "Check for index of elements" ); + assert.equal( elements.index( document ), 1, "Check for index of elements" ); + assert.equal( inputElements.index( document.getElementById( "radio1" ) ), 0, "Check for index of elements" ); + assert.equal( inputElements.index( document.getElementById( "radio2" ) ), 1, "Check for index of elements" ); + assert.equal( inputElements.index( document.getElementById( "check1" ) ), 2, "Check for index of elements" ); + assert.equal( inputElements.index( document.getElementById( "check2" ) ), 3, "Check for index of elements" ); + assert.equal( inputElements.index( window ), -1, "Check for not found index" ); + assert.equal( inputElements.index( document ), -1, "Check for not found index" ); // Passing a jQuery object // enabled since [5500] - equal( elements.index( elements ), 0, "Pass in a jQuery object" ); - equal( elements.index( elements.eq( 1 ) ), 1, "Pass in a jQuery object" ); - equal( jQuery( "#form input[type='radio']" ).index( jQuery( "#radio2" ) ), 1, "Pass in a jQuery object" ); + assert.equal( elements.index( elements ), 0, "Pass in a jQuery object" ); + assert.equal( elements.index( elements.eq( 1 ) ), 1, "Pass in a jQuery object" ); + assert.equal( jQuery( "#form input[type='radio']" ).index( jQuery( "#radio2" ) ), 1, "Pass in a jQuery object" ); // Passing a selector or nothing // enabled since [6330] - equal( jQuery( "#text2" ).index(), 2, "Check for index amongst siblings" ); - equal( jQuery( "#form" ).children().eq( 4 ).index(), 4, "Check for index amongst siblings" ); - equal( jQuery( "#radio2" ).index( "#form input[type='radio']" ), 1, "Check for index within a selector" ); - equal( jQuery( "#form input[type='radio']" ).index( jQuery( "#radio2" ) ), 1, "Check for index within a selector" ); - equal( jQuery( "#radio2" ).index( "#form input[type='text']" ), -1, "Check for index not found within a selector" ); + assert.equal( jQuery( "#text2" ).index(), 2, "Check for index amongst siblings" ); + assert.equal( jQuery( "#form" ).children().eq( 4 ).index(), 4, "Check for index amongst siblings" ); + assert.equal( jQuery( "#radio2" ).index( "#form input[type='radio']" ), 1, "Check for index within a selector" ); + assert.equal( jQuery( "#form input[type='radio']" ).index( jQuery( "#radio2" ) ), 1, "Check for index within a selector" ); + assert.equal( jQuery( "#radio2" ).index( "#form input[type='text']" ), -1, "Check for index not found within a selector" ); } ); -test( "filter(Selector|undefined)", function() { - expect( 9 ); - deepEqual( jQuery( "#form input" ).filter( ":checked" ).get(), q( "radio2", "check1" ), "filter(String)" ); - deepEqual( jQuery( "p" ).filter( "#ap, #sndp" ).get(), q( "ap", "sndp" ), "filter('String, String')" ); - deepEqual( jQuery( "p" ).filter( "#ap,#sndp" ).get(), q( "ap", "sndp" ), "filter('String,String')" ); +QUnit.test( "filter(Selector|undefined)", function( assert ) { + assert.expect( 9 ); + assert.deepEqual( jQuery( "#form input" ).filter( ":checked" ).get(), q( "radio2", "check1" ), "filter(String)" ); + assert.deepEqual( jQuery( "p" ).filter( "#ap, #sndp" ).get(), q( "ap", "sndp" ), "filter('String, String')" ); + assert.deepEqual( jQuery( "p" ).filter( "#ap,#sndp" ).get(), q( "ap", "sndp" ), "filter('String,String')" ); - deepEqual( jQuery( "p" ).filter( null ).get(), [], "filter(null) should return an empty jQuery object" ); - deepEqual( jQuery( "p" ).filter( undefined ).get(), [], "filter(undefined) should return an empty jQuery object" ); - deepEqual( jQuery( "p" ).filter( 0 ).get(), [], "filter(0) should return an empty jQuery object" ); - deepEqual( jQuery( "p" ).filter( "" ).get(), [], "filter('') should return an empty jQuery object" ); + assert.deepEqual( jQuery( "p" ).filter( null ).get(), [], "filter(null) should return an empty jQuery object" ); + assert.deepEqual( jQuery( "p" ).filter( undefined ).get(), [], "filter(undefined) should return an empty jQuery object" ); + assert.deepEqual( jQuery( "p" ).filter( 0 ).get(), [], "filter(0) should return an empty jQuery object" ); + assert.deepEqual( jQuery( "p" ).filter( "" ).get(), [], "filter('') should return an empty jQuery object" ); // using contents will get comments regular, text, and comment nodes var j = jQuery( "#nonnodes" ).contents(); - equal( j.filter( "span" ).length, 1, "Check node,textnode,comment to filter the one span" ); - equal( j.filter( "[name]" ).length, 0, "Check node,textnode,comment to filter the one span" ); + assert.equal( j.filter( "span" ).length, 1, "Check node,textnode,comment to filter the one span" ); + assert.equal( j.filter( "[name]" ).length, 0, "Check node,textnode,comment to filter the one span" ); } ); -test( "filter(Function)", function() { - expect( 2 ); +QUnit.test( "filter(Function)", function( assert ) { + assert.expect( 2 ); - deepEqual( jQuery( "#qunit-fixture p" ).filter( function() { + assert.deepEqual( jQuery( "#qunit-fixture p" ).filter( function() { return !jQuery( "a", this ).length; } ).get(), q( "sndp", "first" ), "filter(Function)" ); - deepEqual( jQuery( "#qunit-fixture p" ).filter( function( i, elem ) { return !jQuery( "a", elem ).length; } ).get(), q( "sndp", "first" ), "filter(Function) using arg" ); + assert.deepEqual( jQuery( "#qunit-fixture p" ).filter( function( i, elem ) { return !jQuery( "a", elem ).length; } ).get(), q( "sndp", "first" ), "filter(Function) using arg" ); } ); -test( "filter(Element)", function() { - expect( 1 ); +QUnit.test( "filter(Element)", function( assert ) { + assert.expect( 1 ); var element = document.getElementById( "text1" ); - deepEqual( jQuery( "#form input" ).filter( element ).get(), q( "text1" ), "filter(Element)" ); + assert.deepEqual( jQuery( "#form input" ).filter( element ).get(), q( "text1" ), "filter(Element)" ); } ); -test( "filter(Array)", function() { - expect( 1 ); +QUnit.test( "filter(Array)", function( assert ) { + assert.expect( 1 ); var elements = [ document.getElementById( "text1" ) ]; - deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" ); + assert.deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" ); } ); -test( "filter(jQuery)", function() { - expect( 1 ); +QUnit.test( "filter(jQuery)", function( assert ) { + assert.expect( 1 ); var elements = jQuery( "#text1" ); - deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" ); + assert.deepEqual( jQuery( "#form input" ).filter( elements ).get(), q( "text1" ), "filter(Element)" ); } ); -test( "filter() with positional selectors", function() { - expect( 19 ); +QUnit.test( "filter() with positional selectors", function( assert ) { + assert.expect( 19 ); var filterit = function( sel, filter, length ) { - equal( jQuery( sel ).filter( filter ).length, length, "jQuery( " + sel + " ).filter( " + filter + " )" ); + assert.equal( jQuery( sel ).filter( filter ).length, length, "jQuery( " + sel + " ).filter( " + filter + " )" ); }; jQuery( "" + @@ -322,360 +322,360 @@ test( "filter() with positional selectors", function() { filterit( "#posp .seconda", "#posp a:lt(1)", 1 ); } ); -test( "closest()", function() { - expect( 13 ); +QUnit.test( "closest()", function( assert ) { + assert.expect( 13 ); var jq; - deepEqual( jQuery( "body" ).closest( "body" ).get(), q( "body" ), "closest(body)" ); - deepEqual( jQuery( "body" ).closest( "html" ).get(), q( "html" ), "closest(html)" ); - deepEqual( jQuery( "body" ).closest( "div" ).get(), [], "closest(div)" ); - deepEqual( jQuery( "#qunit-fixture" ).closest( "span,#html" ).get(), q( "html" ), "closest(span,#html)" ); + assert.deepEqual( jQuery( "body" ).closest( "body" ).get(), q( "body" ), "closest(body)" ); + assert.deepEqual( jQuery( "body" ).closest( "html" ).get(), q( "html" ), "closest(html)" ); + assert.deepEqual( jQuery( "body" ).closest( "div" ).get(), [], "closest(div)" ); + assert.deepEqual( jQuery( "#qunit-fixture" ).closest( "span,#html" ).get(), q( "html" ), "closest(span,#html)" ); // Test .closest() limited by the context jq = jQuery( "#nothiddendivchild" ); - deepEqual( jq.closest( "html", document.body ).get(), [], "Context limited." ); - deepEqual( jq.closest( "body", document.body ).get(), [], "Context limited." ); - deepEqual( jq.closest( "#nothiddendiv", document.body ).get(), q( "nothiddendiv" ), "Context not reached." ); + assert.deepEqual( jq.closest( "html", document.body ).get(), [], "Context limited." ); + assert.deepEqual( jq.closest( "body", document.body ).get(), [], "Context limited." ); + assert.deepEqual( jq.closest( "#nothiddendiv", document.body ).get(), q( "nothiddendiv" ), "Context not reached." ); //Test that .closest() returns unique'd set - equal( jQuery( "#qunit-fixture p" ).closest( "#qunit-fixture" ).length, 1, "Closest should return a unique set" ); + assert.equal( jQuery( "#qunit-fixture p" ).closest( "#qunit-fixture" ).length, 1, "Closest should return a unique set" ); // Test on disconnected node - equal( jQuery( "<div><p></p></div>" ).find( "p" ).closest( "table" ).length, 0, "Make sure disconnected closest work." ); + assert.equal( jQuery( "<div><p></p></div>" ).find( "p" ).closest( "table" ).length, 0, "Make sure disconnected closest work." ); // Bug #7369 - equal( jQuery( "<div foo='bar'></div>" ).closest( "[foo]" ).length, 1, "Disconnected nodes with attribute selector" ); - equal( jQuery( "<div>text</div>" ).closest( "[lang]" ).length, 0, "Disconnected nodes with text and non-existent attribute selector" ); + assert.equal( jQuery( "<div foo='bar'></div>" ).closest( "[foo]" ).length, 1, "Disconnected nodes with attribute selector" ); + assert.equal( jQuery( "<div>text</div>" ).closest( "[lang]" ).length, 0, "Disconnected nodes with text and non-existent attribute selector" ); - ok( !jQuery( document ).closest( "#foo" ).length, "Calling closest on a document fails silently" ); + assert.ok( !jQuery( document ).closest( "#foo" ).length, "Calling closest on a document fails silently" ); jq = jQuery( "<div>text</div>" ); - deepEqual( jq.contents().closest( "*" ).get(), jq.get(), "Text node input (#13332)" ); + assert.deepEqual( jq.contents().closest( "*" ).get(), jq.get(), "Text node input (#13332)" ); } ); -test( "closest() with positional selectors", function() { - expect( 2 ); +QUnit.test( "closest() with positional selectors", function( assert ) { + assert.expect( 2 ); - deepEqual( jQuery( "#qunit-fixture" ).closest( "div:first" ).get(), [], "closest(div:first)" ); - deepEqual( jQuery( "#qunit-fixture div" ).closest( "body:first div:last" ).get(), q( "fx-tests" ), "closest(body:first div:last)" ); + assert.deepEqual( jQuery( "#qunit-fixture" ).closest( "div:first" ).get(), [], "closest(div:first)" ); + assert.deepEqual( jQuery( "#qunit-fixture div" ).closest( "body:first div:last" ).get(), q( "fx-tests" ), "closest(body:first div:last)" ); } ); -test( "closest(jQuery)", function() { - expect( 8 ); +QUnit.test( "closest(jQuery)", function( assert ) { + assert.expect( 8 ); var $child = jQuery( "#nothiddendivchild" ), $parent = jQuery( "#nothiddendiv" ), $sibling = jQuery( "#foo" ), $body = jQuery( "body" ); - ok( $child.closest( $parent ).is( "#nothiddendiv" ), "closest( jQuery('#nothiddendiv') )" ); - ok( $child.closest( $parent[ 0 ] ).is( "#nothiddendiv" ), "closest( jQuery('#nothiddendiv') ) :: node" ); - ok( $child.closest( $child ).is( "#nothiddendivchild" ), "child is included" ); - ok( $child.closest( $child[ 0 ] ).is( "#nothiddendivchild" ), "child is included :: node" ); - equal( $child.closest( document.createElement( "div" ) ).length, 0, "created element is not related" ); - equal( $child.closest( $sibling ).length, 0, "Sibling not a parent of child" ); - equal( $child.closest( $sibling[ 0 ] ).length, 0, "Sibling not a parent of child :: node" ); - ok( $child.closest( $body.add( $parent ) ).is( "#nothiddendiv" ), "Closest ancestor retrieved." ); -} ); - -test( "not(Selector|undefined)", function() { - expect( 11 ); - equal( jQuery( "#qunit-fixture > p#ap > a" ).not( "#google" ).length, 2, "not('selector')" ); - deepEqual( jQuery( "p" ).not( ".result" ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "not('.class')" ); - deepEqual( jQuery( "p" ).not( "#ap, #sndp, .result" ).get(), q( "firstp", "en", "sap", "first" ), "not('selector, selector')" ); - - deepEqual( jQuery( "#ap *" ).not( "code" ).get(), q( "google", "groups", "anchor1", "mark" ), "not('tag selector')" ); - deepEqual( jQuery( "#ap *" ).not( "code, #mark" ).get(), q( "google", "groups", "anchor1" ), "not('tag, ID selector')" ); - deepEqual( jQuery( "#ap *" ).not( "#mark, code" ).get(), q( "google", "groups", "anchor1" ), "not('ID, tag selector')" ); + assert.ok( $child.closest( $parent ).is( "#nothiddendiv" ), "closest( jQuery('#nothiddendiv') )" ); + assert.ok( $child.closest( $parent[ 0 ] ).is( "#nothiddendiv" ), "closest( jQuery('#nothiddendiv') ) :: node" ); + assert.ok( $child.closest( $child ).is( "#nothiddendivchild" ), "child is included" ); + assert.ok( $child.closest( $child[ 0 ] ).is( "#nothiddendivchild" ), "child is included :: node" ); + assert.equal( $child.closest( document.createElement( "div" ) ).length, 0, "created element is not related" ); + assert.equal( $child.closest( $sibling ).length, 0, "Sibling not a parent of child" ); + assert.equal( $child.closest( $sibling[ 0 ] ).length, 0, "Sibling not a parent of child :: node" ); + assert.ok( $child.closest( $body.add( $parent ) ).is( "#nothiddendiv" ), "Closest ancestor retrieved." ); +} ); + +QUnit.test( "not(Selector|undefined)", function( assert ) { + assert.expect( 11 ); + assert.equal( jQuery( "#qunit-fixture > p#ap > a" ).not( "#google" ).length, 2, "not('selector')" ); + assert.deepEqual( jQuery( "p" ).not( ".result" ).get(), q( "firstp", "ap", "sndp", "en", "sap", "first" ), "not('.class')" ); + assert.deepEqual( jQuery( "p" ).not( "#ap, #sndp, .result" ).get(), q( "firstp", "en", "sap", "first" ), "not('selector, selector')" ); + + assert.deepEqual( jQuery( "#ap *" ).not( "code" ).get(), q( "google", "groups", "anchor1", "mark" ), "not('tag selector')" ); + assert.deepEqual( jQuery( "#ap *" ).not( "code, #mark" ).get(), q( "google", "groups", "anchor1" ), "not('tag, ID selector')" ); + assert.deepEqual( jQuery( "#ap *" ).not( "#mark, code" ).get(), q( "google", "groups", "anchor1" ), "not('ID, tag selector')" ); var all = jQuery( "p" ).get(); - deepEqual( jQuery( "p" ).not( null ).get(), all, "not(null) should have no effect" ); - deepEqual( jQuery( "p" ).not( undefined ).get(), all, "not(undefined) should have no effect" ); - deepEqual( jQuery( "p" ).not( 0 ).get(), all, "not(0) should have no effect" ); - deepEqual( jQuery( "p" ).not( "" ).get(), all, "not('') should have no effect" ); + assert.deepEqual( jQuery( "p" ).not( null ).get(), all, "not(null) should have no effect" ); + assert.deepEqual( jQuery( "p" ).not( undefined ).get(), all, "not(undefined) should have no effect" ); + assert.deepEqual( jQuery( "p" ).not( 0 ).get(), all, "not(0) should have no effect" ); + assert.deepEqual( jQuery( "p" ).not( "" ).get(), all, "not('') should have no effect" ); - deepEqual( + assert.deepEqual( jQuery( "#form option" ).not( "option.emptyopt:contains('Nothing'),optgroup *,[value='1']" ).get(), q( "option1c", "option1d", "option2c", "option2d", "option3c", "option3d", "option3e", "option4d", "option4e", "option5a", "option5b" ), "not('complex selector')" ); } ); -test( "not(Element)", function() { - expect( 1 ); +QUnit.test( "not(Element)", function( assert ) { + assert.expect( 1 ); var selects = jQuery( "#form select" ); - deepEqual( selects.not( selects[ 1 ] ).get(), q( "select1", "select3", "select4", "select5" ), "filter out DOM element" ); + assert.deepEqual( selects.not( selects[ 1 ] ).get(), q( "select1", "select3", "select4", "select5" ), "filter out DOM element" ); } ); -test( "not(Function)", function() { - expect( 1 ); +QUnit.test( "not(Function)", function( assert ) { + assert.expect( 1 ); - deepEqual( jQuery( "#qunit-fixture p" ).not( function() { return jQuery( "a", this ).length; } ).get(), q( "sndp", "first" ), "not(Function)" ); + assert.deepEqual( jQuery( "#qunit-fixture p" ).not( function() { return jQuery( "a", this ).length; } ).get(), q( "sndp", "first" ), "not(Function)" ); } ); -test( "not(Array)", function() { - expect( 2 ); +QUnit.test( "not(Array)", function( assert ) { + assert.expect( 2 ); - equal( jQuery( "#qunit-fixture > p#ap > a" ).not( document.getElementById( "google" ) ).length, 2, "not(DOMElement)" ); - equal( jQuery( "p" ).not( document.getElementsByTagName( "p" ) ).length, 0, "not(Array-like DOM collection)" ); + assert.equal( jQuery( "#qunit-fixture > p#ap > a" ).not( document.getElementById( "google" ) ).length, 2, "not(DOMElement)" ); + assert.equal( jQuery( "p" ).not( document.getElementsByTagName( "p" ) ).length, 0, "not(Array-like DOM collection)" ); } ); -test( "not(jQuery)", function() { - expect( 1 ); +QUnit.test( "not(jQuery)", function( assert ) { + assert.expect( 1 ); - deepEqual( jQuery( "p" ).not( jQuery( "#ap, #sndp, .result" ) ).get(), q( "firstp", "en", "sap", "first" ), "not(jQuery)" ); + assert.deepEqual( jQuery( "p" ).not( jQuery( "#ap, #sndp, .result" ) ).get(), q( "firstp", "en", "sap", "first" ), "not(jQuery)" ); } ); -test( "has(Element)", function() { - expect( 3 ); +QUnit.test( "has(Element)", function( assert ) { + assert.expect( 3 ); var obj, detached, multipleParent; obj = jQuery( "#qunit-fixture" ).has( jQuery( "#sndp" )[ 0 ] ); - deepEqual( obj.get(), q( "qunit-fixture" ), "Keeps elements that have the element as a descendant" ); + assert.deepEqual( obj.get(), q( "qunit-fixture" ), "Keeps elements that have the element as a descendant" ); detached = jQuery( "<a><b><i/></b></a>" ); - deepEqual( detached.has( detached.find( "i" )[ 0 ] ).get(), detached.get(), "...Even when detached" ); + assert.deepEqual( detached.has( detached.find( "i" )[ 0 ] ).get(), detached.get(), "...Even when detached" ); multipleParent = jQuery( "#qunit-fixture, #header" ).has( jQuery( "#sndp" )[ 0 ] ); - deepEqual( multipleParent.get(), q( "qunit-fixture" ), "Does not include elements that do not have the element as a descendant" ); + assert.deepEqual( multipleParent.get(), q( "qunit-fixture" ), "Does not include elements that do not have the element as a descendant" ); } ); -test( "has(Selector)", function() { - expect( 5 ); +QUnit.test( "has(Selector)", function( assert ) { + assert.expect( 5 ); var obj, detached, multipleParent, multipleHas; obj = jQuery( "#qunit-fixture" ).has( "#sndp" ); - deepEqual( obj.get(), q( "qunit-fixture" ), "Keeps elements that have any element matching the selector as a descendant" ); + assert.deepEqual( obj.get(), q( "qunit-fixture" ), "Keeps elements that have any element matching the selector as a descendant" ); detached = jQuery( "<a><b><i/></b></a>" ); - deepEqual( detached.has( "i" ).get(), detached.get(), "...Even when detached" ); + assert.deepEqual( detached.has( "i" ).get(), detached.get(), "...Even when detached" ); multipleParent = jQuery( "#qunit-fixture, #header" ).has( "#sndp" ); - deepEqual( multipleParent.get(), q( "qunit-fixture" ), "Does not include elements that do not have the element as a descendant" ); + assert.deepEqual( multipleParent.get(), q( "qunit-fixture" ), "Does not include elements that do not have the element as a descendant" ); multipleParent = jQuery( "#select1, #select2, #select3" ).has( "#option1a, #option3a" ); - deepEqual( multipleParent.get(), q( "select1", "select3" ), "Multiple contexts are checks correctly" ); + assert.deepEqual( multipleParent.get(), q( "select1", "select3" ), "Multiple contexts are checks correctly" ); multipleHas = jQuery( "#qunit-fixture" ).has( "#sndp, #first" ); - deepEqual( multipleHas.get(), q( "qunit-fixture" ), "Only adds elements once" ); + assert.deepEqual( multipleHas.get(), q( "qunit-fixture" ), "Only adds elements once" ); } ); -test( "has(Arrayish)", function() { - expect( 4 ); +QUnit.test( "has(Arrayish)", function( assert ) { + assert.expect( 4 ); var simple, detached, multipleParent, multipleHas; simple = jQuery( "#qunit-fixture" ).has( jQuery( "#sndp" ) ); - deepEqual( simple.get(), q( "qunit-fixture" ), "Keeps elements that have any element in the jQuery list as a descendant" ); + assert.deepEqual( simple.get(), q( "qunit-fixture" ), "Keeps elements that have any element in the jQuery list as a descendant" ); detached = jQuery( "<a><b><i/></b></a>" ); - deepEqual( detached.has( detached.find( "i" ) ).get(), detached.get(), "...Even when detached" ); + assert.deepEqual( detached.has( detached.find( "i" ) ).get(), detached.get(), "...Even when detached" ); multipleParent = jQuery( "#qunit-fixture, #header" ).has( jQuery( "#sndp" ) ); - deepEqual( multipleParent.get(), q( "qunit-fixture" ), "Does not include elements that do not have an element in the jQuery list as a descendant" ); + assert.deepEqual( multipleParent.get(), q( "qunit-fixture" ), "Does not include elements that do not have an element in the jQuery list as a descendant" ); multipleHas = jQuery( "#qunit-fixture" ).has( jQuery( "#sndp, #first" ) ); - deepEqual( multipleHas.get(), q( "qunit-fixture" ), "Only adds elements once" ); + assert.deepEqual( multipleHas.get(), q( "qunit-fixture" ), "Only adds elements once" ); } ); -test( "addBack()", function() { - expect( 5 ); - deepEqual( jQuery( "#en" ).siblings().addBack().get(), q( "sndp", "en", "sap" ), "Check for siblings and self" ); - deepEqual( jQuery( "#foo" ).children().addBack().get(), q( "foo", "sndp", "en", "sap" ), "Check for children and self" ); - deepEqual( jQuery( "#sndp, #en" ).parent().addBack().get(), q( "foo", "sndp", "en" ), "Check for parent and self" ); - deepEqual( jQuery( "#groups" ).parents( "p, div" ).addBack().get(), q( "qunit-fixture", "ap", "groups" ), "Check for parents and self" ); - deepEqual( jQuery( "#select1 > option" ).filter( ":first-child" ).addBack( ":last-child" ).get(), q( "option1a", "option1d" ), "Should contain the last elems plus the *filtered* prior set elements" ); +QUnit.test( "addBack()", function( assert ) { + assert.expect( 5 ); + assert.deepEqual( jQuery( "#en" ).siblings().addBack().get(), q( "sndp", "en", "sap" ), "Check for siblings and self" ); + assert.deepEqual( jQuery( "#foo" ).children().addBack().get(), q( "foo", "sndp", "en", "sap" ), "Check for children and self" ); + assert.deepEqual( jQuery( "#sndp, #en" ).parent().addBack().get(), q( "foo", "sndp", "en" ), "Check for parent and self" ); + assert.deepEqual( jQuery( "#groups" ).parents( "p, div" ).addBack().get(), q( "qunit-fixture", "ap", "groups" ), "Check for parents and self" ); + assert.deepEqual( jQuery( "#select1 > option" ).filter( ":first-child" ).addBack( ":last-child" ).get(), q( "option1a", "option1d" ), "Should contain the last elems plus the *filtered* prior set elements" ); } ); -test( "siblings([String])", function() { - expect( 6 ); - deepEqual( jQuery( "#en" ).siblings().get(), q( "sndp", "sap" ), "Check for siblings" ); - deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).siblings().get(), q( "nonnodesElement" ), "Check for text node siblings" ); - deepEqual( jQuery( "#foo" ).siblings( "form, b" ).get(), q( "form", "floatTest", "lengthtest", "name-tests", "testForm" ), "Check for multiple filters" ); +QUnit.test( "siblings([String])", function( assert ) { + assert.expect( 6 ); + assert.deepEqual( jQuery( "#en" ).siblings().get(), q( "sndp", "sap" ), "Check for siblings" ); + assert.deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).siblings().get(), q( "nonnodesElement" ), "Check for text node siblings" ); + assert.deepEqual( jQuery( "#foo" ).siblings( "form, b" ).get(), q( "form", "floatTest", "lengthtest", "name-tests", "testForm" ), "Check for multiple filters" ); var set = q( "sndp", "en", "sap" ); - deepEqual( jQuery( "#en, #sndp" ).siblings().get(), set, "Check for unique results from siblings" ); - deepEqual( jQuery( "#option5a" ).siblings( "option[data-attr]" ).get(), q( "option5c" ), "Has attribute selector in siblings (#9261)" ); - equal( jQuery( "<a/>" ).siblings().length, 0, "Detached elements have no siblings (#11370)" ); + assert.deepEqual( jQuery( "#en, #sndp" ).siblings().get(), set, "Check for unique results from siblings" ); + assert.deepEqual( jQuery( "#option5a" ).siblings( "option[data-attr]" ).get(), q( "option5c" ), "Has attribute selector in siblings (#9261)" ); + assert.equal( jQuery( "<a/>" ).siblings().length, 0, "Detached elements have no siblings (#11370)" ); } ); -test( "siblings([String]) - jQuery only", function() { - expect( 2 ); - deepEqual( jQuery( "#sndp" ).siblings( ":has(code)" ).get(), q( "sap" ), "Check for filtered siblings (has code child element)" ); - deepEqual( jQuery( "#sndp" ).siblings( ":has(a)" ).get(), q( "en", "sap" ), "Check for filtered siblings (has anchor child element)" ); +QUnit.test( "siblings([String]) - jQuery only", function( assert ) { + assert.expect( 2 ); + assert.deepEqual( jQuery( "#sndp" ).siblings( ":has(code)" ).get(), q( "sap" ), "Check for filtered siblings (has code child element)" ); + assert.deepEqual( jQuery( "#sndp" ).siblings( ":has(a)" ).get(), q( "en", "sap" ), "Check for filtered siblings (has anchor child element)" ); } ); -test( "children([String])", function() { - expect( 2 ); - deepEqual( jQuery( "#foo" ).children().get(), q( "sndp", "en", "sap" ), "Check for children" ); - deepEqual( jQuery( "#foo" ).children( "#en, #sap" ).get(), q( "en", "sap" ), "Check for multiple filters" ); +QUnit.test( "children([String])", function( assert ) { + assert.expect( 2 ); + assert.deepEqual( jQuery( "#foo" ).children().get(), q( "sndp", "en", "sap" ), "Check for children" ); + assert.deepEqual( jQuery( "#foo" ).children( "#en, #sap" ).get(), q( "en", "sap" ), "Check for multiple filters" ); } ); -test( "children([String]) - jQuery only", function() { - expect( 1 ); - deepEqual( jQuery( "#foo" ).children( ":has(code)" ).get(), q( "sndp", "sap" ), "Check for filtered children" ); +QUnit.test( "children([String]) - jQuery only", function( assert ) { + assert.expect( 1 ); + assert.deepEqual( jQuery( "#foo" ).children( ":has(code)" ).get(), q( "sndp", "sap" ), "Check for filtered children" ); } ); -test( "parent([String])", function() { - expect( 6 ); +QUnit.test( "parent([String])", function( assert ) { + assert.expect( 6 ); var $el; - equal( jQuery( "#groups" ).parent()[ 0 ].id, "ap", "Simple parent check" ); - equal( jQuery( "#groups" ).parent( "p" )[ 0 ].id, "ap", "Filtered parent check" ); - equal( jQuery( "#groups" ).parent( "div" ).length, 0, "Filtered parent check, no match" ); - equal( jQuery( "#groups" ).parent( "div, p" )[ 0 ].id, "ap", "Check for multiple filters" ); - deepEqual( jQuery( "#en, #sndp" ).parent().get(), q( "foo" ), "Check for unique results from parent" ); + assert.equal( jQuery( "#groups" ).parent()[ 0 ].id, "ap", "Simple parent check" ); + assert.equal( jQuery( "#groups" ).parent( "p" )[ 0 ].id, "ap", "Filtered parent check" ); + assert.equal( jQuery( "#groups" ).parent( "div" ).length, 0, "Filtered parent check, no match" ); + assert.equal( jQuery( "#groups" ).parent( "div, p" )[ 0 ].id, "ap", "Check for multiple filters" ); + assert.deepEqual( jQuery( "#en, #sndp" ).parent().get(), q( "foo" ), "Check for unique results from parent" ); $el = jQuery( "<div>text</div>" ); - strictEqual( $el.contents().parent()[ 0 ], $el[ 0 ], "Check for parent of text node (#13265)" ); + assert.strictEqual( $el.contents().parent()[ 0 ], $el[ 0 ], "Check for parent of text node (#13265)" ); } ); -test( "parents([String])", function() { - expect( 6 ); - equal( jQuery( "#groups" ).parents()[ 0 ].id, "ap", "Simple parents check" ); - deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).parents().eq( 0 ).get(), q( "nonnodes" ), "Text node parents check" ); - equal( jQuery( "#groups" ).parents( "p" )[ 0 ].id, "ap", "Filtered parents check" ); - equal( jQuery( "#groups" ).parents( "div" )[ 0 ].id, "qunit-fixture", "Filtered parents check2" ); - deepEqual( jQuery( "#groups" ).parents( "p, div" ).get(), q( "ap", "qunit-fixture" ), "Check for multiple filters" ); - deepEqual( jQuery( "#en, #sndp" ).parents().get(), q( "foo", "qunit-fixture", "dl", "body", "html" ), "Check for unique results from parents" ); +QUnit.test( "parents([String])", function( assert ) { + assert.expect( 6 ); + assert.equal( jQuery( "#groups" ).parents()[ 0 ].id, "ap", "Simple parents check" ); + assert.deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).parents().eq( 0 ).get(), q( "nonnodes" ), "Text node parents check" ); + assert.equal( jQuery( "#groups" ).parents( "p" )[ 0 ].id, "ap", "Filtered parents check" ); + assert.equal( jQuery( "#groups" ).parents( "div" )[ 0 ].id, "qunit-fixture", "Filtered parents check2" ); + assert.deepEqual( jQuery( "#groups" ).parents( "p, div" ).get(), q( "ap", "qunit-fixture" ), "Check for multiple filters" ); + assert.deepEqual( jQuery( "#en, #sndp" ).parents().get(), q( "foo", "qunit-fixture", "dl", "body", "html" ), "Check for unique results from parents" ); } ); -test( "parentsUntil([String])", function() { - expect( 10 ); +QUnit.test( "parentsUntil([String])", function( assert ) { + assert.expect( 10 ); var parents = jQuery( "#groups" ).parents(); - deepEqual( jQuery( "#groups" ).parentsUntil().get(), parents.get(), "parentsUntil with no selector (nextAll)" ); - deepEqual( jQuery( "#groups" ).parentsUntil( ".foo" ).get(), parents.get(), "parentsUntil with invalid selector (nextAll)" ); - deepEqual( jQuery( "#groups" ).parentsUntil( "#html" ).get(), parents.slice( 0, -1 ).get(), "Simple parentsUntil check" ); - equal( jQuery( "#groups" ).parentsUntil( "#ap" ).length, 0, "Simple parentsUntil check" ); - deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).parentsUntil( "#html" ).eq( 0 ).get(), q( "nonnodes" ), "Text node parentsUntil check" ); - deepEqual( jQuery( "#groups" ).parentsUntil( "#html, #body" ).get(), parents.slice( 0, 3 ).get(), "Less simple parentsUntil check" ); - deepEqual( jQuery( "#groups" ).parentsUntil( "#html", "div" ).get(), jQuery( "#qunit-fixture" ).get(), "Filtered parentsUntil check" ); - deepEqual( jQuery( "#groups" ).parentsUntil( "#html", "p,div,dl" ).get(), parents.slice( 0, 3 ).get(), "Multiple-filtered parentsUntil check" ); - equal( jQuery( "#groups" ).parentsUntil( "#html", "span" ).length, 0, "Filtered parentsUntil check, no match" ); - deepEqual( jQuery( "#groups, #ap" ).parentsUntil( "#html", "p,div,dl" ).get(), parents.slice( 0, 3 ).get(), "Multi-source, multiple-filtered parentsUntil check" ); + assert.deepEqual( jQuery( "#groups" ).parentsUntil().get(), parents.get(), "parentsUntil with no selector (nextAll)" ); + assert.deepEqual( jQuery( "#groups" ).parentsUntil( ".foo" ).get(), parents.get(), "parentsUntil with invalid selector (nextAll)" ); + assert.deepEqual( jQuery( "#groups" ).parentsUntil( "#html" ).get(), parents.slice( 0, -1 ).get(), "Simple parentsUntil check" ); + assert.equal( jQuery( "#groups" ).parentsUntil( "#ap" ).length, 0, "Simple parentsUntil check" ); + assert.deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).parentsUntil( "#html" ).eq( 0 ).get(), q( "nonnodes" ), "Text node parentsUntil check" ); + assert.deepEqual( jQuery( "#groups" ).parentsUntil( "#html, #body" ).get(), parents.slice( 0, 3 ).get(), "Less simple parentsUntil check" ); + assert.deepEqual( jQuery( "#groups" ).parentsUntil( "#html", "div" ).get(), jQuery( "#qunit-fixture" ).get(), "Filtered parentsUntil check" ); + assert.deepEqual( jQuery( "#groups" ).parentsUntil( "#html", "p,div,dl" ).get(), parents.slice( 0, 3 ).get(), "Multiple-filtered parentsUntil check" ); + assert.equal( jQuery( "#groups" ).parentsUntil( "#html", "span" ).length, 0, "Filtered parentsUntil check, no match" ); + assert.deepEqual( jQuery( "#groups, #ap" ).parentsUntil( "#html", "p,div,dl" ).get(), parents.slice( 0, 3 ).get(), "Multi-source, multiple-filtered parentsUntil check" ); } ); -test( "next([String])", function() { - expect( 6 ); - equal( jQuery( "#ap" ).next()[ 0 ].id, "foo", "Simple next check" ); - equal( jQuery( "<div>text<a id='element'></a></div>" ).contents().eq( 0 ).next().attr( "id" ), "element", "Text node next check" ); - equal( jQuery( "#ap" ).next( "div" )[ 0 ].id, "foo", "Filtered next check" ); - equal( jQuery( "#ap" ).next( "p" ).length, 0, "Filtered next check, no match" ); - equal( jQuery( "#ap" ).next( "div, p" )[ 0 ].id, "foo", "Multiple filters" ); - equal( jQuery( "body" ).next().length, 0, "Simple next check, no match" ); +QUnit.test( "next([String])", function( assert ) { + assert.expect( 6 ); + assert.equal( jQuery( "#ap" ).next()[ 0 ].id, "foo", "Simple next check" ); + assert.equal( jQuery( "<div>text<a id='element'></a></div>" ).contents().eq( 0 ).next().attr( "id" ), "element", "Text node next check" ); + assert.equal( jQuery( "#ap" ).next( "div" )[ 0 ].id, "foo", "Filtered next check" ); + assert.equal( jQuery( "#ap" ).next( "p" ).length, 0, "Filtered next check, no match" ); + assert.equal( jQuery( "#ap" ).next( "div, p" )[ 0 ].id, "foo", "Multiple filters" ); + assert.equal( jQuery( "body" ).next().length, 0, "Simple next check, no match" ); } ); -test( "prev([String])", function() { - expect( 5 ); - equal( jQuery( "#foo" ).prev()[ 0 ].id, "ap", "Simple prev check" ); - deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).prev().get(), q( "nonnodesElement" ), "Text node prev check" ); - equal( jQuery( "#foo" ).prev( "p" )[ 0 ].id, "ap", "Filtered prev check" ); - equal( jQuery( "#foo" ).prev( "div" ).length, 0, "Filtered prev check, no match" ); - equal( jQuery( "#foo" ).prev( "p, div" )[ 0 ].id, "ap", "Multiple filters" ); +QUnit.test( "prev([String])", function( assert ) { + assert.expect( 5 ); + assert.equal( jQuery( "#foo" ).prev()[ 0 ].id, "ap", "Simple prev check" ); + assert.deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).prev().get(), q( "nonnodesElement" ), "Text node prev check" ); + assert.equal( jQuery( "#foo" ).prev( "p" )[ 0 ].id, "ap", "Filtered prev check" ); + assert.equal( jQuery( "#foo" ).prev( "div" ).length, 0, "Filtered prev check, no match" ); + assert.equal( jQuery( "#foo" ).prev( "p, div" )[ 0 ].id, "ap", "Multiple filters" ); } ); -test( "nextAll([String])", function() { - expect( 5 ); +QUnit.test( "nextAll([String])", function( assert ) { + assert.expect( 5 ); var elems = jQuery( "#form" ).children(); - deepEqual( jQuery( "#label-for" ).nextAll().get(), elems.slice( 1 ).get(), "Simple nextAll check" ); - equal( jQuery( "<div>text<a id='element'></a></div>" ).contents().eq( 0 ).nextAll().attr( "id" ), "element", "Text node nextAll check" ); - deepEqual( jQuery( "#label-for" ).nextAll( "input" ).get(), elems.slice( 1 ).filter( "input" ).get(), "Filtered nextAll check" ); - deepEqual( jQuery( "#label-for" ).nextAll( "input,select" ).get(), elems.slice( 1 ).filter( "input,select" ).get(), "Multiple-filtered nextAll check" ); - deepEqual( jQuery( "#label-for, #hidden1" ).nextAll( "input,select" ).get(), elems.slice( 1 ).filter( "input,select" ).get(), "Multi-source, multiple-filtered nextAll check" ); + assert.deepEqual( jQuery( "#label-for" ).nextAll().get(), elems.slice( 1 ).get(), "Simple nextAll check" ); + assert.equal( jQuery( "<div>text<a id='element'></a></div>" ).contents().eq( 0 ).nextAll().attr( "id" ), "element", "Text node nextAll check" ); + assert.deepEqual( jQuery( "#label-for" ).nextAll( "input" ).get(), elems.slice( 1 ).filter( "input" ).get(), "Filtered nextAll check" ); + assert.deepEqual( jQuery( "#label-for" ).nextAll( "input,select" ).get(), elems.slice( 1 ).filter( "input,select" ).get(), "Multiple-filtered nextAll check" ); + assert.deepEqual( jQuery( "#label-for, #hidden1" ).nextAll( "input,select" ).get(), elems.slice( 1 ).filter( "input,select" ).get(), "Multi-source, multiple-filtered nextAll check" ); } ); -test( "prevAll([String])", function() { - expect( 5 ); +QUnit.test( "prevAll([String])", function( assert ) { + assert.expect( 5 ); var elems = jQuery( jQuery( "#form" ).children().slice( 0, 12 ).get().reverse() ); - deepEqual( jQuery( "#area1" ).prevAll().get(), elems.get(), "Simple prevAll check" ); - deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).prevAll().get(), q( "nonnodesElement" ), "Text node prevAll check" ); - deepEqual( jQuery( "#area1" ).prevAll( "input" ).get(), elems.filter( "input" ).get(), "Filtered prevAll check" ); - deepEqual( jQuery( "#area1" ).prevAll( "input,select" ).get(), elems.filter( "input,select" ).get(), "Multiple-filtered prevAll check" ); - deepEqual( jQuery( "#area1, #hidden1" ).prevAll( "input,select" ).get(), elems.filter( "input,select" ).get(), "Multi-source, multiple-filtered prevAll check" ); + assert.deepEqual( jQuery( "#area1" ).prevAll().get(), elems.get(), "Simple prevAll check" ); + assert.deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).prevAll().get(), q( "nonnodesElement" ), "Text node prevAll check" ); + assert.deepEqual( jQuery( "#area1" ).prevAll( "input" ).get(), elems.filter( "input" ).get(), "Filtered prevAll check" ); + assert.deepEqual( jQuery( "#area1" ).prevAll( "input,select" ).get(), elems.filter( "input,select" ).get(), "Multiple-filtered prevAll check" ); + assert.deepEqual( jQuery( "#area1, #hidden1" ).prevAll( "input,select" ).get(), elems.filter( "input,select" ).get(), "Multi-source, multiple-filtered prevAll check" ); } ); -test( "nextUntil([String])", function() { - expect( 12 ); +QUnit.test( "nextUntil([String])", function( assert ) { + assert.expect( 12 ); var elems = jQuery( "#form" ).children().slice( 2, 12 ); - deepEqual( jQuery( "#text1" ).nextUntil().get(), jQuery( "#text1" ).nextAll().get(), "nextUntil with no selector (nextAll)" ); - equal( jQuery( "<div>text<a id='element'></a></div>" ).contents().eq( 0 ).nextUntil().attr( "id" ), "element", "Text node nextUntil with no selector (nextAll)" ); - deepEqual( jQuery( "#text1" ).nextUntil( ".foo" ).get(), jQuery( "#text1" ).nextAll().get(), "nextUntil with invalid selector (nextAll)" ); - deepEqual( jQuery( "#text1" ).nextUntil( "#area1" ).get(), elems.get(), "Simple nextUntil check" ); - equal( jQuery( "#text1" ).nextUntil( "#text2" ).length, 0, "Simple nextUntil check" ); - deepEqual( jQuery( "#text1" ).nextUntil( "#area1, #radio1" ).get(), jQuery( "#text1" ).next().get(), "Less simple nextUntil check" ); - deepEqual( jQuery( "#text1" ).nextUntil( "#area1", "input" ).get(), elems.not( "button" ).get(), "Filtered nextUntil check" ); - deepEqual( jQuery( "#text1" ).nextUntil( "#area1", "button" ).get(), elems.not( "input" ).get(), "Filtered nextUntil check" ); - deepEqual( jQuery( "#text1" ).nextUntil( "#area1", "button,input" ).get(), elems.get(), "Multiple-filtered nextUntil check" ); - equal( jQuery( "#text1" ).nextUntil( "#area1", "div" ).length, 0, "Filtered nextUntil check, no match" ); - deepEqual( jQuery( "#text1, #hidden1" ).nextUntil( "#area1", "button,input" ).get(), elems.get(), "Multi-source, multiple-filtered nextUntil check" ); + assert.deepEqual( jQuery( "#text1" ).nextUntil().get(), jQuery( "#text1" ).nextAll().get(), "nextUntil with no selector (nextAll)" ); + assert.equal( jQuery( "<div>text<a id='element'></a></div>" ).contents().eq( 0 ).nextUntil().attr( "id" ), "element", "Text node nextUntil with no selector (nextAll)" ); + assert.deepEqual( jQuery( "#text1" ).nextUntil( ".foo" ).get(), jQuery( "#text1" ).nextAll().get(), "nextUntil with invalid selector (nextAll)" ); + assert.deepEqual( jQuery( "#text1" ).nextUntil( "#area1" ).get(), elems.get(), "Simple nextUntil check" ); + assert.equal( jQuery( "#text1" ).nextUntil( "#text2" ).length, 0, "Simple nextUntil check" ); + assert.deepEqual( jQuery( "#text1" ).nextUntil( "#area1, #radio1" ).get(), jQuery( "#text1" ).next().get(), "Less simple nextUntil check" ); + assert.deepEqual( jQuery( "#text1" ).nextUntil( "#area1", "input" ).get(), elems.not( "button" ).get(), "Filtered nextUntil check" ); + assert.deepEqual( jQuery( "#text1" ).nextUntil( "#area1", "button" ).get(), elems.not( "input" ).get(), "Filtered nextUntil check" ); + assert.deepEqual( jQuery( "#text1" ).nextUntil( "#area1", "button,input" ).get(), elems.get(), "Multiple-filtered nextUntil check" ); + assert.equal( jQuery( "#text1" ).nextUntil( "#area1", "div" ).length, 0, "Filtered nextUntil check, no match" ); + assert.deepEqual( jQuery( "#text1, #hidden1" ).nextUntil( "#area1", "button,input" ).get(), elems.get(), "Multi-source, multiple-filtered nextUntil check" ); - deepEqual( jQuery( "#text1" ).nextUntil( "[class=foo]" ).get(), jQuery( "#text1" ).nextAll().get(), "Non-element nodes must be skipped, since they have no attributes" ); + assert.deepEqual( jQuery( "#text1" ).nextUntil( "[class=foo]" ).get(), jQuery( "#text1" ).nextAll().get(), "Non-element nodes must be skipped, since they have no attributes" ); } ); -test( "prevUntil([String])", function() { - expect( 11 ); +QUnit.test( "prevUntil([String])", function( assert ) { + assert.expect( 11 ); var elems = jQuery( "#area1" ).prevAll(); - deepEqual( jQuery( "#area1" ).prevUntil().get(), elems.get(), "prevUntil with no selector (prevAll)" ); - deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).prevUntil().get(), q( "nonnodesElement" ), "Text node prevUntil with no selector (prevAll)" ); - deepEqual( jQuery( "#area1" ).prevUntil( ".foo" ).get(), elems.get(), "prevUntil with invalid selector (prevAll)" ); - deepEqual( jQuery( "#area1" ).prevUntil( "label" ).get(), elems.slice( 0, -1 ).get(), "Simple prevUntil check" ); - equal( jQuery( "#area1" ).prevUntil( "#button" ).length, 0, "Simple prevUntil check" ); - deepEqual( jQuery( "#area1" ).prevUntil( "label, #search" ).get(), jQuery( "#area1" ).prev().get(), "Less simple prevUntil check" ); - deepEqual( jQuery( "#area1" ).prevUntil( "label", "input" ).get(), elems.slice( 0, -1 ).not( "button" ).get(), "Filtered prevUntil check" ); - deepEqual( jQuery( "#area1" ).prevUntil( "label", "button" ).get(), elems.slice( 0, -1 ).not( "input" ).get(), "Filtered prevUntil check" ); - deepEqual( jQuery( "#area1" ).prevUntil( "label", "button,input" ).get(), elems.slice( 0, -1 ).get(), "Multiple-filtered prevUntil check" ); - equal( jQuery( "#area1" ).prevUntil( "label", "div" ).length, 0, "Filtered prevUntil check, no match" ); - deepEqual( jQuery( "#area1, #hidden1" ).prevUntil( "label", "button,input" ).get(), elems.slice( 0, -1 ).get(), "Multi-source, multiple-filtered prevUntil check" ); -} ); - -test( "contents()", function() { - expect( 12 ); + assert.deepEqual( jQuery( "#area1" ).prevUntil().get(), elems.get(), "prevUntil with no selector (prevAll)" ); + assert.deepEqual( jQuery( "#nonnodes" ).contents().eq( 1 ).prevUntil().get(), q( "nonnodesElement" ), "Text node prevUntil with no selector (prevAll)" ); + assert.deepEqual( jQuery( "#area1" ).prevUntil( ".foo" ).get(), elems.get(), "prevUntil with invalid selector (prevAll)" ); + assert.deepEqual( jQuery( "#area1" ).prevUntil( "label" ).get(), elems.slice( 0, -1 ).get(), "Simple prevUntil check" ); + assert.equal( jQuery( "#area1" ).prevUntil( "#button" ).length, 0, "Simple prevUntil check" ); + assert.deepEqual( jQuery( "#area1" ).prevUntil( "label, #search" ).get(), jQuery( "#area1" ).prev().get(), "Less simple prevUntil check" ); + assert.deepEqual( jQuery( "#area1" ).prevUntil( "label", "input" ).get(), elems.slice( 0, -1 ).not( "button" ).get(), "Filtered prevUntil check" ); + assert.deepEqual( jQuery( "#area1" ).prevUntil( "label", "button" ).get(), elems.slice( 0, -1 ).not( "input" ).get(), "Filtered prevUntil check" ); + assert.deepEqual( jQuery( "#area1" ).prevUntil( "label", "button,input" ).get(), elems.slice( 0, -1 ).get(), "Multiple-filtered prevUntil check" ); + assert.equal( jQuery( "#area1" ).prevUntil( "label", "div" ).length, 0, "Filtered prevUntil check, no match" ); + assert.deepEqual( jQuery( "#area1, #hidden1" ).prevUntil( "label", "button,input" ).get(), elems.slice( 0, -1 ).get(), "Multi-source, multiple-filtered prevUntil check" ); +} ); + +QUnit.test( "contents()", function( assert ) { + assert.expect( 12 ); var ibody, c; - equal( jQuery( "#ap" ).contents().length, 9, "Check element contents" ); - ok( jQuery( "#iframe" ).contents()[ 0 ], "Check existence of IFrame document" ); + assert.equal( jQuery( "#ap" ).contents().length, 9, "Check element contents" ); + assert.ok( jQuery( "#iframe" ).contents()[ 0 ], "Check existence of IFrame document" ); ibody = jQuery( "#loadediframe" ).contents()[ 0 ].body; - ok( ibody, "Check existence of IFrame body" ); + assert.ok( ibody, "Check existence of IFrame body" ); - equal( jQuery( "span", ibody ).text(), "span text", "Find span in IFrame and check its text" ); + assert.equal( jQuery( "span", ibody ).text(), "span text", "Find span in IFrame and check its text" ); jQuery( ibody ).append( "<div>init text</div>" ); - equal( jQuery( "div", ibody ).length, 2, "Check the original div and the new div are in IFrame" ); + assert.equal( jQuery( "div", ibody ).length, 2, "Check the original div and the new div are in IFrame" ); - equal( jQuery( "div", ibody ).last().text(), "init text", "Add text to div in IFrame" ); + assert.equal( jQuery( "div", ibody ).last().text(), "init text", "Add text to div in IFrame" ); jQuery( "div", ibody ).last().text( "div text" ); - equal( jQuery( "div", ibody ).last().text(), "div text", "Add text to div in IFrame" ); + assert.equal( jQuery( "div", ibody ).last().text(), "div text", "Add text to div in IFrame" ); jQuery( "div", ibody ).last().remove(); - equal( jQuery( "div", ibody ).length, 1, "Delete the div and check only one div left in IFrame" ); + assert.equal( jQuery( "div", ibody ).length, 1, "Delete the div and check only one div left in IFrame" ); - equal( jQuery( "div", ibody ).text(), "span text", "Make sure the correct div is still left after deletion in IFrame" ); + assert.equal( jQuery( "div", ibody ).text(), "span text", "Make sure the correct div is still left after deletion in IFrame" ); jQuery( "<table/>", ibody ).append( "<tr><td>cell</td></tr>" ).appendTo( ibody ); jQuery( "table", ibody ).remove(); - equal( jQuery( "div", ibody ).length, 1, "Check for JS error on add and delete of a table in IFrame" ); + assert.equal( jQuery( "div", ibody ).length, 1, "Check for JS error on add and delete of a table in IFrame" ); // using contents will get comments regular, text, and comment nodes c = jQuery( "#nonnodes" ).contents().contents(); - equal( c.length, 1, "Check node,textnode,comment contents is just one" ); - equal( c[ 0 ].nodeValue, "hi", "Check node,textnode,comment contents is just the one from span" ); + assert.equal( c.length, 1, "Check node,textnode,comment contents is just one" ); + assert.equal( c[ 0 ].nodeValue, "hi", "Check node,textnode,comment contents is just the one from span" ); } ); -test( "sort direction", function() { - expect( 12 ); +QUnit.test( "sort direction", function( assert ) { + assert.expect( 12 ); var elems = jQuery( "#ap, #select1 > *, #moretests > form" ), methodDirections = { @@ -696,50 +696,50 @@ test( "sort direction", function() { jQuery.each( methodDirections, function( method, reversed ) { var actual = elems[ method ]().get(), forward = jQuery.uniqueSort( [].concat( actual ) ); - deepEqual( actual, reversed ? forward.reverse() : forward, "Correct sort direction for " + method ); + assert.deepEqual( actual, reversed ? forward.reverse() : forward, "Correct sort direction for " + method ); } ); } ); -test( "add(String selector)", function() { - expect( 2 ); +QUnit.test( "add(String selector)", function( assert ) { + assert.expect( 2 ); var divs; - deepEqual( + assert.deepEqual( jQuery( "#sndp" ).add( "#en" ).add( "#sap" ).toArray(), q( "sndp", "en", "sap" ), "Check elements from document" ); divs = jQuery( "<div/>" ).add( "#sndp" ); - ok( divs[ 0 ].parentNode, "Sort with the disconnected node last (started with disconnected first)." ); + assert.ok( divs[ 0 ].parentNode, "Sort with the disconnected node last (started with disconnected first)." ); } ); -test( "add(String selector, String context)", function() { - expect( 1 ); +QUnit.test( "add(String selector, String context)", function( assert ) { + assert.expect( 1 ); - deepEqual( + assert.deepEqual( jQuery( [] ).add( "div", "#nothiddendiv" ).toArray(), q( "nothiddendivchild" ), "Check elements from document" ); } ); -test( "add(String html)", function() { - expect( 3 ); +QUnit.test( "add(String html)", function( assert ) { + assert.expect( 3 ); var x, divs = jQuery( "#sndp" ).add( "<div/>" ); - ok( !divs[ 1 ].parentNode, "Sort with the disconnected node last." ); + assert.ok( !divs[ 1 ].parentNode, "Sort with the disconnected node last." ); x = jQuery( [] ).add( "<p id='x1'>xxx</p>" ).add( "<p id='x2'>xxx</p>" ); - equal( x[ 0 ].id, "x1", "Check detached element1" ); - equal( x[ 1 ].id, "x2", "Check detached element2" ); + assert.equal( x[ 0 ].id, "x1", "Check detached element1" ); + assert.equal( x[ 1 ].id, "x2", "Check detached element2" ); } ); -test( "add(jQuery)", function() { - expect( 4 ); +QUnit.test( "add(jQuery)", function( assert ) { + assert.expect( 4 ); var x, tmp = jQuery( "<div/>" ); @@ -752,8 +752,8 @@ test( "add(jQuery)", function() { jQuery( "<p id='x2'>xxx</p>" ).appendTo( tmp ) ); - equal( x[ 0 ].id, "x1", "Check element1 in detached parent" ); - equal( x[ 1 ].id, "x2", "Check element2 in detached parent" ); + assert.equal( x[ 0 ].id, "x1", "Check element1 in detached parent" ); + assert.equal( x[ 1 ].id, "x2", "Check element2 in detached parent" ); x = jQuery( [] ) .add( @@ -763,33 +763,33 @@ test( "add(jQuery)", function() { jQuery( "<p id='x2'>xxx</p>" ) ); - equal( x[ 0 ].id, "x1", "Check detached element1" ); - equal( x[ 1 ].id, "x2", "Check detached element2" ); + assert.equal( x[ 0 ].id, "x1", "Check detached element1" ); + assert.equal( x[ 1 ].id, "x2", "Check detached element2" ); } ); -test( "add(Element)", function() { - expect( 2 ); +QUnit.test( "add(Element)", function( assert ) { + assert.expect( 2 ); var x, tmp = jQuery( "<div/>" ); x = jQuery( [] ).add( jQuery( "<p id='x1'>xxx</p>" ).appendTo( tmp )[ 0 ] ).add( jQuery( "<p id='x2'>xxx</p>" ).appendTo( tmp )[ 0 ] ); - equal( x[ 0 ].id, "x1", "Check on-the-fly element1" ); - equal( x[ 1 ].id, "x2", "Check on-the-fly element2" ); + assert.equal( x[ 0 ].id, "x1", "Check on-the-fly element1" ); + assert.equal( x[ 1 ].id, "x2", "Check on-the-fly element2" ); } ); -test( "add(Array elements)", function() { - expect( 1 ); +QUnit.test( "add(Array elements)", function( assert ) { + assert.expect( 1 ); - deepEqual( + assert.deepEqual( jQuery( "#sndp" ).add( jQuery( "#en" )[ 0 ] ).add( jQuery( "#sap" ) ).toArray(), q( "sndp", "en", "sap" ), "Check elements from document" ); } ); -test( "add(Window)", function() { - expect( 1 ); +QUnit.test( "add(Window)", function( assert ) { + assert.expect( 1 ); var frame1 = document.createElement( "iframe" ), frame2 = document.createElement( "iframe" ); @@ -800,25 +800,25 @@ test( "add(Window)", function() { // Window is tricky because it is a lot like an array, even Array#slice will // turn it into a multi-item array. - equal( jQuery( [] ).add( window ).length, 1, "Add a window" ); + assert.equal( jQuery( [] ).add( window ).length, 1, "Add a window" ); document.body.removeChild( frame1 ); document.body.removeChild( frame2 ); } ); -test( "add(NodeList|undefined|HTMLFormElement|HTMLSelectElement)", function() { - expect( 4 ); +QUnit.test( "add(NodeList|undefined|HTMLFormElement|HTMLSelectElement)", function( assert ) { + assert.expect( 4 ); var ps, notDefined; ps = document.getElementsByTagName( "p" ); - equal( jQuery( [] ).add( ps ).length, ps.length, "Add a NodeList" ); + assert.equal( jQuery( [] ).add( ps ).length, ps.length, "Add a NodeList" ); - equal( jQuery( [] ).add( notDefined ).length, 0, "Adding undefined adds nothing" ); + assert.equal( jQuery( [] ).add( notDefined ).length, 0, "Adding undefined adds nothing" ); - equal( jQuery( [] ).add( document.getElementById( "form" ) ).length, 1, "Add a form" ); - equal( jQuery( [] ).add( document.getElementById( "select1" ) ).length, 1, "Add a select" ); + assert.equal( jQuery( [] ).add( document.getElementById( "form" ) ).length, 1, "Add a form" ); + assert.equal( jQuery( [] ).add( document.getElementById( "select1" ) ).length, 1, "Add a select" ); // We no longer support .add(form.elements), unfortunately. // There is no way, in browsers, to reliably determine the difference @@ -831,30 +831,30 @@ test( "add(NodeList|undefined|HTMLFormElement|HTMLSelectElement)", function() { //equal( jQuery([]).add(jQuery("#form")[0].elements).length, jQuery(jQuery("#form")[0].elements).length, "Array in constructor must equals array in add()" ); } ); -test( "add(String, Context)", function() { - expect( 6 ); +QUnit.test( "add(String, Context)", function( assert ) { + assert.expect( 6 ); - deepEqual( jQuery( "#firstp" ).add( "#ap" ).get(), q( "firstp", "ap" ), "Add selector to selector " ); - deepEqual( jQuery( document.getElementById( "firstp" ) ).add( "#ap" ).get(), q( "firstp", "ap" ), "Add gEBId to selector" ); - deepEqual( jQuery( document.getElementById( "firstp" ) ).add( document.getElementById( "ap" ) ).get(), q( "firstp", "ap" ), "Add gEBId to gEBId" ); + assert.deepEqual( jQuery( "#firstp" ).add( "#ap" ).get(), q( "firstp", "ap" ), "Add selector to selector " ); + assert.deepEqual( jQuery( document.getElementById( "firstp" ) ).add( "#ap" ).get(), q( "firstp", "ap" ), "Add gEBId to selector" ); + assert.deepEqual( jQuery( document.getElementById( "firstp" ) ).add( document.getElementById( "ap" ) ).get(), q( "firstp", "ap" ), "Add gEBId to gEBId" ); var ctx = document.getElementById( "firstp" ); - deepEqual( jQuery( "#firstp" ).add( "#ap", ctx ).get(), q( "firstp" ), "Add selector to selector " ); - deepEqual( jQuery( document.getElementById( "firstp" ) ).add( "#ap", ctx ).get(), q( "firstp" ), "Add gEBId to selector, not in context" ); - deepEqual( jQuery( document.getElementById( "firstp" ) ).add( "#ap", document.getElementsByTagName( "body" )[ 0 ] ).get(), q( "firstp", "ap" ), "Add gEBId to selector, in context" ); + assert.deepEqual( jQuery( "#firstp" ).add( "#ap", ctx ).get(), q( "firstp" ), "Add selector to selector " ); + assert.deepEqual( jQuery( document.getElementById( "firstp" ) ).add( "#ap", ctx ).get(), q( "firstp" ), "Add gEBId to selector, not in context" ); + assert.deepEqual( jQuery( document.getElementById( "firstp" ) ).add( "#ap", document.getElementsByTagName( "body" )[ 0 ] ).get(), q( "firstp", "ap" ), "Add gEBId to selector, in context" ); } ); -test( "eq('-1') #10616", function() { - expect( 3 ); +QUnit.test( "eq('-1') #10616", function( assert ) { + assert.expect( 3 ); var $divs = jQuery( "div" ); - equal( $divs.eq( -1 ).length, 1, "The number -1 returns a selection that has length 1" ); - equal( $divs.eq( "-1" ).length, 1, "The string '-1' returns a selection that has length 1" ); - deepEqual( $divs.eq( "-1" ), $divs.eq( -1 ), "String and number -1 match" ); + assert.equal( $divs.eq( -1 ).length, 1, "The number -1 returns a selection that has length 1" ); + assert.equal( $divs.eq( "-1" ).length, 1, "The string '-1' returns a selection that has length 1" ); + assert.deepEqual( $divs.eq( "-1" ), $divs.eq( -1 ), "String and number -1 match" ); } ); -test( "index(no arg) #10977", function() { - expect( 2 ); +QUnit.test( "index(no arg) #10977", function( assert ) { + assert.expect( 2 ); var $list, fragment, div; $list = jQuery( "<ul id='indextest'><li class='zero'>THIS ONE</li><li class='one'>a</li><li class='two'>b</li><li class='three'>c</li></ul>" ); @@ -865,17 +865,17 @@ test( "index(no arg) #10977", function() { fragment = document.createDocumentFragment(); div = fragment.appendChild( document.createElement( "div" ) ); - equal( jQuery( div ).index(), 0, "If jQuery#index called on element whose parent is fragment, it still should work correctly" ); + assert.equal( jQuery( div ).index(), 0, "If jQuery#index called on element whose parent is fragment, it still should work correctly" ); } ); -test( "traversing non-elements with attribute filters (#12523)", function() { - expect( 5 ); +QUnit.test( "traversing non-elements with attribute filters (#12523)", function( assert ) { + assert.expect( 5 ); var nonnodes = jQuery( "#nonnodes" ).contents(); - equal( nonnodes.filter( "[id]" ).length, 1, ".filter" ); - equal( nonnodes.find( "[id]" ).length, 0, ".find" ); - strictEqual( nonnodes.is( "[id]" ), true, ".is" ); - deepEqual( nonnodes.closest( "[id='nonnodes']" ).get(), q( "nonnodes" ), ".closest" ); - deepEqual( nonnodes.parents( "[id='nonnodes']" ).get(), q( "nonnodes" ), ".parents" ); + assert.equal( nonnodes.filter( "[id]" ).length, 1, ".filter" ); + assert.equal( nonnodes.find( "[id]" ).length, 0, ".find" ); + assert.strictEqual( nonnodes.is( "[id]" ), true, ".is" ); + assert.deepEqual( nonnodes.closest( "[id='nonnodes']" ).get(), q( "nonnodes" ), ".closest" ); + assert.deepEqual( nonnodes.parents( "[id='nonnodes']" ).get(), q( "nonnodes" ), ".parents" ); } ); diff --git a/test/unit/tween.js b/test/unit/tween.js index cbfdcb14c..42ab03789 100644 --- a/test/unit/tween.js +++ b/test/unit/tween.js @@ -7,7 +7,7 @@ if ( !jQuery.fx ) { var oldRaf = window.requestAnimationFrame; -module( "tween", { +QUnit.module( "tween", { setup: function() { window.requestAnimationFrame = null; this.sandbox = sinon.sandbox.create(); @@ -28,79 +28,109 @@ module( "tween", { } } ); -test( "jQuery.Tween - Default propHooks on plain objects", function() { - expect( 8 ); +QUnit.test( "jQuery.Tween - Default propHooks on plain objects", function( assert ) { + assert.expect( 8 ); var propHooks, defaultHook, testObject, fakeTween, stepSpy; propHooks = jQuery.Tween.propHooks; - equal( typeof propHooks, "object", "jQuery.Tween.propHooks exists" ); + assert.equal( + typeof propHooks, "object", "jQuery.Tween.propHooks exists" + ); defaultHook = propHooks._default; - ok( defaultHook, "_default propHook exists" ); + assert.ok( defaultHook, "_default propHook exists" ); testObject = { test: 0 }; fakeTween = { elem: testObject, prop: "test", now: 10, unit: "px" }; - equal( defaultHook.get( fakeTween ), 0, "Can get property of object" ); + assert.equal( + defaultHook.get( fakeTween ), 0, "Can get property of object" + ); fakeTween.prop = "testMissing"; - equal( defaultHook.get( fakeTween ), undefined, "Can get missing property on object" ); + assert.equal( + defaultHook.get( fakeTween ), undefined, "Can get missing property on object" + ); defaultHook.set( fakeTween ); - equal( testObject.testMissing, 10, "Sets missing value properly on plain object" ); + assert.equal( + testObject.testMissing, 10, "Sets missing value properly on plain object" + ); fakeTween.prop = "opacity"; defaultHook.set( fakeTween ); - equal( testObject.opacity, 10, "Correctly set opacity on plain object" ); + assert.equal( + testObject.opacity, 10, "Correctly set opacity on plain object" + ); fakeTween.prop = "test"; stepSpy = jQuery.fx.step.test = this.sandbox.spy(); defaultHook.set( fakeTween ); - ok( stepSpy.calledWith( fakeTween ), "Step function called with Tween" ); - equal( testObject.test, 0, "Because step didn't set, value is unchanged" ); + assert.ok( stepSpy.calledWith( fakeTween ), "Step function called with Tween" ); + assert.equal( + testObject.test, 0, "Because step didn't set, value is unchanged" + ); } ); -test( "jQuery.Tween - Default propHooks on elements", function() { - expect( 19 ); +QUnit.test( "jQuery.Tween - Default propHooks on elements", function( assert ) { + assert.expect( 19 ); var propHooks, defaultHook, testElement, fakeTween, cssStub, styleStub, stepSpy; propHooks = jQuery.Tween.propHooks; - equal( typeof propHooks, "object", "jQuery.Tween.propHooks exists" ); + assert.equal( + typeof propHooks, "object", "jQuery.Tween.propHooks exists" + ); defaultHook = propHooks._default; - ok( defaultHook, "_default propHook exists" ); + assert.ok( defaultHook, "_default propHook exists" ); testElement = jQuery( "<div>" )[ 0 ]; fakeTween = { elem: testElement, prop: "height", now: 10, unit: "px" }; cssStub = this.sandbox.stub( jQuery, "css" ).returns( 10 ); - equal( defaultHook.get( fakeTween ), 10, "Gets expected style value" ); - ok( cssStub.calledWith( testElement, "height", "" ), "Calls jQuery.css correctly" ); + assert.equal( + defaultHook.get( fakeTween ), 10, "Gets expected style value" + ); + assert.ok( cssStub.calledWith( testElement, "height", "" ), "Calls jQuery.css correctly" ); fakeTween.prop = "testOpti"; testElement.testOpti = 15; cssStub.reset(); - equal( defaultHook.get( fakeTween ), 15, "Gets expected value not defined on style" ); - equal( cssStub.callCount, 0, "Did not call jQuery.css" ); + assert.equal( + defaultHook.get( fakeTween ), 15, "Gets expected value not defined on style" + ); + assert.equal( + cssStub.callCount, 0, "Did not call jQuery.css" + ); fakeTween.prop = "testMissing"; - equal( defaultHook.get( fakeTween ), 10, "Can get missing property on element" ); - ok( cssStub.calledWith( testElement, "testMissing", "" ), "...using jQuery.css" ); + assert.equal( + defaultHook.get( fakeTween ), 10, "Can get missing property on element" + ); + assert.ok( cssStub.calledWith( testElement, "testMissing", "" ), "...using jQuery.css" ); cssStub.returns( "" ); - equal( defaultHook.get( fakeTween ), 0, "Uses 0 for empty string" ); + assert.equal( + defaultHook.get( fakeTween ), 0, "Uses 0 for empty string" + ); cssStub.returns( "auto" ); - equal( defaultHook.get( fakeTween ), 0, "Uses 0 for 'auto'" ); + assert.equal( + defaultHook.get( fakeTween ), 0, "Uses 0 for 'auto'" + ); cssStub.returns( null ); - equal( defaultHook.get( fakeTween ), 0, "Uses 0 for null" ); + assert.equal( + defaultHook.get( fakeTween ), 0, "Uses 0 for null" + ); cssStub.returns( undefined ); - equal( defaultHook.get( fakeTween ), 0, "Uses 0 for undefined" ); + assert.equal( + defaultHook.get( fakeTween ), 0, "Uses 0 for undefined" + ); cssStub.reset(); @@ -109,15 +139,19 @@ test( "jQuery.Tween - Default propHooks on elements", function() { fakeTween.prop = "height"; defaultHook.set( fakeTween ); - ok( styleStub.calledWith( testElement, "height", "10px" ), + assert.ok( styleStub.calledWith( testElement, "height", "10px" ), "Calls jQuery.style with elem, prop, now+unit" ); styleStub.reset(); fakeTween.prop = "testMissing"; defaultHook.set( fakeTween ); - equal( styleStub.callCount, 0, "Did not call jQuery.style for non css property" ); - equal( testElement.testMissing, 10, "Instead, set value on element directly" ); + assert.equal( + styleStub.callCount, 0, "Did not call jQuery.style for non css property" + ); + assert.equal( + testElement.testMissing, 10, "Instead, set value on element directly" + ); jQuery.cssHooks.testMissing = jQuery.noop; fakeTween.now = 11; @@ -125,91 +159,147 @@ test( "jQuery.Tween - Default propHooks on elements", function() { defaultHook.set( fakeTween ); delete jQuery.cssHooks.testMissing; - ok( styleStub.calledWith( testElement, "testMissing", "11px" ), + assert.ok( styleStub.calledWith( testElement, "testMissing", "11px" ), "Presence of cssHooks causes jQuery.style with elem, prop, now+unit" ); - equal( testElement.testMissing, 10, "And value was unchanged" ); + assert.equal( + testElement.testMissing, 10, "And value was unchanged" + ); stepSpy = jQuery.fx.step.test = this.sandbox.spy(); styleStub.reset(); fakeTween.prop = "test"; defaultHook.set( fakeTween ); - ok( stepSpy.calledWith( fakeTween ), "Step function called with Tween" ); - equal( styleStub.callCount, 0, "Did not call jQuery.style" ); + assert.ok( stepSpy.calledWith( fakeTween ), "Step function called with Tween" ); + assert.equal( + styleStub.callCount, 0, "Did not call jQuery.style" + ); } ); -test( "jQuery.Tween - Plain Object", function() { - expect( 13 ); +QUnit.test( "jQuery.Tween - Plain Object", function( assert ) { + assert.expect( 13 ); var testObject = { test: 100 }, testOptions = { duration: 100 }, tween, easingSpy; tween = jQuery.Tween( testObject, testOptions, "test", 0, "linear" ); - equal( tween.elem, testObject, "Sets .element" ); - equal( tween.options, testOptions, "sets .options" ); - equal( tween.prop, "test", "sets .prop" ); - equal( tween.end, 0, "sets .end" ); - - equal( tween.easing, "linear", "sets .easing when provided" ); - - equal( tween.start, 100, "Reads .start value during construction" ); - equal( tween.now, 100, "Reads .now value during construction" ); + assert.equal( + tween.elem, testObject, "Sets .element" + ); + assert.equal( + tween.options, testOptions, "sets .options" + ); + assert.equal( + tween.prop, "test", "sets .prop" + ); + assert.equal( + tween.end, 0, "sets .end" + ); + + assert.equal( + tween.easing, "linear", "sets .easing when provided" + ); + + assert.equal( + tween.start, 100, "Reads .start value during construction" + ); + assert.equal( + tween.now, 100, "Reads .now value during construction" + ); easingSpy = this.sandbox.spy( jQuery.easing, "linear" ); - equal( tween.run( 0.1 ), tween, ".run() returns this" ); + assert.equal( + tween.run( 0.1 ), tween, ".run() returns this" + ); - equal( tween.now, 90, "Calculated tween" ); + assert.equal( + tween.now, 90, "Calculated tween" + ); - ok( easingSpy.calledWith( 0.1, 0.1 * testOptions.duration, 0, 1, testOptions.duration ), + assert.ok( easingSpy.calledWith( 0.1, 0.1 * testOptions.duration, 0, 1, testOptions.duration ), "...using jQuery.easing.linear with back-compat arguments" ); - equal( testObject.test, 90, "Set value" ); + assert.equal( + testObject.test, 90, "Set value" + ); tween.run( 1 ); - equal( testObject.test, 0, "Checking another value" ); + assert.equal( + testObject.test, 0, "Checking another value" + ); tween.run( 0 ); - equal( testObject.test, 100, "Can even go back in time" ); + assert.equal( + testObject.test, 100, "Can even go back in time" + ); } ); -test( "jQuery.Tween - Element", function() { - expect( 15 ); +QUnit.test( "jQuery.Tween - Element", function( assert ) { + assert.expect( 15 ); var testElement = jQuery( "<div>" ).css( "height", 100 )[ 0 ], testOptions = { duration: 100 }, tween, easingSpy, eased; tween = jQuery.Tween( testElement, testOptions, "height", 0 ); - equal( tween.elem, testElement, "Sets .element" ); - equal( tween.options, testOptions, "sets .options" ); - equal( tween.prop, "height", "sets .prop" ); - equal( tween.end, 0, "sets .end" ); - - equal( tween.easing, jQuery.easing._default, "sets .easing to default when not provided" ); - equal( tween.unit, "px", "sets .unit to px when not provided" ); - - equal( tween.start, 100, "Reads .start value during construction" ); - equal( tween.now, 100, "Reads .now value during construction" ); + assert.equal( + tween.elem, testElement, "Sets .element" + ); + assert.equal( + tween.options, testOptions, "sets .options" + ); + assert.equal( + tween.prop, "height", "sets .prop" + ); + assert.equal( + tween.end, 0, "sets .end" + ); + + assert.equal( + tween.easing, jQuery.easing._default, "sets .easing to default when not provided" + ); + assert.equal( + tween.unit, "px", "sets .unit to px when not provided" + ); + + assert.equal( + tween.start, 100, "Reads .start value during construction" + ); + assert.equal( + tween.now, 100, "Reads .now value during construction" + ); easingSpy = this.sandbox.spy( jQuery.easing, "swing" ); - equal( tween.run( 0.1 ), tween, ".run() returns this" ); - equal( tween.pos, jQuery.easing.swing( 0.1 ), "set .pos" ); + assert.equal( + tween.run( 0.1 ), tween, ".run() returns this" + ); + assert.equal( + tween.pos, jQuery.easing.swing( 0.1 ), "set .pos" + ); eased = 100 - ( jQuery.easing.swing( 0.1 ) * 100 ); - equal( tween.now, eased, "Calculated tween" ); + assert.equal( + tween.now, eased, "Calculated tween" + ); - ok( easingSpy.calledWith( 0.1, 0.1 * testOptions.duration, 0, 1, testOptions.duration ), + assert.ok( easingSpy.calledWith( 0.1, 0.1 * testOptions.duration, 0, 1, testOptions.duration ), "...using jQuery.easing.linear with back-compat arguments" ); - equal( Math.floor( parseFloat( testElement.style.height ) ), Math.floor( eased ), "Set value" ); + assert.equal( + Math.floor( parseFloat( testElement.style.height ) ), Math.floor( eased ), "Set value" + ); tween.run( 1 ); - equal( testElement.style.height, "0px", "Checking another value" ); + assert.equal( + testElement.style.height, "0px", "Checking another value" + ); tween.run( 0 ); - equal( testElement.style.height, "100px", "Can even go back in time" ); + assert.equal( + testElement.style.height, "100px", "Can even go back in time" + ); } ); -test( "jQuery.Tween - No duration", function() { - expect( 3 ); +QUnit.test( "jQuery.Tween - No duration", function( assert ) { + assert.expect( 3 ); var testObject = { test: 100 }, testOptions = { duration: 0 }, @@ -219,13 +309,19 @@ test( "jQuery.Tween - No duration", function() { easingSpy = this.sandbox.spy( jQuery.easing, "swing" ); tween.run( 0.5 ); - equal( tween.pos, 0.5, "set .pos correctly" ); - equal( testObject.test, 50, "set value on object correctly" ); - equal( easingSpy.callCount, 0, "didn't ease the value" ); + assert.equal( + tween.pos, 0.5, "set .pos correctly" + ); + assert.equal( + testObject.test, 50, "set value on object correctly" + ); + assert.equal( + easingSpy.callCount, 0, "didn't ease the value" + ); } ); -test( "jQuery.Tween - step function option", function() { - expect( 4 ); +QUnit.test( "jQuery.Tween - step function option", function( assert ) { + assert.expect( 4 ); var testObject = { test: 100 }, testOptions = { duration: 100, step: this.sandbox.spy() }, @@ -234,20 +330,25 @@ test( "jQuery.Tween - step function option", function() { propHookSpy = this.sandbox.spy( jQuery.Tween.propHooks._default, "set" ); tween = jQuery.Tween( testObject, testOptions, "test", 0, "linear" ); - equal( testOptions.step.callCount, 0, "didn't call step on create" ); + assert.equal( + testOptions.step.callCount, 0, "didn't call step on create" + ); tween.run( 0.5 ); - ok( testOptions.step.calledOn( testObject ), + assert.ok( testOptions.step.calledOn( testObject ), "Called step function in context of animated object" ); - ok( testOptions.step.calledWith( 50, tween ), "Called step function with correct parameters" ); + assert.ok( + testOptions.step.calledWith( 50, tween ), + "Called step function with correct parameters" + ); - ok( testOptions.step.calledBefore( propHookSpy ), + assert.ok( testOptions.step.calledBefore( propHookSpy ), "Called step function before calling propHook.set" ); } ); -test( "jQuery.Tween - custom propHooks", function() { - expect( 3 ); +QUnit.test( "jQuery.Tween - custom propHooks", function( assert ) { + assert.expect( 3 ); var testObject = {}, testOptions = { duration: 100, step: this.sandbox.spy() }, @@ -260,17 +361,22 @@ test( "jQuery.Tween - custom propHooks", function() { jQuery.Tween.propHooks.testHooked = propHook; tween = jQuery.Tween( testObject, testOptions, "testHooked", 0, "linear" ); - ok( propHook.get.calledWith( tween ), "called propHook.get on create" ); - equal( tween.now, 100, "Used return value from propHook.get" ); + assert.ok( propHook.get.calledWith( tween ), "called propHook.get on create" ); + assert.equal( + tween.now, 100, "Used return value from propHook.get" + ); tween.run( 0.5 ); - ok( propHook.set.calledWith( tween ), "Called propHook.set function with correct parameters" ); + assert.ok( + propHook.set.calledWith( tween ), + "Called propHook.set function with correct parameters" + ); delete jQuery.Tween.propHooks.testHooked; } ); -test( "jQuery.Tween - custom propHooks - advanced values", function() { - expect( 5 ); +QUnit.test( "jQuery.Tween - custom propHooks - advanced values", function( assert ) { + assert.expect( 5 ); var testObject = {}, testOptions = { duration: 100, step: this.sandbox.spy() }, @@ -283,15 +389,20 @@ test( "jQuery.Tween - custom propHooks - advanced values", function() { jQuery.Tween.propHooks.testHooked = propHook; tween = jQuery.Tween( testObject, testOptions, "testHooked", [ 1, 1 ], "linear" ); - ok( propHook.get.calledWith( tween ), "called propHook.get on create" ); - deepEqual( tween.start, [ 0, 0 ], "Used return value from get" ); + assert.ok( propHook.get.calledWith( tween ), "called propHook.get on create" ); + assert.deepEqual( tween.start, [ 0, 0 ], "Used return value from get" ); tween.run( 0.5 ); // Some day this NaN assumption might change - perhaps add a "calc" helper to the hooks? - ok( isNaN( tween.now ), "Used return value from propHook.get" ); - equal( tween.pos, 0.5, "But the eased percent is still available" ); - ok( propHook.set.calledWith( tween ), "Called propHook.set function with correct parameters" ); + assert.ok( isNaN( tween.now ), "Used return value from propHook.get" ); + assert.equal( + tween.pos, 0.5, "But the eased percent is still available" + ); + assert.ok( + propHook.set.calledWith( tween ), + "Called propHook.set function with correct parameters" + ); delete jQuery.Tween.propHooks.testHooked; } ); diff --git a/test/unit/wrap.js b/test/unit/wrap.js index 6d0760f1d..28077f3a3 100644 --- a/test/unit/wrap.js +++ b/test/unit/wrap.js @@ -4,7 +4,7 @@ if ( !jQuery.fn.wrap ) { // no wrap module return; } -module( "wrap", { +QUnit.module( "wrap", { teardown: moduleTeardown } ); @@ -19,42 +19,50 @@ function manipulationFunctionReturningObj( value ) { }; } -function testWrap( val ) { +function testWrap( val, assert ) { - expect( 19 ); + assert.expect( 19 ); var defaultText, result, j, i, cacheLength; defaultText = "Try them out:"; result = jQuery( "#first" ).wrap( val( "<div class='red'><span></span></div>" ) ).text(); - equal( + assert.equal( defaultText, result, "Check for wrapping of on-the-fly html" ); - ok( jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" ); + assert.ok( + jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" + ); result = jQuery( "#first" ).wrap( val( document.getElementById( "empty" ) ) ).parent(); - ok( result.is( "ol" ), "Check for element wrapping" ); - equal( + assert.ok( + result.is( "ol" ), "Check for element wrapping" + ); + assert.equal( result.text(), defaultText, "Check for element wrapping" ); jQuery( "#check1" ).on( "click", function() { var checkbox = this; - ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" ); + assert.ok( + checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" + ); jQuery( checkbox ).wrap( val( "<div id='c1' style='display:none;'></div>" ) ); - ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" ); + assert.ok( + checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" + ); } ).prop( "checked", false )[ 0 ].click(); // using contents will get comments regular, text, and comment nodes j = jQuery( "#nonnodes" ).contents(); j.wrap( val( "<i></i>" ) ); - equal( + assert.equal( jQuery( "#nonnodes > i" ).length, 3, "Check node,textnode,comment wraps ok" ); - equal( + assert.equal( jQuery( "#nonnodes > i" ).text(), j.text(), "Check node,textnode,comment wraps doesn't hurt text" @@ -67,52 +75,54 @@ function testWrap( val ) { } j = jQuery( "<label/>" ).wrap( val( "<li/>" ) ); - equal( + assert.equal( j[ 0 ] .nodeName.toUpperCase(), "LABEL", "Element is a label" ); - equal( + assert.equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" ); for ( i in jQuery.cache ) { cacheLength--; } - equal( + assert.equal( cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)" ); // Wrap an element containing a text node j = jQuery( "<span/>" ).wrap( "<div>test</div>" ); - equal( + assert.equal( j[ 0 ].previousSibling.nodeType, 3, "Make sure the previous node is a text element" ); - equal( + assert.equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "DIV", "And that we're in the div element." ); // Try to wrap an element with multiple elements (should fail) j = jQuery( "<div><span></span></div>" ).children().wrap( "<p></p><div></div>" ); - equal( + assert.equal( j[ 0 ].parentNode.parentNode.childNodes.length, 1, "There should only be one element wrapping." ); - equal( + assert.equal( j.length, 1, "There should only be one element (no cloning)." ); - equal( + assert.equal( j[ 0 ].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph." ); // Wrap an element with a jQuery set j = jQuery( "<span/>" ).wrap( jQuery( "<div></div>" ) ); - equal( + assert.equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." ); // Wrap an element with a jQuery set and event result = jQuery( "<div></div>" ).on( "click", function() { - ok( true, "Event triggered." ); + assert.ok( + true, "Event triggered." + ); // Remove handlers on detached elements result.off(); @@ -120,7 +130,7 @@ function testWrap( val ) { } ); j = jQuery( "<span/>" ).wrap( result ); - equal( + assert.equal( j[ 0 ].parentNode.nodeName.toLowerCase(), "div", "Wrapping works." ); @@ -128,21 +138,21 @@ function testWrap( val ) { } -test( "wrap(String|Element)", function() { - testWrap( manipulationBareObj ); +QUnit.test( "wrap(String|Element)", function( assert ) { + testWrap( manipulationBareObj, assert ); } ); -test( "wrap(Function)", function() { - testWrap( manipulationFunctionReturningObj ); +QUnit.test( "wrap(Function)", function( assert ) { + testWrap( manipulationFunctionReturningObj, assert ); } ); -test( "wrap(Function) with index (#10177)", function() { +QUnit.test( "wrap(Function) with index (#10177)", function( assert ) { var expectedIndex = 0, targets = jQuery( "#qunit-fixture p" ); - expect( targets.length ); + assert.expect( targets.length ); targets.wrap( function( i ) { - equal( + assert.equal( i, expectedIndex, "Check if the provided index (" + i + ") is as expected (" + expectedIndex + ")" @@ -153,25 +163,28 @@ test( "wrap(Function) with index (#10177)", function() { } ); } ); -test( "wrap(String) consecutive elements (#10177)", function() { +QUnit.test( "wrap(String) consecutive elements (#10177)", function( assert ) { var targets = jQuery( "#qunit-fixture p" ); - expect( targets.length * 2 ); + assert.expect( targets.length * 2 ); targets.wrap( "<div class='wrapper'></div>" ); targets.each( function() { var $this = jQuery( this ); - ok( $this.parent().is( ".wrapper" ), "Check each elements parent is correct (.wrapper)" ); - equal( + assert.ok( + $this.parent().is( ".wrapper" ), + "Check each elements parent is correct (.wrapper)" + ); + assert.equal( $this.siblings().length, 0, "Each element should be wrapped individually" ); } ); } ); -test( "wrapAll(String)", function() { +QUnit.test( "wrapAll(String)", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var prev, p, result; @@ -179,22 +192,28 @@ test( "wrapAll(String)", function() { p = jQuery( "#firstp,#first" )[ 0 ].parentNode; result = jQuery( "#firstp,#first" ).wrapAll( "<div class='red'><div class='tmp'></div></div>" ); - equal( + assert.equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" ); - ok( jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" ); - ok( jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" ); - equal( + assert.ok( + jQuery( "#first" ).parent().parent().is( ".red" ), + "Check if wrapper has class 'red'" + ); + assert.ok( + jQuery( "#firstp" ).parent().parent().is( ".red" ), + "Check if wrapper has class 'red'" + ); + assert.equal( jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" ); - equal( + assert.equal( jQuery( "#first" ).parent().parent()[ 0 ].parentNode, p, "Correct Parent" ); } ); -test( "wrapAll(Function)", function() { - expect( 5 ); +QUnit.test( "wrapAll(Function)", function( assert ) { + assert.expect( 5 ); var prev = jQuery( "#firstp" )[ 0 ].previousSibling, p = jQuery( "#firstp,#first" )[ 0 ].parentNode, @@ -202,19 +221,25 @@ test( "wrapAll(Function)", function() { return "<div class='red'><div class='tmp'></div></div>"; } ); - equal( + assert.equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" ); - ok( jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" ); - ok( jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" ); - ok( jQuery( "#first" ).parent().parent().parent().is( p ), "Correct Parent" ); - strictEqual( + assert.ok( + jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" + ); + assert.ok( + jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" + ); + assert.ok( + jQuery( "#first" ).parent().parent().parent().is( p ), "Correct Parent" + ); + assert.strictEqual( jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" ); } ); -test( "wrapAll(Function) check execution characteristics", function() { - expect( 3 ); +QUnit.test( "wrapAll(Function) check execution characteristics", function( assert ) { + assert.expect( 3 ); var i = 0; @@ -223,20 +248,22 @@ test( "wrapAll(Function) check execution characteristics", function() { return ""; } ); - ok( !i, "should not execute function argument if target element does not exist" ); + assert.ok( + !i, "should not execute function argument if target element does not exist" + ); jQuery( "#firstp" ).wrapAll( function( index ) { - strictEqual( + assert.strictEqual( this, jQuery( "#firstp" )[ 0 ], "context must be the first found element" ); - strictEqual( + assert.strictEqual( index, undefined, "index argument should not be included in function execution" ); } ); } ); -test( "wrapAll(Function)", function() { - expect( 5 ); +QUnit.test( "wrapAll(Function)", function( assert ) { + assert.expect( 5 ); var prev = jQuery( "#firstp" )[ 0 ].previousSibling, p = jQuery( "#firstp,#first" )[ 0 ].parentNode, @@ -244,19 +271,25 @@ test( "wrapAll(Function)", function() { return "<div class='red'><div class='tmp'></div></div>"; } ); - equal( + assert.equal( result.parent().length, 1, "Check for wrapping of on-the-fly html" ); - ok( jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" ); - ok( jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" ); - ok( jQuery( "#first" ).parent().parent().parent().is( p ), "Correct Parent" ); - strictEqual( + assert.ok( + jQuery( "#first" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" + ); + assert.ok( + jQuery( "#firstp" ).parent().parent().is( ".red" ), "Check if wrapper has class 'red'" + ); + assert.ok( + jQuery( "#first" ).parent().parent().parent().is( p ), "Correct Parent" + ); + assert.strictEqual( jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" ); } ); -test( "wrapAll(Function) check execution characteristics", function() { - expect( 3 ); +QUnit.test( "wrapAll(Function) check execution characteristics", function( assert ) { + assert.expect( 3 ); var i = 0; @@ -265,21 +298,23 @@ test( "wrapAll(Function) check execution characteristics", function() { return ""; } ); - ok( !i, "should not execute function argument if target element does not exist" ); + assert.ok( + !i, "should not execute function argument if target element does not exist" + ); jQuery( "#firstp" ).wrapAll( function( index ) { - strictEqual( + assert.strictEqual( this, jQuery( "#firstp" )[ 0 ], "context must be the first found element" ); - strictEqual( + assert.strictEqual( index, undefined, "index argument should not be included in function execution" ); } ); } ); -test( "wrapAll(Element)", function() { +QUnit.test( "wrapAll(Element)", function( assert ) { - expect( 3 ); + assert.expect( 3 ); var prev, p; @@ -287,74 +322,80 @@ test( "wrapAll(Element)", function() { p = jQuery( "#first" )[ 0 ].parentNode; jQuery( "#firstp,#first" ).wrapAll( document.getElementById( "empty" ) ); - equal( + assert.equal( jQuery( "#first" ).parent()[ 0 ], jQuery( "#firstp" ).parent()[ 0 ], "Same Parent" ); - equal( + assert.equal( jQuery( "#first" ).parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" ); - equal( + assert.equal( jQuery( "#first" ).parent()[ 0 ].parentNode, p, "Correct Parent" ); } ); -test( "wrapInner(String)", function() { +QUnit.test( "wrapInner(String)", function( assert ) { - expect( 6 ); + assert.expect( 6 ); var num; num = jQuery( "#first" ).children().length; jQuery( "#first" ).wrapInner( "<div class='red'><div id='tmp'></div></div>" ); - equal( + assert.equal( jQuery( "#first" ).children().length, 1, "Only one child" ); - ok( jQuery( "#first" ).children().is( ".red" ), "Verify Right Element" ); - equal( + assert.ok( + jQuery( "#first" ).children().is( ".red" ), "Verify Right Element" + ); + assert.equal( jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact" ); num = jQuery( "#first" ).html( "foo<div>test</div><div>test2</div>" ).children().length; jQuery( "#first" ).wrapInner( "<div class='red'><div id='tmp'></div></div>" ); - equal( + assert.equal( jQuery( "#first" ).children().length, 1, "Only one child" ); - ok( jQuery( "#first" ).children().is( ".red" ), "Verify Right Element" ); - equal( + assert.ok( + jQuery( "#first" ).children().is( ".red" ), "Verify Right Element" + ); + assert.equal( jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact" ); } ); -test( "wrapInner(Element)", function() { +QUnit.test( "wrapInner(Element)", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var num, div = jQuery( "<div/>" ); num = jQuery( "#first" ).children().length; jQuery( "#first" ).wrapInner( document.getElementById( "empty" ) ); - equal( + assert.equal( jQuery( "#first" ).children().length, 1, "Only one child" ); - ok( jQuery( "#first" ).children().is( "#empty" ), "Verify Right Element" ); - equal( + assert.ok( + jQuery( "#first" ).children().is( "#empty" ), "Verify Right Element" + ); + assert.equal( jQuery( "#first" ).children().children().length, num, "Verify Elements Intact" ); div.wrapInner( "<span></span>" ); - equal( + assert.equal( div.children().length, 1, "The contents were wrapped." ); - equal( + assert.equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." ); } ); -test( "wrapInner(Function) returns String", function() { +QUnit.test( "wrapInner(Function) returns String", function( assert ) { - expect( 6 ); + assert.expect( 6 ); var num, val = manipulationFunctionReturningObj; @@ -362,28 +403,32 @@ test( "wrapInner(Function) returns String", function() { num = jQuery( "#first" ).children().length; jQuery( "#first" ).wrapInner( val( "<div class='red'><div id='tmp'></div></div>" ) ); - equal( + assert.equal( jQuery( "#first" ).children().length, 1, "Only one child" ); - ok( jQuery( "#first" ).children().is( ".red" ), "Verify Right Element" ); - equal( + assert.ok( + jQuery( "#first" ).children().is( ".red" ), "Verify Right Element" + ); + assert.equal( jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact" ); num = jQuery( "#first" ).html( "foo<div>test</div><div>test2</div>" ).children().length; jQuery( "#first" ).wrapInner( val( "<div class='red'><div id='tmp'></div></div>" ) ); - equal( + assert.equal( jQuery( "#first" ).children().length, 1, "Only one child" ); - ok( jQuery( "#first" ).children().is( ".red" ), "Verify Right Element" ); - equal( + assert.ok( + jQuery( "#first" ).children().is( ".red" ), "Verify Right Element" + ); + assert.equal( jQuery( "#first" ).children().children().children().length, num, "Verify Elements Intact" ); } ); -test( "wrapInner(Function) returns Element", function() { +QUnit.test( "wrapInner(Function) returns Element", function( assert ) { - expect( 5 ); + assert.expect( 5 ); var num, val = manipulationFunctionReturningObj, @@ -391,26 +436,28 @@ test( "wrapInner(Function) returns Element", function() { num = jQuery( "#first" ).children().length; jQuery( "#first" ).wrapInner( val( document.getElementById( "empty" ) ) ); - equal( + assert.equal( jQuery( "#first" ).children().length, 1, "Only one child" ); - ok( jQuery( "#first" ).children().is( "#empty" ), "Verify Right Element" ); - equal( + assert.ok( + jQuery( "#first" ).children().is( "#empty" ), "Verify Right Element" + ); + assert.equal( jQuery( "#first" ).children().children().length, num, "Verify Elements Intact" ); div.wrapInner( val( "<span></span>" ) ); - equal( + assert.equal( div.children().length, 1, "The contents were wrapped." ); - equal( + assert.equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." ); } ); -test( "unwrap()", function() { +QUnit.test( "unwrap()", function( assert ) { - expect( 9 ); + assert.expect( 9 ); jQuery( "body" ).append( " <div id='unwrap' style='display: none;'> <div id='unwrap1'> <span class='unwrap'>" + @@ -423,58 +470,58 @@ test( "unwrap()", function() { var abcd = jQuery( "#unwrap1 > span, #unwrap2 > span" ).get(), abcdef = jQuery( "#unwrap span" ).get(); - equal( + assert.equal( jQuery( "#unwrap1 span" ).add( "#unwrap2 span:first-child" ).unwrap().length, 3, "make #unwrap1 and #unwrap2 go away" ); - deepEqual( + assert.deepEqual( jQuery( "#unwrap > span" ).get(), abcd, "all four spans should still exist" ); - deepEqual( + assert.deepEqual( jQuery( "#unwrap3 span" ).unwrap().get(), jQuery( "#unwrap3 > span" ).get(), "make all b in #unwrap3 go away" ); - deepEqual( + assert.deepEqual( jQuery( "#unwrap3 span" ).unwrap().get(), jQuery( "#unwrap > span.unwrap3" ).get(), "make #unwrap3 go away" ); - deepEqual( + assert.deepEqual( jQuery( "#unwrap" ).children().get(), abcdef, "#unwrap only contains 6 child spans" ); - deepEqual( + assert.deepEqual( jQuery( "#unwrap > span" ).unwrap().get(), jQuery( "body > span.unwrap" ).get(), "make the 6 spans become children of body" ); - deepEqual( + assert.deepEqual( jQuery( "body > span.unwrap" ).unwrap().get(), jQuery( "body > span.unwrap" ).get(), "can't unwrap children of body" ); - deepEqual( + assert.deepEqual( jQuery( "body > span.unwrap" ).unwrap().get(), abcdef, "can't unwrap children of body" ); - deepEqual( + assert.deepEqual( jQuery( "body > span.unwrap" ).get(), abcdef, "body contains 6 .unwrap child spans" ); jQuery( "body > span.unwrap" ).remove(); } ); -test( "unwrap( selector )", function() { +QUnit.test( "unwrap( selector )", function( assert ) { - expect( 5 ); + assert.expect( 5 ); jQuery( "body" ).append( " <div id='unwrap' style='display: none;'> <div id='unwrap1'>" + @@ -485,29 +532,29 @@ test( "unwrap( selector )", function() { // Shouldn't unwrap, no match jQuery( "#unwrap1 span" ) .unwrap( "#unwrap2" ); - equal( + assert.equal( jQuery( "#unwrap1" ).length, 1, "still wrapped" ); // Shouldn't unwrap, no match jQuery( "#unwrap1 span" ) .unwrap( "span" ); - equal( + assert.equal( jQuery( "#unwrap1" ).length, 1, "still wrapped" ); // Unwraps jQuery( "#unwrap1 span" ) .unwrap( "#unwrap1" ); - equal( + assert.equal( jQuery( "#unwrap1" ).length, 0, "unwrapped match" ); // Check return values - deepEqual( + assert.deepEqual( jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "quote" ).get(), "return on unmatched unwrap" ); - deepEqual( + assert.deepEqual( jQuery( "#unwrap2 span" ).get(), jQuery( "#unwrap2 span" ).unwrap( "#unwrap2" ).get(), "return on matched unwrap" @@ -516,30 +563,30 @@ test( "unwrap( selector )", function() { jQuery( "body > span.unwrap" ).remove(); } ); -test( "jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", function() { +QUnit.test( "jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var $wraptarget = jQuery( "<div id='wrap-target'>Target</div>" ).appendTo( "#qunit-fixture" ), $section = jQuery( "<section>" ).appendTo( "#qunit-fixture" ); $wraptarget.wrapAll( "<aside style='background-color:green'></aside>" ); - notEqual( + assert.notEqual( $wraptarget.parent( "aside" ).get( 0 ).style.backgroundColor, "transparent", "HTML5 elements created with wrapAll inherit styles" ); - notEqual( + assert.notEqual( $section.get( 0 ).style.backgroundColor, "transparent", "HTML5 elements create with jQuery( string ) inherit styles" ); } ); -test( "wrapping scripts (#10470)", function() { +QUnit.test( "wrapping scripts (#10470)", function( assert ) { - expect( 2 ); + assert.expect( 2 ); var script = document.createElement( "script" ); script.text = script.textContent = @@ -548,7 +595,7 @@ test( "wrapping scripts (#10470)", function() { document.eval10470 = false; jQuery( "#qunit-fixture" ).empty()[ 0 ].appendChild( script ); jQuery( "#qunit-fixture script" ).wrap( "<b></b>" ); - strictEqual( + assert.strictEqual( script.parentNode, jQuery( "#qunit-fixture > b" )[ 0 ], "correctly wrapped" ); jQuery( script ).remove(); |