Skip to content

Commit

Permalink
Tests: Remove remaining obsolete jQuery.cache references
Browse files Browse the repository at this point in the history
PR gh-4586 removed some of those but not all.

Closes gh-4715
Ref gh-4586

(cherry picked from commit d96111e)
  • Loading branch information
mgol committed May 18, 2020
1 parent 8ad78cd commit 5e028c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 36 deletions.
26 changes: 4 additions & 22 deletions test/data/testrunner.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
( function() {

// Store the old counts so that we only assert on tests that have actually leaked,
"use strict";

// Store the old count so that we only assert on tests that have actually leaked,
// instead of asserting every time a test has leaked sometime in the past
var oldCacheLength = 0,
oldActive = 0,
var oldActive = 0,

expectedDataKeys = {},
splice = [].splice,
ajaxSettings = jQuery.ajaxSettings;

Expand All @@ -24,11 +24,6 @@ QUnit.config.requireExpects = true;
* teardown function on all modules' lifecycle object.
*/
window.moduleTeardown = function( assert ) {
var i, expectedKeys, actualKeys,
cacheLength = 0;

// Reset data register
expectedDataKeys = {};

// Check for (and clean up, if possible) incomplete animations/requests/etc.
if ( jQuery.timers && jQuery.timers.length !== 0 ) {
Expand All @@ -45,19 +40,6 @@ window.moduleTeardown = function( assert ) {
}

Globals.cleanup();

for ( i in jQuery.cache ) {
++cacheLength;
}

// Because QUnit doesn't have a mechanism for retrieving
// the number of expected assertions for a test,
// if we unconditionally assert any of these,
// the test will fail with too many assertions :|
if ( cacheLength !== oldCacheLength ) {
assert.equal( cacheLength, oldCacheLength, "No unit tests leak memory in jQuery.cache" );
oldCacheLength = cacheLength;
}
};

QUnit.done( function() {
Expand Down
15 changes: 1 addition & 14 deletions test/unit/wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function manipulationFunctionReturningObj( value ) {

function testWrap( val, assert ) {

assert.expect( 19 );
assert.expect( 18 );

var defaultText, result, j, i, cacheLength;

Expand Down Expand Up @@ -68,12 +68,6 @@ function testWrap( val, assert ) {
"Check node,textnode,comment wraps doesn't hurt text"
);

// Try wrapping a disconnected node
cacheLength = 0;
for ( i in jQuery.cache ) {
cacheLength++;
}

j = jQuery( "<label></label>" ).wrap( val( "<li></li>" ) );
assert.equal(
j[ 0 ] .nodeName.toUpperCase(), "LABEL", "Element is a label"
Expand All @@ -82,13 +76,6 @@ function testWrap( val, assert ) {
j[ 0 ].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped"
);

for ( i in jQuery.cache ) {
cacheLength--;
}
assert.equal(
cacheLength, 0, "No memory leak in jQuery.cache (bug #7165)"
);

// Wrap an element containing a text node
j = jQuery( "<span></span>" ).wrap( "<div>test</div>" );
assert.equal(
Expand Down

0 comments on commit 5e028c7

Please sign in to comment.