From 2f0cedc9972efa4bf9eb656001a098d9c51e53ec Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Tue, 8 Sep 2015 03:26:29 +0300 Subject: 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 Ref c8d15a2f9f108e90d3651c31e4abf45415a30fde --- test/data/testrunner.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'test/data/testrunner.js') diff --git a/test/data/testrunner.js b/test/data/testrunner.js index c60b152b1..0758219f0 100644 --- a/test/data/testrunner.js +++ b/test/data/testrunner.js @@ -43,7 +43,7 @@ function keys( o ) { * @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 @@ -83,7 +83,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, " + @@ -111,7 +111,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; @@ -123,7 +123,7 @@ window.moduleTeardown = function() { expectedKeys = expectedDataKeys[ i ]; actualKeys = jQuery.cache[ i ] ? 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 ]; @@ -131,7 +131,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 + ")" @@ -145,12 +145,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" ); } @@ -168,7 +168,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; } }; -- cgit v1.2.3