aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorabnud1 <ahmad13932013@hotmail.com>2019-02-18 19:02:38 +0100
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2019-02-18 19:03:26 +0100
commitc3498187421d0a50ee0369163428481137a04b99 (patch)
tree9f56f408a22f610089474d2f1784f1a680b4d483 /test
parentda44ff39c2c3433e32b757b05b5643edb72fe786 (diff)
downloadjquery-c3498187421d0a50ee0369163428481137a04b99.tar.gz
jquery-c3498187421d0a50ee0369163428481137a04b99.zip
Build: Update test code for compatibility with QUnit 2.x (#4297)
Also, run `grunt npmcopy` to sync the "external" directory with dependencies from package.json. For example, the Sinon library version didn't match. Ref gh-4234 Closes gh-4297
Diffstat (limited to 'test')
-rw-r--r--test/data/cleanScript.html4
-rw-r--r--test/data/inner_module.js2
-rw-r--r--test/data/mock.php6
-rw-r--r--test/data/module.js2
-rw-r--r--test/data/name.html2
-rw-r--r--test/data/test.include.html2
-rw-r--r--test/data/test2.html2
-rw-r--r--test/data/testinit.js11
-rw-r--r--test/data/testrunner.js3
-rw-r--r--test/middleware-mockserver.js6
-rw-r--r--test/unit/ajax.js195
-rw-r--r--test/unit/animation.js4
-rw-r--r--test/unit/attributes.js2
-rw-r--r--test/unit/basic.js2
-rw-r--r--test/unit/callbacks.js2
-rw-r--r--test/unit/core.js18
-rw-r--r--test/unit/css.js4
-rw-r--r--test/unit/data.js6
-rw-r--r--test/unit/deferred.js2
-rw-r--r--test/unit/deprecated.js2
-rw-r--r--test/unit/dimensions.js2
-rw-r--r--test/unit/effects.js8
-rw-r--r--test/unit/event.js7
-rw-r--r--test/unit/exports.js2
-rw-r--r--test/unit/manipulation.js77
-rw-r--r--test/unit/offset.js4
-rw-r--r--test/unit/queue.js67
-rw-r--r--test/unit/selector.js10
-rw-r--r--test/unit/serialize.js2
-rw-r--r--test/unit/support.js2
-rw-r--r--test/unit/traversing.js2
-rw-r--r--test/unit/tween.js12
-rw-r--r--test/unit/wrap.js4
33 files changed, 276 insertions, 200 deletions
diff --git a/test/data/cleanScript.html b/test/data/cleanScript.html
index 69288a858..c37694aac 100644
--- a/test/data/cleanScript.html
+++ b/test/data/cleanScript.html
@@ -1,10 +1,10 @@
<script>
<!--
-ok( true, "script within html comments executed" );
+QUnit.assert.ok( true, "script within html comments executed" );
-->
</script>
<script>
<![CDATA[
-ok( true, "script within CDATA executed" );
+QUnit.assert.ok( true, "script within CDATA executed" );
]]>
</script>
diff --git a/test/data/inner_module.js b/test/data/inner_module.js
index 7f359ed95..b13315a24 100644
--- a/test/data/inner_module.js
+++ b/test/data/inner_module.js
@@ -1 +1 @@
-window.ok( true, "evaluated: inner module with src" );
+QUnit.assert.ok( true, "evaluated: inner module with src" );
diff --git a/test/data/mock.php b/test/data/mock.php
index 52de8ae9d..ba1930415 100644
--- a/test/data/mock.php
+++ b/test/data/mock.php
@@ -16,7 +16,7 @@ class MockServer {
header( 'Content-type: text/javascript' );
} else {
header( 'Content-type: text/html' );
- echo 'ERROR <script>ok( true, "mock executed" );</script>';
+ echo 'ERROR <script>QUnit.assert.ok( true, "mock executed" );</script>';
}
}
@@ -54,7 +54,7 @@ class MockServer {
} else {
header( 'Content-type: text/html' );
}
- echo 'ok( true, "mock executed" );';
+ echo 'QUnit.assert.ok( true, "mock executed" );';
}
// Used to be in test.js, but was renamed to testbar.php
@@ -62,7 +62,7 @@ class MockServer {
protected function testbar( $req ) {
echo 'this.testBar = "bar";
jQuery("#ap").html("bar");
-ok( true, "mock executed");';
+QUnit.assert.ok( true, "mock executed");';
}
protected function json( $req ) {
diff --git a/test/data/module.js b/test/data/module.js
index b0a8a21fd..a3a8c7aec 100644
--- a/test/data/module.js
+++ b/test/data/module.js
@@ -1 +1 @@
-window.ok( true, "evaluated: module with src" );
+QUnit.assert.ok( true, "evaluated: module with src" );
diff --git a/test/data/name.html b/test/data/name.html
index 0fa32d1a8..e360af9bf 100644
--- a/test/data/name.html
+++ b/test/data/name.html
@@ -1 +1 @@
-ERROR <script type="text/javascript">ok( true, "name.html retrieved" );</script>
+ERROR <script type="text/javascript">QUnit.assert.ok( true, "name.html retrieved" );</script>
diff --git a/test/data/test.include.html b/test/data/test.include.html
index 73299db07..ea75074f9 100644
--- a/test/data/test.include.html
+++ b/test/data/test.include.html
@@ -1,7 +1,7 @@
html text<br/>
<script type="text/javascript">/* <![CDATA[ */
testFoo = "foo"; jQuery('#foo').html('foo');
-ok( true, "test.include.html executed" );
+QUnit.assert.ok( true, "test.include.html executed" );
/* ]]> */</script>
<script src="{{baseURL}}mock.php?action=testbar"></script>
blabla
diff --git a/test/data/test2.html b/test/data/test2.html
index 1df6151a0..c7fff22fb 100644
--- a/test/data/test2.html
+++ b/test/data/test2.html
@@ -1,5 +1,5 @@
<script type="text/javascript">
var testFoo = "foo";
jQuery('#foo').html('foo');
-ok( true, "test2.html executed" );
+QUnit.assert.ok( true, "test2.html executed" );
</script>
diff --git a/test/data/testinit.js b/test/data/testinit.js
index a87ebf206..e1d81c5c7 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -48,7 +48,7 @@ this.q = function() {
* @param {(String|Node)=document} context - Selector context
* @example match("Check for something", "p", ["foo", "bar"]);
*/
-function match( message, selector, expectedIds, context ) {
+function match( message, selector, expectedIds, context, assert ) {
var f = jQuery( selector, context ).get(),
s = "",
i = 0;
@@ -57,7 +57,7 @@ function match( message, selector, expectedIds, context ) {
s += ( s && "," ) + "\"" + f[ i ].id + "\"";
}
- this.deepEqual( f, q.apply( q, expectedIds ), message + " (" + selector + ")" );
+ assert.deepEqual( f, q.apply( q, expectedIds ), message + " (" + selector + ")" );
}
/**
@@ -69,7 +69,7 @@ function match( message, selector, expectedIds, context ) {
* @example t("Check for something", "p", ["foo", "bar"]);
*/
QUnit.assert.t = function( message, selector, expectedIds ) {
- match( message, selector, expectedIds, undefined );
+ match( message, selector, expectedIds, undefined, QUnit.assert );
};
/**
@@ -81,7 +81,7 @@ QUnit.assert.t = function( message, selector, expectedIds ) {
* @example selectInFixture("Check for something", "p", ["foo", "bar"]);
*/
QUnit.assert.selectInFixture = function( message, selector, expectedIds ) {
- match( message, selector, expectedIds, "#qunit-fixture" );
+ match( message, selector, expectedIds, "#qunit-fixture", QUnit.assert );
};
this.createDashboardXML = function() {
@@ -174,7 +174,8 @@ function url( value ) {
// Ajax testing helper
this.ajaxTest = function( title, expect, options ) {
- QUnit.test( title, expect, function( assert ) {
+ QUnit.test( title, function( assert ) {
+ assert.expect( expect );
var requestOptions;
if ( typeof options === "function" ) {
diff --git a/test/data/testrunner.js b/test/data/testrunner.js
index d5120c6a0..39000c33b 100644
--- a/test/data/testrunner.js
+++ b/test/data/testrunner.js
@@ -13,8 +13,7 @@ var oldCacheLength = 0,
* QUnit configuration
*/
-// Max time for stop() and asyncTest() until it aborts test
-// and start()'s the next test.
+// Max time for done() to fire in an async test.
QUnit.config.testTimeout = 60e3; // 1 minute
// Enforce an "expect" argument or expect() call in all test bodies.
diff --git a/test/middleware-mockserver.js b/test/middleware-mockserver.js
index 12c2e7533..20a660714 100644
--- a/test/middleware-mockserver.js
+++ b/test/middleware-mockserver.js
@@ -21,7 +21,7 @@ var mocks = {
resp.writeHead( 200, { "content-type": "text/javascript" } );
} else {
resp.writeHead( 200, { "content-type": "text/html" } );
- resp.end( "ERROR <script>ok( true, \"mock executed\" );</script>" );
+ resp.end( "ERROR <script>QUnit.assert.ok( true, \"mock executed\" );</script>" );
}
}, wait );
},
@@ -67,14 +67,14 @@ var mocks = {
} else {
resp.writeHead( 200, { "content-type": "text/html" } );
}
- resp.end( "ok( true, \"mock executed\" );" );
+ resp.end( "QUnit.assert.ok( true, \"mock executed\" );" );
},
testbar: function( req, resp ) {
resp.writeHead( 200 );
resp.end(
"this.testBar = 'bar'; " +
"jQuery('#ap').html('bar'); " +
- "ok( true, 'mock executed');"
+ "QUnit.assert.ok( true, 'mock executed');"
);
},
json: function( req, resp ) {
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index 3defc0ea8..35f7bba6b 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -1,5 +1,5 @@
QUnit.module( "ajax", {
- teardown: function() {
+ afterEach: function() {
jQuery( document ).off( "ajaxStart ajaxStop ajaxSend ajaxComplete ajaxError ajaxSuccess" );
moduleTeardown.apply( this, arguments );
}
@@ -221,9 +221,11 @@ QUnit.module( "ajax", {
};
} );
- QUnit.asyncTest( "jQuery.ajax() - retry with jQuery.ajax( this )", 2, function( assert ) {
+ QUnit.test( "jQuery.ajax() - retry with jQuery.ajax( this )", function( assert ) {
+ assert.expect( 2 );
var previousUrl,
- firstTime = true;
+ firstTime = true,
+ done = assert.async();
jQuery.ajax( {
url: url( "mock.php?action=error" ),
error: function() {
@@ -239,7 +241,7 @@ QUnit.module( "ajax", {
previousUrl = this.url;
} else {
assert.strictEqual( this.url, previousUrl, "url parameters are not re-appended" );
- QUnit.start();
+ done();
return false;
}
},
@@ -856,7 +858,9 @@ QUnit.module( "ajax", {
};
} );
- QUnit.asyncTest( "jQuery.ajax(), jQuery.get[Script|JSON](), jQuery.post(), pass-through request object", 8, function( assert ) {
+ QUnit.test( "jQuery.ajax(), jQuery.get[Script|JSON](), jQuery.post(), pass-through request object", function( assert ) {
+ assert.expect( 8 );
+ var done = assert.async();
var target = "name.html",
successCount = 0,
errorCount = 0,
@@ -872,7 +876,7 @@ QUnit.module( "ajax", {
assert.equal( successCount, 5, "Check all ajax calls successful" );
assert.equal( errorCount, 0, "Check no ajax errors (status" + errorEx + ")" );
jQuery( document ).off( "ajaxError.passthru" );
- QUnit.start();
+ done();
} );
Globals.register( "testBar" );
@@ -1376,7 +1380,9 @@ QUnit.module( "ajax", {
},
function( type, url ) {
url = baseURL + url + "&ts=" + ifModifiedNow++;
- QUnit.asyncTest( "jQuery.ajax() - " + type + " support" + label, 4, function( assert ) {
+ QUnit.test( "jQuery.ajax() - " + type + " support" + label, function( assert ) {
+ assert.expect( 4 );
+ var done = assert.async();
jQuery.ajax( {
url: url,
ifModified: true,
@@ -1393,7 +1399,7 @@ QUnit.module( "ajax", {
assert.equal( data, null, "no response body is given" );
},
complete: function() {
- QUnit.start();
+ done();
}
} );
}
@@ -1434,24 +1440,27 @@ QUnit.module( "ajax", {
};
} );
- QUnit.asyncTest( "jQuery.ajax() - statusText", 3, function( assert ) {
+ QUnit.test( "jQuery.ajax() - statusText", function( assert ) {
+ assert.expect( 3 );
+ var done = assert.async();
jQuery.ajax( url( "mock.php?action=status&code=200&text=Hello" ) ).done( function( _, statusText, jqXHR ) {
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( "mock.php?action=status&code=404&text=World" ) ).fail( function( jqXHR, statusText ) {
assert.strictEqual( statusText, "error", "callback status text ok for error" );
- QUnit.start();
+ done();
} );
} );
} );
- QUnit.asyncTest( "jQuery.ajax() - statusCode", 20, function( assert ) {
-
- var count = 12;
+ QUnit.test( "jQuery.ajax() - statusCode", function( assert ) {
+ assert.expect( 20 );
+ var done = assert.async(),
+ count = 12;
function countComplete() {
if ( !--count ) {
- QUnit.start();
+ done();
}
}
@@ -1853,12 +1862,14 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
}
- QUnit.asyncTest( "#11743 - jQuery.ajax() - script, throws exception", 1, function( assert ) {
+ QUnit.test( "#11743 - jQuery.ajax() - script, throws exception", function( assert ) {
+ assert.expect( 1 );
+ var done = assert.async();
var onerror = window.onerror;
window.onerror = function() {
assert.ok( true, "Exception thrown" );
window.onerror = onerror;
- QUnit.start();
+ done();
};
jQuery.ajax( {
url: baseURL + "badjson.js",
@@ -2148,29 +2159,33 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
//----------- jQuery.ajaxSetup()
- QUnit.asyncTest( "jQuery.ajaxSetup()", 1, function( assert ) {
+ QUnit.test( "jQuery.ajaxSetup()", function( assert ) {
+ assert.expect( 1 );
+ var done = assert.async();
jQuery.ajaxSetup( {
url: url( "mock.php?action=name&name=foo" ),
success: function( msg ) {
assert.strictEqual( msg, "bar", "Check for GET" );
- QUnit.start();
+ done();
}
} );
jQuery.ajax();
} );
- QUnit.asyncTest( "jQuery.ajaxSetup({ timeout: Number }) - with global timeout", 2, function( assert ) {
+ QUnit.test( "jQuery.ajaxSetup({ timeout: Number }) - with global timeout", function( assert ) {
+ assert.expect( 2 );
+ var done = assert.async();
var passed = 0,
pass = function() {
assert.ok( passed++ < 2, "Error callback executed" );
if ( passed === 2 ) {
jQuery( document ).off( "ajaxError.setupTest" );
- QUnit.start();
+ done();
}
},
fail = function( a, b ) {
assert.ok( false, "Check for timeout failed " + a + " " + b );
- QUnit.start();
+ done();
};
jQuery( document ).on( "ajaxError.setupTest", pass );
@@ -2187,7 +2202,9 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
} );
- QUnit.asyncTest( "jQuery.ajaxSetup({ timeout: Number }) with localtimeout", 1, function( assert ) {
+ QUnit.test( "jQuery.ajaxSetup({ timeout: Number }) with localtimeout", function( assert ) {
+ assert.expect( 1 );
+ var done = assert.async();
jQuery.ajaxSetup( {
timeout: 50
} );
@@ -2197,11 +2214,11 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
url: url( "mock.php?action=wait&wait=1" ),
error: function() {
assert.ok( false, "Check for local timeout failed" );
- QUnit.start();
+ done();
},
success: function() {
assert.ok( true, "Check for local timeout" );
- QUnit.start();
+ done();
}
} );
} );
@@ -2225,8 +2242,9 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
QUnit.test(
- "jQuery#load() - always use GET method even if it overrided through ajaxSetup (#11264)", 1,
+ "jQuery#load() - always use GET method even if it overrided through ajaxSetup (#11264)",
function( assert ) {
+ assert.expect( 1 );
var done = assert.async();
jQuery.ajaxSetup( {
@@ -2241,8 +2259,9 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
);
QUnit.test(
- "jQuery#load() - should resolve with correct context", 2,
+ "jQuery#load() - should resolve with correct context",
function( assert ) {
+ assert.expect( 2 );
var done = assert.async();
var ps = jQuery( "<p></p><p></p>" );
var i = 0;
@@ -2260,15 +2279,18 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
);
QUnit.test(
- "#11402 - jQuery.domManip() - script in comments are properly evaluated", 2,
+ "#11402 - jQuery.domManip() - script in comments are properly evaluated",
function( assert ) {
+ assert.expect( 2 );
jQuery( "#qunit-fixture" ).load( baseURL + "cleanScript.html", assert.async() );
}
);
//----------- jQuery.get()
- QUnit.asyncTest( "jQuery.get( String, Hash, Function ) - parse xml and use text() on nodes", 2, function( assert ) {
+ QUnit.test( "jQuery.get( String, Hash, Function ) - parse xml and use text() on nodes", function( assert ) {
+ assert.expect( 2 );
+ var done = assert.async();
jQuery.get( url( "dashboard.xml" ), function( xml ) {
var content = [];
jQuery( "tab", xml ).each( function() {
@@ -2276,23 +2298,27 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
assert.strictEqual( content[ 0 ], "blabla", "Check first tab" );
assert.strictEqual( content[ 1 ], "blublu", "Check second tab" );
- QUnit.start();
+ done();
} );
} );
- QUnit.asyncTest( "#8277 - jQuery.get( String, Function ) - data in ajaxSettings", 1, function( assert ) {
+ QUnit.test( "#8277 - jQuery.get( String, Function ) - data in ajaxSettings", function( assert ) {
+ assert.expect( 1 );
+ var done = assert.async();
jQuery.ajaxSetup( {
data: "helloworld"
} );
jQuery.get( url( "mock.php?action=echoQuery" ), function( data ) {
assert.ok( /helloworld$/.test( data ), "Data from ajaxSettings was used" );
- QUnit.start();
+ done();
} );
} );
//----------- jQuery.getJSON()
- QUnit.asyncTest( "jQuery.getJSON( String, Hash, Function ) - JSON array", 5, function( assert ) {
+ QUnit.test( "jQuery.getJSON( String, Hash, Function ) - JSON array", function( assert ) {
+ assert.expect( 5 );
+ var done = assert.async();
jQuery.getJSON(
url( "mock.php?action=json" ),
{
@@ -2304,22 +2330,26 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
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();
+ done();
}
);
} );
- QUnit.asyncTest( "jQuery.getJSON( String, Function ) - JSON object", 2, function( assert ) {
+ QUnit.test( "jQuery.getJSON( String, Function ) - JSON object", function( assert ) {
+ assert.expect( 2 );
+ var done = assert.async();
jQuery.getJSON( url( "mock.php?action=json" ), function( json ) {
if ( json && json[ "data" ] ) {
assert.strictEqual( json[ "data" ][ "lang" ], "en", "Check JSON: lang" );
assert.strictEqual( json[ "data" ].length, 25, "Check JSON: length" );
- QUnit.start();
+ done();
}
} );
} );
- QUnit.asyncTest( "jQuery.getJSON( String, Function ) - JSON object with absolute url to local content", 2, function( assert ) {
+ QUnit.test( "jQuery.getJSON( String, Function ) - JSON object with absolute url to local content", function( assert ) {
+ assert.expect( 2 );
+ var done = assert.async();
var absoluteUrl = url( "mock.php?action=json" );
// Make a relative URL absolute relative to the document location
@@ -2338,14 +2368,15 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
jQuery.getJSON( absoluteUrl, function( json ) {
assert.strictEqual( json.data.lang, "en", "Check JSON: lang" );
assert.strictEqual( json.data.length, 25, "Check JSON: length" );
- QUnit.start();
+ done();
} );
} );
//----------- jQuery.getScript()
- QUnit.test( "jQuery.getScript( String, Function ) - with callback", 2,
+ QUnit.test( "jQuery.getScript( String, Function ) - with callback",
function( assert ) {
+ assert.expect( 2 );
var done = assert.async();
Globals.register( "testBar" );
@@ -2356,12 +2387,14 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
}
);
- QUnit.test( "jQuery.getScript( String, Function ) - no callback", 1, function( assert ) {
+ QUnit.test( "jQuery.getScript( String, Function ) - no callback", function( assert ) {
+ assert.expect( 1 );
Globals.register( "testBar" );
jQuery.getScript( url( "mock.php?action=testbar" ) ).done( assert.async() );
} );
- QUnit.test( "#8082 - jQuery.getScript( String, Function ) - source as responseText", 2, function( assert ) {
+ QUnit.test( "#8082 - jQuery.getScript( String, Function ) - source as responseText", function( assert ) {
+ assert.expect( 2 );
var done = assert.async();
Globals.register( "testBar" );
@@ -2371,7 +2404,8 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
} );
- QUnit.test( "jQuery.getScript( Object ) - with callback", 2, function( assert ) {
+ QUnit.test( "jQuery.getScript( Object ) - with callback", function( assert ) {
+ assert.expect( 2 );
var done = assert.async();
Globals.register( "testBar" );
@@ -2384,7 +2418,8 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
} );
- QUnit.test( "jQuery.getScript( Object ) - no callback", 1, function( assert ) {
+ QUnit.test( "jQuery.getScript( Object ) - no callback", function( assert ) {
+ assert.expect( 1 );
Globals.register( "testBar" );
jQuery.getScript( { url: url( "mock.php?action=testbar" ) } ).done( assert.async() );
} );
@@ -2392,7 +2427,8 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
// //----------- jQuery.fn.load()
// check if load can be called with only url
- QUnit.test( "jQuery.fn.load( String )", 2, function( assert ) {
+ QUnit.test( "jQuery.fn.load( String )", function( assert ) {
+ assert.expect( 2 );
jQuery.ajaxSetup( {
beforeSend: function() {
assert.strictEqual( this.type, "GET", "no data means GET request" );
@@ -2413,7 +2449,8 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
// check if load can be called with url and null data
- QUnit.test( "jQuery.fn.load( String, null )", 2, function( assert ) {
+ QUnit.test( "jQuery.fn.load( String, null )", function( assert ) {
+ assert.expect( 2 );
jQuery.ajaxSetup( {
beforeSend: function() {
assert.strictEqual( this.type, "GET", "no data means GET request" );
@@ -2423,7 +2460,8 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
// check if load can be called with url and undefined data
- QUnit.test( "jQuery.fn.load( String, undefined )", 2, function( assert ) {
+ QUnit.test( "jQuery.fn.load( String, undefined )", function( assert ) {
+ assert.expect( 2 );
jQuery.ajaxSetup( {
beforeSend: function() {
assert.strictEqual( this.type, "GET", "no data means GET request" );
@@ -2433,18 +2471,22 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
// check if load can be called with only url
- QUnit.asyncTest( "jQuery.fn.load( URL_SELECTOR )", 1, function( assert ) {
+ QUnit.test( "jQuery.fn.load( URL_SELECTOR )", function( assert ) {
+ assert.expect( 1 );
+ var done = assert.async();
jQuery( "#first" ).load( baseURL + "test3.html div.user", function() {
assert.strictEqual( jQuery( this ).children( "div" ).length, 2, "Verify that specific elements were injected" );
- QUnit.start();
+ done();
} );
} );
// Selector should be trimmed to avoid leading spaces (#14773)
- QUnit.asyncTest( "jQuery.fn.load( URL_SELECTOR with spaces )", 1, function( assert ) {
+ QUnit.test( "jQuery.fn.load( URL_SELECTOR with spaces )", function( assert ) {
+ assert.expect( 1 );
+ var done = assert.async();
jQuery( "#first" ).load( baseURL + "test3.html #superuser ", function() {
assert.strictEqual( jQuery( this ).children( "div" ).length, 1, "Verify that specific elements were injected" );
- QUnit.start();
+ done();
} );
} );
@@ -2459,18 +2501,22 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
} );
- QUnit.asyncTest( "jQuery.fn.load( String, Function ) - simple: inject text into DOM", 2, function( assert ) {
+ QUnit.test( "jQuery.fn.load( String, Function ) - simple: inject text into DOM", function( assert ) {
+ assert.expect( 2 );
+ var done = assert.async();
jQuery( "#first" ).load( url( "name.html" ), function() {
assert.ok( /^ERROR/.test( jQuery( "#first" ).text() ), "Check if content was injected into the DOM" );
- QUnit.start();
+ done();
} );
} );
- QUnit.asyncTest( "jQuery.fn.load( String, Function ) - check scripts", 7, function( assert ) {
+ QUnit.test( "jQuery.fn.load( String, Function ) - check scripts", function( assert ) {
+ assert.expect( 7 );
+ var done = assert.async();
var verifyEvaluation = function() {
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();
+ done();
};
Globals.register( "testFoo" );
@@ -2484,17 +2530,21 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
} );
- QUnit.asyncTest( "jQuery.fn.load( String, Function ) - check file with only a script tag", 3, function( assert ) {
+ QUnit.test( "jQuery.fn.load( String, Function ) - check file with only a script tag", function( assert ) {
+ assert.expect( 3 );
+ var done = assert.async();
Globals.register( "testFoo" );
jQuery( "#first" ).load( url( "test2.html" ), function() {
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();
+ done();
} );
} );
- QUnit.asyncTest( "jQuery.fn.load( String, Function ) - dataFilter in ajaxSettings", 2, function( assert ) {
+ QUnit.test( "jQuery.fn.load( String, Function ) - dataFilter in ajaxSettings", function( assert ) {
+ assert.expect( 2 );
+ var done = assert.async();
jQuery.ajaxSetup( {
dataFilter: function() {
return "Hello World";
@@ -2503,22 +2553,25 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
jQuery( "<div/>" ).load( url( "name.html" ), function( responseText ) {
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();
+ done();
} );
} );
- QUnit.asyncTest( "jQuery.fn.load( String, Object, Function )", 2, function( assert ) {
+ QUnit.test( "jQuery.fn.load( String, Object, Function )", function( assert ) {
+ assert.expect( 2 );
+ var done = assert.async();
jQuery( "<div />" ).load( url( "mock.php?action=echoHtml" ), {
"bar": "ok"
}, function() {
var $node = jQuery( this );
assert.strictEqual( $node.find( "#method" ).text(), "POST", "Check method" );
assert.strictEqual( $node.find( "#data" ).text(), "bar=ok", "Check if data is passed correctly" );
- QUnit.start();
+ done();
} );
} );
- QUnit.test( "jQuery.fn.load( String, String, Function )", 2, function( assert ) {
+ QUnit.test( "jQuery.fn.load( String, String, Function )", function( assert ) {
+ assert.expect( 2 );
var done = assert.async();
jQuery( "<div />" ).load( url( "mock.php?action=echoHtml" ), "foo=3&bar=ok", function() {
@@ -2529,9 +2582,10 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
} );
- QUnit.test( "jQuery.fn.load() - callbacks get the correct parameters", 8, function( assert ) {
- var completeArgs = {};
- var done = assert.async();
+ QUnit.test( "jQuery.fn.load() - callbacks get the correct parameters", function( assert ) {
+ assert.expect( 8 );
+ var completeArgs = {},
+ done = assert.async();
jQuery.ajaxSetup( {
success: function( _, status, jqXHR ) {
@@ -2569,7 +2623,8 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
).always( done );
} );
- QUnit.test( "#2046 - jQuery.fn.load( String, Function ) with ajaxSetup on dataType json", 1, function( assert ) {
+ QUnit.test( "#2046 - jQuery.fn.load( String, Function ) with ajaxSetup on dataType json", function( assert ) {
+ assert.expect( 1 );
var done = assert.async();
jQuery.ajaxSetup( {
@@ -2583,7 +2638,8 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
jQuery( "#first" ).load( baseURL + "test3.html" );
} );
- QUnit.test( "#10524 - jQuery.fn.load() - data specified in ajaxSettings is merged in", 1, function( assert ) {
+ QUnit.test( "#10524 - jQuery.fn.load() - data specified in ajaxSettings is merged in", function( assert ) {
+ assert.expect( 1 );
var done = assert.async();
var data = {
@@ -2603,7 +2659,8 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
// //----------- jQuery.post()
- QUnit.test( "jQuery.post() - data", 3, function( assert ) {
+ QUnit.test( "jQuery.post() - data", function( assert ) {
+ assert.expect( 3 );
var done = assert.async();
jQuery.when(
@@ -2635,7 +2692,8 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
).always( done );
} );
- QUnit.test( "jQuery.post( String, Hash, Function ) - simple with xml", 4, function( assert ) {
+ QUnit.test( "jQuery.post( String, Hash, Function ) - simple with xml", function( assert ) {
+ assert.expect( 4 );
var done = assert.async();
jQuery.when(
@@ -2662,7 +2720,8 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
} );
} );
- QUnit.test( "jQuery[get|post]( options ) - simple with xml", 2, function( assert ) {
+ QUnit.test( "jQuery[get|post]( options ) - simple with xml", function( assert ) {
+ assert.expect( 2 );
var done = assert.async();
jQuery.when.apply( jQuery,
diff --git a/test/unit/animation.js b/test/unit/animation.js
index dfa00ac8d..7a51add31 100644
--- a/test/unit/animation.js
+++ b/test/unit/animation.js
@@ -12,7 +12,7 @@ var oldRaf = window.requestAnimationFrame,
// This module tests jQuery.Animation and the corresponding 1.8+ effects APIs
QUnit.module( "animation", {
- setup: function() {
+ beforeEach: function() {
window.requestAnimationFrame = null;
this.sandbox = sinon.sandbox.create();
this.clock = this.sandbox.useFakeTimers( startTime );
@@ -22,7 +22,7 @@ QUnit.module( "animation", {
jQuery.Animation.prefilters = [ defaultPrefilter ];
jQuery.Animation.tweeners = { "*": [ defaultTweener ] };
},
- teardown: function() {
+ afterEach: function() {
this.sandbox.restore();
jQuery.fx.stop();
jQuery.fx.interval = this._oldInterval;
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index 5d88634a0..7d5d2de1a 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -1,5 +1,5 @@
QUnit.module( "attributes", {
- teardown: moduleTeardown
+ afterEach: moduleTeardown
} );
function bareObj( value ) {
diff --git a/test/unit/basic.js b/test/unit/basic.js
index 811d337a4..b57c0c0ba 100644
--- a/test/unit/basic.js
+++ b/test/unit/basic.js
@@ -1,4 +1,4 @@
-QUnit.module( "basic", { teardown: moduleTeardown } );
+QUnit.module( "basic", { afterEach: moduleTeardown } );
if ( jQuery.ajax ) {
QUnit.test( "ajax", function( assert ) {
diff --git a/test/unit/callbacks.js b/test/unit/callbacks.js
index 04d44443d..b440f3822 100644
--- a/test/unit/callbacks.js
+++ b/test/unit/callbacks.js
@@ -1,5 +1,5 @@
QUnit.module( "callbacks", {
- teardown: moduleTeardown
+ afterEach: moduleTeardown
} );
( function() {
diff --git a/test/unit/core.js b/test/unit/core.js
index fba05b0ec..260038300 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -1,8 +1,8 @@
QUnit.module( "core", {
- setup: function() {
+ beforeEach: function() {
this.sandbox = sinon.sandbox.create();
},
- teardown: function() {
+ afterEach: function() {
this.sandbox.restore();
return moduleTeardown.apply( this, arguments );
}
@@ -238,7 +238,8 @@ QUnit.test( "trim", function( assert ) {
assert.equal( jQuery.trim( "\uFEFF \xA0! | \uFEFF" ), "! |", "leading/trailing should be trimmed" );
} );
-QUnit.asyncTest( "isPlainObject", function( assert ) {
+QUnit.test( "isPlainObject", function( assert ) {
+ var done = assert.async();
assert.expect( 23 );
@@ -314,7 +315,7 @@ QUnit.asyncTest( "isPlainObject", function( assert ) {
window.iframeDone = undefined;
iframe.parentNode.removeChild( iframe );
assert.ok( jQuery.isPlainObject( new otherObject() ), "new otherObject" + ( detail ? " - " + detail : "" ) );
- QUnit.start();
+ done();
};
try {
@@ -380,14 +381,14 @@ QUnit.test( "isXMLDoc - HTML", function( assert ) {
} );
QUnit.test( "XSS via location.hash", function( assert ) {
+ var done = assert.async();
assert.expect( 1 );
- QUnit.stop();
jQuery[ "_check9521" ] = function( x ) {
assert.ok( x, "script called from #id-like selector with inline handler" );
jQuery( "#check9521" ).remove();
delete jQuery[ "_check9521" ];
- QUnit.start();
+ done();
};
try {
@@ -1312,7 +1313,8 @@ QUnit.test( "jQuery.parseHTML(<a href>) - gh-2965", function( assert ) {
} );
if ( jQuery.support.createHTMLDocument ) {
- QUnit.asyncTest( "jQuery.parseHTML", function( assert ) {
+ QUnit.test( "jQuery.parseHTML", function( assert ) {
+ var done = assert.async();
assert.expect( 1 );
Globals.register( "parseHTMLError" );
@@ -1321,8 +1323,8 @@ if ( jQuery.support.createHTMLDocument ) {
jQuery.parseHTML( "<img src=x onerror='parseHTMLError = true'>" );
window.setTimeout( function() {
- QUnit.start();
assert.equal( window.parseHTMLError, false, "onerror eventhandler has not been called." );
+ done();
}, 2000 );
} );
}
diff --git a/test/unit/css.js b/test/unit/css.js
index a197b6f04..65e4a49b3 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -1,6 +1,6 @@
if ( jQuery.css ) {
-QUnit.module( "css", { teardown: moduleTeardown } );
+QUnit.module( "css", { afterEach: moduleTeardown } );
QUnit.test( "css(String|Hash)", function( assert ) {
assert.expect( 42 );
@@ -1503,8 +1503,8 @@ QUnit.test( "Reset the style if set to an empty string", function( assert ) {
QUnit.test(
"Clearing a Cloned Element's Style Shouldn't Clear the Original Element's Style (#8908)",
- 24,
function( assert ) {
+ assert.expect( 24 );
var done = assert.async();
var styles = [ {
name: "backgroundAttachment",
diff --git a/test/unit/data.js b/test/unit/data.js
index c769d9040..32605cff8 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -1,4 +1,4 @@
-QUnit.module( "data", { teardown: moduleTeardown } );
+QUnit.module( "data", { afterEach: moduleTeardown } );
QUnit.test( "expando", function( assert ) {
assert.expect( 1 );
@@ -832,12 +832,12 @@ QUnit.test( ".removeData supports removal of hyphenated properties via array (#1
// Test originally by Moschel
QUnit.test( ".removeData should not throw exceptions. (#10080)", function( assert ) {
+ var done = assert.async();
assert.expect( 1 );
- QUnit.stop();
var frame = jQuery( "#loadediframe" );
jQuery( frame[ 0 ].contentWindow ).on( "unload", function() {
assert.ok( true, "called unload" );
- QUnit.start();
+ done();
} );
// change the url to trigger unload
diff --git a/test/unit/deferred.js b/test/unit/deferred.js
index 70d1254a1..c704f905f 100644
--- a/test/unit/deferred.js
+++ b/test/unit/deferred.js
@@ -1,5 +1,5 @@
QUnit.module( "deferred", {
- teardown: moduleTeardown
+ afterEach: moduleTeardown
} );
jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js
index aaab68beb..3d9cbec29 100644
--- a/test/unit/deprecated.js
+++ b/test/unit/deprecated.js
@@ -1,4 +1,4 @@
-QUnit.module( "deprecated", { teardown: moduleTeardown } );
+QUnit.module( "deprecated", { afterEach: moduleTeardown } );
QUnit.test( "bind/unbind", function( assert ) {
diff --git a/test/unit/dimensions.js b/test/unit/dimensions.js
index 223e17b0a..e5733fc86 100644
--- a/test/unit/dimensions.js
+++ b/test/unit/dimensions.js
@@ -4,7 +4,7 @@ if ( !jQuery.fn.width ) {
return;
}
-QUnit.module( "dimensions", { teardown: moduleTeardown } );
+QUnit.module( "dimensions", { afterEach: moduleTeardown } );
function pass( val ) {
return val;
diff --git a/test/unit/effects.js b/test/unit/effects.js
index 9e8838132..091f3ded3 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -12,7 +12,7 @@ var oldRaf = window.requestAnimationFrame,
};
QUnit.module( "effects", {
- setup: function() {
+ beforeEach: function() {
window.requestAnimationFrame = null;
this.sandbox = sinon.sandbox.create();
this.clock = this.sandbox.useFakeTimers( 505877050 );
@@ -20,7 +20,7 @@ QUnit.module( "effects", {
jQuery.fx.step = {};
jQuery.fx.interval = 10;
},
- teardown: function() {
+ afterEach: function() {
this.sandbox.restore();
jQuery.fx.stop();
jQuery.fx.interval = this._oldInterval;
@@ -453,8 +453,8 @@ QUnit.test( "animate resets overflow-x and overflow-y when finished", function(
/* // This test ends up being flaky depending upon the CPU load
QUnit.test("animate option (queue === false)", function( assert ) {
+ var done = assert.async();
assert.expect(1);
- QUnit.stop();
var order = [];
@@ -463,7 +463,7 @@ QUnit.test("animate option (queue === false)", function( assert ) {
// should finish after unqueued animation so second
order.push(2);
assert.deepEqual( order, [ 1, 2 ], "Animations finished in the correct order" );
- QUnit.start();
+ done();
});
$foo.animate({fontSize:"2em"}, {queue:false, duration:10, complete:function () {
// short duration and out of queue so should finish first
diff --git a/test/unit/event.js b/test/unit/event.js
index f146df86a..e18bf9ed3 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -1,8 +1,8 @@
QUnit.module( "event", {
- setup: function() {
+ beforeEach: function() {
document.body.focus();
},
- teardown: moduleTeardown
+ afterEach: moduleTeardown
} );
QUnit.test( "null or undefined handler", function( assert ) {
@@ -1418,7 +1418,8 @@ QUnit.test( "Submit event can be stopped (#11049)", function( assert ) {
// iOS has the window.onbeforeunload field but doesn't support the beforeunload
// handler making it impossible to feature-detect the support.
QUnit[ /(ipad|iphone|ipod)/i.test( navigator.userAgent ) ? "skip" : "test" ](
- "on(beforeunload)", 1, function( assert ) {
+ "on(beforeunload)", function( assert ) {
+ assert.expect( 1 );
var iframe = jQuery( jQuery.parseHTML( "<iframe src='" + baseURL + "event/onbeforeunload.html'><iframe>" ) );
var done = assert.async();
diff --git a/test/unit/exports.js b/test/unit/exports.js
index bca8954cf..3cb248052 100644
--- a/test/unit/exports.js
+++ b/test/unit/exports.js
@@ -1,4 +1,4 @@
-QUnit.module( "exports", { teardown: moduleTeardown } );
+QUnit.module( "exports", { afterEach: moduleTeardown } );
QUnit.test( "amdModule", function( assert ) {
assert.expect( 1 );
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 0acb45f3e..d72f1374f 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -1,5 +1,5 @@
QUnit.module( "manipulation", {
- teardown: moduleTeardown
+ afterEach: moduleTeardown
} );
// Ensure that an extended Array prototype doesn't break jQuery
@@ -1300,7 +1300,7 @@ function testReplaceWith( val, assert ) {
$div = jQuery( "<div class='replacewith'></div>" ).appendTo( "#qunit-fixture" );
$div.replaceWith( val( "<div class='replacewith'></div><script>" +
- "equal( jQuery('.replacewith').length, 1, 'Check number of elements in page.' );" +
+ "QUnit.assert.equal( jQuery('.replacewith').length, 1, 'Check number of elements in page.' );" +
"</script>" ) );
jQuery( "#qunit-fixture" ).append( "<div id='replaceWith'></div>" );
@@ -1754,15 +1754,15 @@ function testHtml( valueObj, assert ) {
tmp = fixture.html(
valueObj( [
- "<script type='something/else'>ok( false, 'evaluated: non-script' );</script>",
- "<script type='text/javascript'>ok( true, 'evaluated: text/javascript' );</script>",
- "<script type='text/ecmascript'>ok( true, 'evaluated: text/ecmascript' );</script>",
- "<script>ok( true, 'evaluated: no type' );</script>",
+ "<script type='something/else'>QUnit.assert.ok( false, 'evaluated: non-script' );</script>",
+ "<script type='text/javascript'>QUnit.assert.ok( true, 'evaluated: text/javascript' );</script>",
+ "<script type='text/ecmascript'>QUnit.assert.ok( true, 'evaluated: text/ecmascript' );</script>",
+ "<script>QUnit.assert.ok( true, 'evaluated: no type' );</script>",
"<div>",
- "<script type='something/else'>ok( false, 'evaluated: inner non-script' );</script>",
- "<script type='text/javascript'>ok( true, 'evaluated: inner text/javascript' );</script>",
- "<script type='text/ecmascript'>ok( true, 'evaluated: inner text/ecmascript' );</script>",
- "<script>ok( true, 'evaluated: inner no type' );</script>",
+ "<script type='something/else'>QUnit.assert.ok( false, 'evaluated: inner non-script' );</script>",
+ "<script type='text/javascript'>QUnit.assert.ok( true, 'evaluated: inner text/javascript' );</script>",
+ "<script type='text/ecmascript'>QUnit.assert.ok( true, 'evaluated: inner text/ecmascript' );</script>",
+ "<script>QUnit.assert.ok( true, 'evaluated: inner no type' );</script>",
"</div>"
].join( "" ) )
).find( "script" );
@@ -1770,19 +1770,19 @@ function testHtml( valueObj, assert ) {
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>" ) );
- fixture.html( valueObj( "<script type='text/javascript'>ok( true, 'Injection of identical script' );</script>" ) );
- fixture.html( valueObj( "foo <form><script type='text/javascript'>ok( true, 'Injection of identical script (#975)' );</script></form>" ) );
+ fixture.html( valueObj( "<script type='text/javascript'>QUnit.assert.ok( true, 'Injection of identical script' );</script>" ) );
+ fixture.html( valueObj( "<script type='text/javascript'>QUnit.assert.ok( true, 'Injection of identical script' );</script>" ) );
+ fixture.html( valueObj( "<script type='text/javascript'>QUnit.assert.ok( true, 'Injection of identical script' );</script>" ) );
+ fixture.html( valueObj( "foo <form><script type='text/javascript'>QUnit.assert.ok( true, 'Injection of identical script (#975)' );</script></form>" ) );
jQuery.scriptorder = 0;
fixture.html( valueObj( [
"<script>",
- "equal( jQuery('#scriptorder').length, 1,'Execute after html' );",
- "equal( jQuery.scriptorder++, 0, 'Script is executed in order' );",
+ "QUnit.assert.equal( jQuery('#scriptorder').length, 1,'Execute after html' );",
+ "QUnit.assert.equal( jQuery.scriptorder++, 0, 'Script is executed in order' );",
"</script>",
- "<span id='scriptorder'><script>equal( jQuery.scriptorder++, 1, 'Script (nested) is executed in order');</script></span>",
- "<script>equal( jQuery.scriptorder++, 2, 'Script (unnested) is executed in order' );</script>"
+ "<span id='scriptorder'><script>QUnit.assert.equal( jQuery.scriptorder++, 1, 'Script (nested) is executed in order');</script></span>",
+ "<script>QUnit.assert.equal( jQuery.scriptorder++, 2, 'Script (unnested) is executed in order' );</script>"
].join( "" ) ) );
fixture.html( valueObj( fixture.text() ) );
@@ -1810,10 +1810,10 @@ QUnit[
$fixture.html(
[
- "<script type='module'>ok( true, 'evaluated: module' );</script>",
+ "<script type='module'>QUnit.assert.ok( true, 'evaluated: module' );</script>",
"<script type='module' src='" + url( "module.js" ) + "'></script>",
"<div>",
- "<script type='module'>ok( true, 'evaluated: inner module' );</script>",
+ "<script type='module'>QUnit.assert.ok( true, 'evaluated: inner module' );</script>",
"<script type='module' src='" + url( "inner_module.js" ) + "'></script>",
"</div>"
].join( "" )
@@ -2273,7 +2273,7 @@ QUnit.test( "domManip executes scripts containing html comments or CDATA (trac-9
jQuery( [
"<script type='text/javascript'>",
"<!--",
- "ok( true, '<!-- handled' );",
+ "QUnit.assert.ok( true, '<!-- handled' );",
"//-->",
"</script>"
].join( "\n" ) ).appendTo( "#qunit-fixture" );
@@ -2281,7 +2281,7 @@ QUnit.test( "domManip executes scripts containing html comments or CDATA (trac-9
jQuery( [
"<script type='text/javascript'>",
"<![CDATA[",
- "ok( true, '<![CDATA[ handled' );",
+ "QUnit.assert.ok( true, '<![CDATA[ handled' );",
"//]]>",
"</script>"
].join( "\n" ) ).appendTo( "#qunit-fixture" );
@@ -2289,7 +2289,7 @@ QUnit.test( "domManip executes scripts containing html comments or CDATA (trac-9
jQuery( [
"<script type='text/javascript'>",
"<!--//--><![CDATA[//><!--",
- "ok( true, '<!--//--><![CDATA[//><!-- (Drupal case) handled' );",
+ "QUnit.assert.ok( true, '<!--//--><![CDATA[//><!-- (Drupal case) handled' );",
"//--><!]]>",
"</script>"
].join( "\n" ) ).appendTo( "#qunit-fixture" );
@@ -2418,13 +2418,15 @@ QUnit.test( "Ensure oldIE creates a new set on appendTo (#8894)", function( asse
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" );
} );
-QUnit.asyncTest( "html() - script exceptions bubble (#11743)", 2, function( assert ) {
- var onerror = window.onerror;
+QUnit.test( "html() - script exceptions bubble (#11743)", function( assert ) {
+ assert.expect( 2 );
+ var done = assert.async(),
+ onerror = window.onerror;
setTimeout( function() {
window.onerror = onerror;
- QUnit.start();
+ done();
}, 1000 );
window.onerror = function() {
@@ -2493,15 +2495,15 @@ QUnit.test( "script evaluation (#11795)", function( assert ) {
objGlobal.ok = notOk;
scriptsIn = jQuery( [
- "<script type='something/else'>ok( false, 'evaluated: non-script' );</script>",
- "<script type='text/javascript'>ok( true, 'evaluated: text/javascript' );</script>",
- "<script type='text/ecmascript'>ok( true, 'evaluated: text/ecmascript' );</script>",
- "<script>ok( true, 'evaluated: no type' );</script>",
+ "<script type='something/else'>QUnit.assert.ok( false, 'evaluated: non-script' );</script>",
+ "<script type='text/javascript'>QUnit.assert.ok( true, 'evaluated: text/javascript' );</script>",
+ "<script type='text/ecmascript'>QUnit.assert.ok( true, 'evaluated: text/ecmascript' );</script>",
+ "<script>QUnit.assert.ok( true, 'evaluated: no type' );</script>",
"<div>",
- "<script type='something/else'>ok( false, 'evaluated: inner non-script' );</script>",
- "<script type='text/javascript'>ok( true, 'evaluated: inner text/javascript' );</script>",
- "<script type='text/ecmascript'>ok( true, 'evaluated: inner text/ecmascript' );</script>",
- "<script>ok( true, 'evaluated: inner no type' );</script>",
+ "<script type='something/else'>QUnit.assert.ok( false, 'evaluated: inner non-script' );</script>",
+ "<script type='text/javascript'>QUnit.assert.ok( true, 'evaluated: inner text/javascript' );</script>",
+ "<script type='text/ecmascript'>QUnit.assert.ok( true, 'evaluated: inner text/ecmascript' );</script>",
+ "<script>QUnit.assert.ok( true, 'evaluated: inner no type' );</script>",
"</div>"
].join( "" ) );
scriptsIn.appendTo( jQuery( "<div class='detached'/>" ) );
@@ -2823,7 +2825,8 @@ QUnit.test( "Make sure tags with single-character names are found (gh-4124)", fu
assert.strictEqual( htmlOut, htmlIn );
} );
-QUnit.test( "Insert script with data-URI (gh-1887)", 1, function( assert ) {
+QUnit.test( "Insert script with data-URI (gh-1887)", function( assert ) {
+ assert.expect( 1 );
Globals.register( "testFoo" );
Globals.register( "testSrcFoo" );
@@ -2849,7 +2852,9 @@ QUnit.test( "Insert script with data-URI (gh-1887)", 1, function( assert ) {
}, 100 );
} );
-QUnit.test( "Ignore content from unsuccessful responses (gh-4126)", 1, function( assert ) {
+QUnit.test( "Ignore content from unsuccessful responses (gh-4126)", function( assert ) {
+ assert.expect( 1 );
+
var globalEval = jQuery.globalEval;
jQuery.globalEval = function( code ) {
assert.ok( false, "no attempt to evaluate code from an unsuccessful response" );
diff --git a/test/unit/offset.js b/test/unit/offset.js
index 61f762eea..92b7aff2f 100644
--- a/test/unit/offset.js
+++ b/test/unit/offset.js
@@ -46,7 +46,7 @@ var supportsFixedPosition, supportsScroll, alwaysScrollable,
);
};
-QUnit.module( "offset", { setup: function( assert ) {
+QUnit.module( "offset", { beforeEach: function( assert ) {
if ( typeof checkSupport === "function" ) {
checkSupport( assert );
}
@@ -56,7 +56,7 @@ QUnit.module( "offset", { setup: function( assert ) {
forceScroll.appendTo( "body" );
window.scrollTo( 1, 1 );
forceScroll.detach();
-}, teardown: moduleTeardown } );
+}, afterEach: moduleTeardown } );
QUnit.test( "empty set", function( assert ) {
assert.expect( 2 );
diff --git a/test/unit/queue.js b/test/unit/queue.js
index f604cea04..6c8ad762d 100644
--- a/test/unit/queue.js
+++ b/test/unit/queue.js
@@ -1,9 +1,9 @@
-QUnit.module( "queue", { teardown: moduleTeardown } );
+QUnit.module( "queue", { afterEach: moduleTeardown } );
QUnit.test( "queue() with other types", function( assert ) {
+ var done = assert.async( 2 );
assert.expect( 14 );
- QUnit.stop();
var $div = jQuery( {} ),
counter = 0;
@@ -30,7 +30,7 @@ QUnit.test( "queue() with other types", function( assert ) {
$div.promise( "foo" ).done( function() {
assert.equal( counter, 4, "Testing previous call to dequeue in deferred" );
- QUnit.start();
+ done();
} );
assert.equal( $div.queue( "foo" ).length, 4, "Testing queue length" );
@@ -51,7 +51,7 @@ QUnit.test( "queue() with other types", function( assert ) {
assert.equal( counter, 4, "Testing previous call to dequeue" );
assert.equal( $div.queue( "foo" ).length, 0, "Testing queue length" );
-
+ done();
} );
QUnit.test( "queue(name) passes in the next item in the queue as a parameter", function( assert ) {
@@ -74,8 +74,8 @@ QUnit.test( "queue(name) passes in the next item in the queue as a parameter", f
} );
QUnit.test( "queue() passes in the next item in the queue as a parameter to fx queues", function( assert ) {
+ var done = assert.async();
assert.expect( 3 );
- QUnit.stop();
var div = jQuery( {} ),
counter = 0;
@@ -92,13 +92,13 @@ QUnit.test( "queue() passes in the next item in the queue as a parameter to fx q
jQuery.when( div.promise( "fx" ), div ).done( function() {
assert.equal( counter, 2, "Deferreds resolved" );
- QUnit.start();
+ done();
} );
} );
QUnit.test( "callbacks keep their place in the queue", function( assert ) {
+ var done = assert.async();
assert.expect( 5 );
- QUnit.stop();
var div = jQuery( "<div>" ),
counter = 0;
@@ -119,7 +119,7 @@ QUnit.test( "callbacks keep their place in the queue", function( assert ) {
div.promise( "fx" ).done( function() {
assert.equal( counter, 4, "Deferreds resolved" );
- QUnit.start();
+ done();
} );
} );
@@ -132,25 +132,24 @@ QUnit.test( "jQuery.queue should return array while manipulating the queue", fun
} );
QUnit.test( "delay()", function( assert ) {
+ var done = assert.async();
assert.expect( 2 );
- QUnit.stop();
var foo = jQuery( {} ), run = 0;
foo.delay( 100 ).queue( function() {
run = 1;
assert.ok( true, "The function was dequeued." );
- QUnit.start();
+ done();
} );
assert.equal( run, 0, "The delay delayed the next function from running." );
} );
QUnit.test( "clearQueue(name) clears the queue", function( assert ) {
+ var done = assert.async( 2 );
assert.expect( 2 );
- QUnit.stop();
-
var div = jQuery( {} ),
counter = 0;
@@ -164,12 +163,13 @@ QUnit.test( "clearQueue(name) clears the queue", function( assert ) {
div.promise( "foo" ).done( function() {
assert.ok( true, "dequeue resolves the deferred" );
- QUnit.start();
+ done();
} );
div.dequeue( "foo" );
assert.equal( counter, 1, "the queue was cleared" );
+ done();
} );
QUnit.test( "clearQueue() clears the fx queue", function( assert ) {
@@ -191,9 +191,11 @@ QUnit.test( "clearQueue() clears the fx queue", function( assert ) {
div.removeData();
} );
-QUnit.asyncTest( "fn.promise() - called when fx queue is empty", 3, function( assert ) {
+QUnit.test( "fn.promise() - called when fx queue is empty", function( assert ) {
+ assert.expect( 3 );
var foo = jQuery( "#foo" ).clone().addBack(),
- promised = false;
+ promised = false,
+ done = assert.async();
foo.queue( function( next ) {
@@ -203,11 +205,13 @@ QUnit.asyncTest( "fn.promise() - called when fx queue is empty", 3, function( as
} );
foo.promise().done( function() {
assert.ok( promised = true, "Promised" );
- QUnit.start();
+ done();
} );
} );
-QUnit.asyncTest( "fn.promise( \"queue\" ) - called whenever last queue function is dequeued", 5, function( assert ) {
+QUnit.test( "fn.promise( \"queue\" ) - called whenever last queue function is dequeued", function( assert ) {
+ assert.expect( 5 );
+ var done = assert.async();
var foo = jQuery( "#foo" ),
test;
foo.promise( "queue" ).done( function() {
@@ -222,7 +226,7 @@ QUnit.asyncTest( "fn.promise( \"queue\" ) - called whenever last queue function
setTimeout( function() {
next();
assert.strictEqual( test++, 4, "step four" );
- QUnit.start();
+ done();
}, 10 );
} ).promise( "queue" ).done( function() {
assert.strictEqual( test++, 3, "step three" );
@@ -233,7 +237,9 @@ QUnit.asyncTest( "fn.promise( \"queue\" ) - called whenever last queue function
if ( jQuery.fn.animate ) {
-QUnit.asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete before resolving", 2, function( assert ) {
+QUnit.test( "fn.promise( \"queue\" ) - waits for animation to complete before resolving", function( assert ) {
+ assert.expect( 2 );
+ var done = assert.async();
var foo = jQuery( "#foo" ),
test = 1;
@@ -249,7 +255,7 @@ QUnit.asyncTest( "fn.promise( \"queue\" ) - waits for animation to complete befo
foo.promise( "queue" ).done( function() {
assert.strictEqual( test++, 2, "step two" );
- QUnit.start();
+ done();
} );
} );
@@ -267,19 +273,18 @@ QUnit.test( ".promise(obj)", function( assert ) {
if ( jQuery.fn.stop ) {
QUnit.test( "delay() can be stopped", function( assert ) {
+ var done = assert.async();
assert.expect( 3 );
- QUnit.stop();
-
- var done = {};
+ var storage = {};
jQuery( {} )
.queue( "alternate", function( next ) {
- done.alt1 = true;
+ storage.alt1 = true;
assert.ok( true, "This first function was dequeued" );
next();
} )
.delay( 1000, "alternate" )
.queue( "alternate", function() {
- done.alt2 = true;
+ storage.alt2 = true;
assert.ok( true, "The function was dequeued immediately, the delay was stopped" );
} )
.dequeue( "alternate" )
@@ -290,21 +295,23 @@ if ( jQuery.fn.stop ) {
// this test
.delay( 1 )
.queue( function() {
- done.default1 = true;
+ storage.default1 = true;
assert.ok( false, "This queue should never run" );
} )
// stop( clearQueue ) should clear the queue
.stop( true, false );
- assert.deepEqual( done, { alt1: true, alt2: true }, "Queue ran the proper functions" );
+ assert.deepEqual( storage, { alt1: true, alt2: true }, "Queue ran the proper functions" );
setTimeout( function() {
- QUnit.start();
+ done();
}, 1500 );
} );
- QUnit.asyncTest( "queue stop hooks", 2, function( assert ) {
+ QUnit.test( "queue stop hooks", function( assert ) {
+ assert.expect( 2 );
+ var done = assert.async();
var foo = jQuery( "#foo" );
foo.queue( function( next, hooks ) {
@@ -317,7 +324,7 @@ if ( jQuery.fn.stop ) {
foo.queue( function( next, hooks ) {
hooks.stop = function( gotoEnd ) {
assert.equal( gotoEnd, true, "Stopped with gotoEnd" );
- QUnit.start();
+ done();
};
} );
diff --git a/test/unit/selector.js b/test/unit/selector.js
index 0177f4ba2..f9c6ffc7a 100644
--- a/test/unit/selector.js
+++ b/test/unit/selector.js
@@ -1,4 +1,4 @@
-QUnit.module( "selector", { teardown: moduleTeardown } );
+QUnit.module( "selector", { afterEach: moduleTeardown } );
/**
* This test page is for selector tests that require jQuery in order to do the selection
@@ -503,11 +503,13 @@ testIframe(
}
);
-QUnit.asyncTest( "Iframe dispatch should not affect jQuery (#13936)", 1, function( assert ) {
+QUnit.test( "Iframe dispatch should not affect jQuery (#13936)", function( assert ) {
+ assert.expect( 1 );
var loaded = false,
thrown = false,
iframe = document.getElementById( "iframe" ),
- iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
+ iframeDoc = iframe.contentDocument || iframe.contentWindow.document,
+ done = assert.async();
jQuery( iframe ).on( "load", function() {
var form;
@@ -525,7 +527,7 @@ QUnit.asyncTest( "Iframe dispatch should not affect jQuery (#13936)", 1, functio
// clean up
jQuery( iframe ).off();
- QUnit.start();
+ done();
} else {
loaded = true;
form.submit();
diff --git a/test/unit/serialize.js b/test/unit/serialize.js
index 604d72a21..d23421ddd 100644
--- a/test/unit/serialize.js
+++ b/test/unit/serialize.js
@@ -1,4 +1,4 @@
-QUnit.module( "serialize", { teardown: moduleTeardown } );
+QUnit.module( "serialize", { afterEach: moduleTeardown } );
QUnit.test( "jQuery.param()", function( assert ) {
assert.expect( 24 );
diff --git a/test/unit/support.js b/test/unit/support.js
index 24ca830e2..db9991a76 100644
--- a/test/unit/support.js
+++ b/test/unit/support.js
@@ -1,4 +1,4 @@
-QUnit.module( "support", { teardown: moduleTeardown } );
+QUnit.module( "support", { afterEach: moduleTeardown } );
var computedSupport = getComputedSupport( jQuery.support );
diff --git a/test/unit/traversing.js b/test/unit/traversing.js
index 9ba66959e..e70c121ed 100644
--- a/test/unit/traversing.js
+++ b/test/unit/traversing.js
@@ -1,4 +1,4 @@
-QUnit.module( "traversing", { teardown: moduleTeardown } );
+QUnit.module( "traversing", { afterEach: moduleTeardown } );
QUnit.test( "find(String)", function( assert ) {
assert.expect( 1 );
diff --git a/test/unit/tween.js b/test/unit/tween.js
index 5d3d49d18..68c5c0e8d 100644
--- a/test/unit/tween.js
+++ b/test/unit/tween.js
@@ -8,7 +8,7 @@ if ( !jQuery.fx ) {
var oldRaf = window.requestAnimationFrame;
QUnit.module( "tween", {
- setup: function() {
+ beforeEach: function() {
window.requestAnimationFrame = null;
this.sandbox = sinon.sandbox.create();
this.clock = this.sandbox.useFakeTimers( 505877050 );
@@ -16,7 +16,7 @@ QUnit.module( "tween", {
jQuery.fx.step = {};
jQuery.fx.interval = 10;
},
- teardown: function() {
+ afterEach: function() {
this.sandbox.restore();
jQuery.fx.stop();
jQuery.fx.interval = this._oldInterval;
@@ -78,7 +78,7 @@ QUnit.test( "jQuery.Tween - Default propHooks on elements", function( assert ) {
fakeTween.prop = "testOpti";
testElement.testOpti = 15;
- cssStub.reset();
+ cssStub.resetHistory();
assert.equal( defaultHook.get( fakeTween ), 15, "Gets expected value not defined on style" );
assert.equal( cssStub.callCount, 0, "Did not call jQuery.css" );
@@ -99,7 +99,7 @@ QUnit.test( "jQuery.Tween - Default propHooks on elements", function( assert ) {
cssStub.returns( undefined );
assert.equal( defaultHook.get( fakeTween ), 0, "Uses 0 for undefined" );
- cssStub.reset();
+ cssStub.resetHistory();
// Setters
styleStub = this.sandbox.stub( jQuery, "style" );
@@ -109,7 +109,7 @@ QUnit.test( "jQuery.Tween - Default propHooks on elements", function( assert ) {
assert.ok( styleStub.calledWith( testElement, "height", "10px" ),
"Calls jQuery.style with elem, prop, now+unit" );
- styleStub.reset();
+ styleStub.resetHistory();
fakeTween.prop = "testMissing";
defaultHook.set( fakeTween );
@@ -127,7 +127,7 @@ QUnit.test( "jQuery.Tween - Default propHooks on elements", function( assert ) {
assert.equal( testElement.testMissing, 10, "And value was unchanged" );
stepSpy = jQuery.fx.step.test = this.sandbox.spy();
- styleStub.reset();
+ styleStub.resetHistory();
fakeTween.prop = "test";
defaultHook.set( fakeTween );
diff --git a/test/unit/wrap.js b/test/unit/wrap.js
index 840e35a1f..40c35d692 100644
--- a/test/unit/wrap.js
+++ b/test/unit/wrap.js
@@ -5,7 +5,7 @@ if ( !jQuery.fn.wrap ) { // no wrap module
}
QUnit.module( "wrap", {
- teardown: moduleTeardown
+ afterEach: moduleTeardown
} );
// See test/unit/manipulation.js for explanation about these 2 functions
@@ -522,7 +522,7 @@ QUnit.test( "wrapping scripts (#10470)", function( assert ) {
var script = document.createElement( "script" );
script.text = script.textContent =
- "ok( !document.eval10470, 'script evaluated once' ); document.eval10470 = true;";
+ "QUnit.assert.ok( !document.eval10470, 'script evaluated once' ); document.eval10470 = true;";
document.eval10470 = false;
jQuery( "#qunit-fixture" ).empty()[ 0 ].appendChild( script );