diff options
author | Michał Gołębiowski-Owczarek <m.goleb@gmail.com> | 2020-01-13 19:23:01 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-13 19:23:01 +0100 |
commit | eb35be528fdea40faab4d89ac859d38dfd024271 (patch) | |
tree | ca3599c6fcfaabe516631b02e8f6bd56953f8336 /test/data/testrunner.js | |
parent | 9e66fe9acf0ef27681f5a21149fc61678f791641 (diff) | |
download | jquery-eb35be528fdea40faab4d89ac859d38dfd024271.tar.gz jquery-eb35be528fdea40faab4d89ac859d38dfd024271.zip |
Tests: Remove obsolete jQuery data tests
The tests relied on `jQuery.cache` so they only ever worked in jQuery 1.x.
Closes gh-4586
Diffstat (limited to 'test/data/testrunner.js')
-rw-r--r-- | test/data/testrunner.js | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/test/data/testrunner.js b/test/data/testrunner.js index c4fa5d378..816b271a6 100644 --- a/test/data/testrunner.js +++ b/test/data/testrunner.js @@ -22,74 +22,6 @@ QUnit.config.testTimeout = 60e3; // 1 minute QUnit.config.requireExpects = true; /** - * @param {jQuery|HTMLElement|Object|Array} elems Target (or array of targets) for jQuery.data. - * @param {string} key - */ -QUnit.assert.expectJqData = function( env, elems, key ) { - var i, elem, expando; - - // As of jQuery 2.0, there will be no "cache"-data is - // stored and managed completely below the API surface - if ( jQuery.cache ) { - env.checkJqData = true; - - if ( elems.jquery && elems.toArray ) { - elems = elems.toArray(); - } - if ( !Array.isArray( elems ) ) { - elems = [ elems ]; - } - - for ( i = 0; i < elems.length; i++ ) { - elem = elems[ i ]; - - // jQuery.data only stores data for nodes in jQuery.cache, - // for other data targets the data is stored in the object itself, - // in that case we can't test that target for memory leaks. - // But we don't have to since in that case the data will/must will - // be available as long as the object is not garbage collected by - // the js engine, and when it is, the data will be removed with it. - if ( !elem.nodeType ) { - - // Fixes false positives for dataTests(window), dataTests({}). - continue; - } - - expando = elem[ jQuery.expando ]; - - if ( expando === undefined ) { - - // In this case the element exists fine, but - // jQuery.data (or internal data) was never (in)directly - // called. - // 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). - this.notStrictEqual( - expando, - undefined, - "Target for expectJqData must have an expando, " + - "for else there can be no data to expect." - ); - } else { - if ( expectedDataKeys[ expando ] ) { - expectedDataKeys[ expando ].push( key ); - } else { - expectedDataKeys[ expando ] = [ key ]; - } - } - } - } - -}; -QUnit.config.urlConfig.push( { - id: "jqdata", - label: "Always check jQuery.data", - tooltip: "Trigger QUnit.expectJqData detection for all tests " + - "instead of just the ones that call it" -} ); - -/** * Ensures that tests have cleaned up properly after themselves. Should be passed as the * teardown function on all modules' lifecycle object. */ @@ -97,30 +29,6 @@ window.moduleTeardown = function( assert ) { var i, expectedKeys, actualKeys, cacheLength = 0; - // Only look for jQuery data problems if this test actually - // provided some information to compare against. - if ( QUnit.urlParams.jqdata || this.checkJqData ) { - for ( i in jQuery.cache ) { - expectedKeys = expectedDataKeys[ i ]; - actualKeys = jQuery.cache[ i ] ? Object.keys( jQuery.cache[ i ] ) : jQuery.cache[ i ]; - if ( !QUnit.equiv( expectedKeys, actualKeys ) ) { - assert.deepEqual( actualKeys, expectedKeys, "Expected keys exist in jQuery.cache" ); - } - delete jQuery.cache[ i ]; - delete expectedDataKeys[ i ]; - } - - // In case it was removed from cache before (or never there in the first place) - for ( i in expectedDataKeys ) { - assert.deepEqual( - expectedDataKeys[ i ], - undefined, - "No unexpected keys were left in jQuery.cache (#" + i + ")" - ); - delete expectedDataKeys[ i ]; - } - } - // Reset data register expectedDataKeys = {}; |