Skip to content

Commit f6f8848

Browse files
committed
Tests: Minor updates for QUnit 1.16 compatibility
More to come later.
1 parent b6e31a8 commit f6f8848

File tree

5 files changed

+25
-24
lines changed

5 files changed

+25
-24
lines changed

test/data/testrunner.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,13 @@ function keys( o ) {
4343
* @param {jQuery|HTMLElement|Object|Array} elems Target (or array of targets) for jQuery.data.
4444
* @param {string} key
4545
*/
46-
QUnit.expectJqData = function( elems, key ) {
47-
var i, elem, expando,
48-
currentEnv = "current_testEnvironment";
46+
QUnit.expectJqData = function( env, elems, key ) {
47+
var i, elem, expando;
4948

5049
// As of jQuery 2.0, there will be no "cache"-data is
5150
// stored and managed completely below the API surface
5251
if ( jQuery.cache ) {
53-
QUnit[ currentEnv ].checkJqData = true;
52+
env.checkJqData = true;
5453

5554
if ( elems.jquery && elems.toArray ) {
5655
elems = elems.toArray();

test/unit/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ var testToggleClass = function(valueObj) {
12691269

12701270
// Cleanup
12711271
e.removeClass("testD");
1272-
QUnit.expectJqData( e[ 0 ], "__className__" );
1272+
QUnit.expectJqData( this, e[ 0 ], "__className__" );
12731273
};
12741274

12751275
test( "toggleClass(String|boolean|undefined[, boolean])", function() {

test/unit/data.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ test("jQuery.data(div)", 25, function() {
7878
// We stored one key in the private data
7979
// assert that nothing else was put in there, and that that
8080
// one stayed there.
81-
QUnit.expectJqData( div, "foo" );
81+
QUnit.expectJqData( this, div, "foo" );
8282
});
8383

8484
test("jQuery.data({})", 25, function() {
@@ -96,7 +96,7 @@ test("jQuery.data(window)", 25, function() {
9696
test("jQuery.data(document)", 25, function() {
9797
dataTests( document );
9898

99-
QUnit.expectJqData( document, "foo" );
99+
QUnit.expectJqData( this, document, "foo" );
100100
});
101101

102102
test("Expando cleanup", 4, function() {
@@ -682,4 +682,4 @@ testIframeWithCallback( "enumerate data attrs on body (#14894)", "data/dataAttrs
682682
expect(1);
683683

684684
equal(result, "ok", "enumeration of data- attrs on body" );
685-
});
685+
});

test/unit/dimensions.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function testWidth( val ) {
5757

5858
equal( jQuery(window).width(), document.documentElement.clientWidth, "Window width is equal to width reported by window/document." );
5959

60-
QUnit.expectJqData( $div[0], "olddisplay" );
60+
QUnit.expectJqData( this, $div[0], "olddisplay" );
6161
}
6262

6363
test("width()", function() {
@@ -110,7 +110,7 @@ function testHeight( val ) {
110110

111111
equal( jQuery(window).height(), document.documentElement.clientHeight, "Window width is equal to width reported by window/document." );
112112

113-
QUnit.expectJqData( $div[0], "olddisplay" );
113+
QUnit.expectJqData( this, $div[0], "olddisplay" );
114114
}
115115

116116
test("height()", function() {
@@ -166,7 +166,7 @@ test("innerWidth()", function() {
166166
equal( div.innerWidth(), 0, "Make sure that disconnected nodes are handled." );
167167

168168
div.remove();
169-
QUnit.expectJqData( $div[0], "olddisplay" );
169+
QUnit.expectJqData( this, $div[0], "olddisplay" );
170170
});
171171

172172
test("innerHeight()", function() {
@@ -202,7 +202,7 @@ test("innerHeight()", function() {
202202
equal( div.innerHeight(), 0, "Make sure that disconnected nodes are handled." );
203203

204204
div.remove();
205-
QUnit.expectJqData( $div[0], "olddisplay" );
205+
QUnit.expectJqData( this, $div[0], "olddisplay" );
206206
});
207207

208208
test("outerWidth()", function() {
@@ -241,7 +241,7 @@ test("outerWidth()", function() {
241241
equal( div.outerWidth(), 0, "Make sure that disconnected nodes are handled." );
242242

243243
div.remove();
244-
QUnit.expectJqData( $div[0], "olddisplay" );
244+
QUnit.expectJqData( this, $div[0], "olddisplay" );
245245
});
246246

247247
test("child of a hidden elem (or unconnected node) has accurate inner/outer/Width()/Height() see #9441 #9300", function() {
@@ -388,7 +388,7 @@ test("outerHeight()", function() {
388388
equal( div.outerHeight(), 0, "Make sure that disconnected nodes are handled." );
389389

390390
div.remove();
391-
QUnit.expectJqData( $div[0], "olddisplay" );
391+
QUnit.expectJqData( this, $div[0], "olddisplay" );
392392
});
393393

394394
test("passing undefined is a setter #5571", function() {

test/unit/effects.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ test("show() basic", 2, function() {
4343
// Clean up the detached node
4444
div.remove();
4545

46-
QUnit.expectJqData(hiddendiv, "olddisplay");
46+
QUnit.expectJqData( this, hiddendiv, "olddisplay" );
4747
});
4848

4949
test("show()", 27, function () {
@@ -94,7 +94,7 @@ test("show()", 27, function () {
9494
});
9595

9696
// Tolerate data from show()/hide()
97-
QUnit.expectJqData(div, "olddisplay");
97+
QUnit.expectJqData( this, div, "olddisplay" );
9898

9999
// #show-tests * is set display: none in CSS
100100
jQuery("#qunit-fixture").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
@@ -203,7 +203,7 @@ test("Persist correct display value", function() {
203203

204204
clock.tick( 300 );
205205

206-
QUnit.expectJqData($span, "olddisplay");
206+
QUnit.expectJqData( this, $span, "olddisplay" );
207207
});
208208

209209
test("animate(Hash, Object, Function)", function() {
@@ -1127,7 +1127,8 @@ test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function ()
11271127
test( "interrupt toggle", function() {
11281128
expect( 24 );
11291129

1130-
var longDuration = 2000,
1130+
var env = this,
1131+
longDuration = 2000,
11311132
shortDuration = 500,
11321133
remaining = 0,
11331134
$elems = jQuery(".chain-test"),
@@ -1144,7 +1145,7 @@ test( "interrupt toggle", function() {
11441145
jQuery.data( this, "startVal", jQuery( this ).css( prop ) );
11451146

11461147
// Expect olddisplay data from our .hide() call below
1147-
QUnit.expectJqData( this, "olddisplay" );
1148+
QUnit.expectJqData( env, this, "olddisplay" );
11481149
});
11491150

11501151
// Interrupt a hiding toggle
@@ -1551,7 +1552,8 @@ test( "User supplied callback called after show when fx off (#8892)", 2, functio
15511552
test( "animate should set display for disconnected nodes", function() {
15521553
expect( 18 );
15531554

1554-
var methods = {
1555+
var env = this,
1556+
methods = {
15551557
toggle: [ 1 ],
15561558
slideToggle: [],
15571559
fadeIn: [],
@@ -1572,9 +1574,9 @@ test( "animate should set display for disconnected nodes", function() {
15721574
strictEqual( $divNone.show()[ 0 ].style.display, "block", "show() should change display if it already set to none" );
15731575
strictEqual( $divInline.show()[ 0 ].style.display, "inline", "show() should not change display if it already set" );
15741576

1575-
QUnit.expectJqData( $divTest[ 0 ], "olddisplay" );
1576-
QUnit.expectJqData( $divEmpty[ 0 ], "olddisplay" );
1577-
QUnit.expectJqData( $divNone[ 0 ], "olddisplay" );
1577+
QUnit.expectJqData( env, $divTest[ 0 ], "olddisplay" );
1578+
QUnit.expectJqData( env, $divEmpty[ 0 ], "olddisplay" );
1579+
QUnit.expectJqData( env, $divNone[ 0 ], "olddisplay" );
15781580

15791581
jQuery.each( methods, function( name, opt ) {
15801582
jQuery.each([
@@ -1589,7 +1591,7 @@ test( "animate should set display for disconnected nodes", function() {
15891591
var callback = [function () {
15901592
strictEqual( this.style.display, "block", "set display to block with " + name );
15911593

1592-
QUnit.expectJqData( this, "olddisplay" );
1594+
QUnit.expectJqData( env, this, "olddisplay" );
15931595

15941596
}];
15951597
jQuery.fn[ name ].apply( this, opt.concat( callback ) );

0 commit comments

Comments
 (0)