aboutsummaryrefslogtreecommitdiffstats
path: root/test/data
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-09-08 03:26:29 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-09-08 04:06:20 +0300
commitc8d15a2f9f108e90d3651c31e4abf45415a30fde (patch)
tree695a8bf692b069ba41058195463fe3646be18542 /test/data
parent3dd3d1357d027a487559516fcdd9064cc792edab (diff)
downloadjquery-c8d15a2f9f108e90d3651c31e4abf45415a30fde.tar.gz
jquery-c8d15a2f9f108e90d3651c31e4abf45415a30fde.zip
Tests: further improvements QUnit 2.0 migration
* Remove QUnit jshint globals * Extend QUnit.assert methods * Use assert.async instead of start/stop/done Ref b930d14ce64937e9478405eee2828d4da091d2cb
Diffstat (limited to 'test/data')
-rw-r--r--test/data/testinit.js6
-rw-r--r--test/data/testrunner.js16
2 files changed, 11 insertions, 11 deletions
diff --git a/test/data/testinit.js b/test/data/testinit.js
index 491440e19..341e39413 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -38,7 +38,7 @@ this.q = function() {
* @example t("Check for something", "//[a]", ["foo", "baar"]);
* @result returns true if "//[a]" return two elements with the IDs 'foo' and 'baar'
*/
-this.t = function( a, b, c ) {
+QUnit.assert.t = function( a, b, c ) {
var f = jQuery( b ).get(),
s = "",
i = 0;
@@ -47,7 +47,7 @@ this.t = function( a, b, c ) {
s += ( s && "," ) + '"' + f[ i ].id + '"';
}
- deepEqual( f, q.apply( q, c ), a + " (" + b + ")" );
+ this.deepEqual( f, q.apply( q, c ), a + " (" + b + ")" );
};
this.createDashboardXML = function() {
@@ -199,7 +199,7 @@ this.ajaxTest = function( title, expect, options ) {
if ( !completed ) {
completed = true;
delete ajaxTest.abort;
- ok( false, "aborted " + reason );
+ assert.ok( false, "aborted " + reason );
jQuery.each( requests, function( i, request ) {
request.abort();
} );
diff --git a/test/data/testrunner.js b/test/data/testrunner.js
index 454e8035e..e5ca01389 100644
--- a/test/data/testrunner.js
+++ b/test/data/testrunner.js
@@ -24,7 +24,7 @@ QUnit.config.requireExpects = true;
* @param {jQuery|HTMLElement|Object|Array} elems Target (or array of targets) for jQuery.data.
* @param {string} key
*/
-QUnit.expectJqData = function( env, elems, key ) {
+QUnit.assert.expectJqData = function( env, elems, key ) {
var i, elem, expando;
// As of jQuery 2.0, there will be no "cache"-data is
@@ -64,7 +64,7 @@ QUnit.expectJqData = function( env, elems, key ) {
// Since this method was called it means some data was
// expected to be found, but since there is nothing, fail early
// (instead of in teardown).
- notStrictEqual(
+ this.notStrictEqual(
expando,
undefined,
"Target for expectJqData must have an expando, " +
@@ -92,7 +92,7 @@ QUnit.config.urlConfig.push( {
* Ensures that tests have cleaned up properly after themselves. Should be passed as the
* teardown function on all modules' lifecycle object.
*/
-window.moduleTeardown = function() {
+window.moduleTeardown = function( assert ) {
var i, expectedKeys, actualKeys,
cacheLength = 0;
@@ -103,7 +103,7 @@ window.moduleTeardown = function() {
expectedKeys = expectedDataKeys[ i ];
actualKeys = jQuery.cache[ i ] ? Object.keys( jQuery.cache[ i ] ) : jQuery.cache[ i ];
if ( !QUnit.equiv( expectedKeys, actualKeys ) ) {
- deepEqual( actualKeys, expectedKeys, "Expected keys exist in jQuery.cache" );
+ assert.deepEqual( actualKeys, expectedKeys, "Expected keys exist in jQuery.cache" );
}
delete jQuery.cache[ i ];
delete expectedDataKeys[ i ];
@@ -111,7 +111,7 @@ window.moduleTeardown = function() {
// In case it was removed from cache before (or never there in the first place)
for ( i in expectedDataKeys ) {
- deepEqual(
+ assert.deepEqual(
expectedDataKeys[ i ],
undefined,
"No unexpected keys were left in jQuery.cache (#" + i + ")"
@@ -125,12 +125,12 @@ window.moduleTeardown = function() {
// Check for (and clean up, if possible) incomplete animations/requests/etc.
if ( jQuery.timers && jQuery.timers.length !== 0 ) {
- equal( jQuery.timers.length, 0, "No timers are still running" );
+ assert.equal( jQuery.timers.length, 0, "No timers are still running" );
splice.call( jQuery.timers, 0, jQuery.timers.length );
jQuery.fx.stop();
}
if ( jQuery.active !== undefined && jQuery.active !== oldActive ) {
- equal( jQuery.active, oldActive, "No AJAX requests are still active" );
+ assert.equal( jQuery.active, oldActive, "No AJAX requests are still active" );
if ( ajaxTest.abort ) {
ajaxTest.abort( "active requests" );
}
@@ -148,7 +148,7 @@ window.moduleTeardown = function() {
// if we unconditionally assert any of these,
// the test will fail with too many assertions :|
if ( cacheLength !== oldCacheLength ) {
- equal( cacheLength, oldCacheLength, "No unit tests leak memory in jQuery.cache" );
+ assert.equal( cacheLength, oldCacheLength, "No unit tests leak memory in jQuery.cache" );
oldCacheLength = cacheLength;
}
};