aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Gołębiowski <m.goleb@gmail.com>2013-04-09 00:18:45 +0200
committerDave Methvin <dave.methvin@gmail.com>2013-04-08 20:38:20 -0400
commit52394ba986794423e7855ece3b4f80a1f2fb7398 (patch)
tree899fb5adb106f37a099b2de7b064b00698e42718
parentbea0d9a49df88e382805df08c5431a5e1a0752c9 (diff)
downloadjquery-52394ba986794423e7855ece3b4f80a1f2fb7398.tar.gz
jquery-52394ba986794423e7855ece3b4f80a1f2fb7398.zip
Move size() test to deprecated.js and avoid in other tests. Close gh-1237.
-rw-r--r--test/unit/ajax.js3
-rw-r--r--test/unit/attributes.js2
-rw-r--r--test/unit/core.js7
-rw-r--r--test/unit/css.js2
-rw-r--r--test/unit/data.js2
-rw-r--r--test/unit/deprecated.js9
-rw-r--r--test/unit/effects.js36
-rw-r--r--test/unit/queue.js7
-rw-r--r--test/unit/traversing.js28
9 files changed, 48 insertions, 48 deletions
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index 0de0da05f..226d70983 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -1799,8 +1799,7 @@ module( "ajax", {
});
asyncTest( "jQuery.fn.load() - callbacks get the correct parameters", 8, function() {
- var slice = [].slice,
- completeArgs = {};
+ var completeArgs = {};
jQuery.ajaxSetup({
success: function( _, status, jqXHR ) {
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index 976869780..e7145730b 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -1017,7 +1017,7 @@ var testAddClass = function( valueObj ) {
var div = jQuery("#qunit-fixture div");
div.addClass( valueObj("test") );
var pass = true;
- for ( var i = 0; i < div.size(); i++ ) {
+ for ( var i = 0; i < div.length; i++ ) {
if ( !~div.get( i ).className.indexOf("test") ) {
pass = false;
}
diff --git a/test/unit/core.js b/test/unit/core.js
index b54438753..0f08fb4af 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -677,11 +677,6 @@ test("length", function() {
equal( jQuery("#qunit-fixture p").length, 6, "Get Number of Elements Found" );
});
-test("size()", function() {
- expect(1);
- equal( jQuery("#qunit-fixture p").size(), 6, "Get Number of Elements Found" );
-});
-
test("get()", function() {
expect(1);
deepEqual( jQuery("#qunit-fixture p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" );
@@ -747,7 +742,7 @@ test("each(Function)", function() {
var div = jQuery("div");
div.each(function(){this.foo = "zoo";});
var pass = true;
- for ( var i = 0; i < div.size(); i++ ) {
+ for ( var i = 0; i < div.length; i++ ) {
if ( div.get(i).foo != "zoo" ) {
pass = false;
}
diff --git a/test/unit/css.js b/test/unit/css.js
index 8a2ecfb60..f23c5dbe9 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -528,7 +528,7 @@ test( "show() resolves correct default display for detached nodes", function(){
equal( tr[ 0 ].style.display, trDisplay, "For detached tr elements, display should always be like for attached trs" );
tr.remove();
- span = span = jQuery("<span/>").hide().show();
+ span = jQuery("<span/>").hide().show();
equal( span[ 0 ].style.display, "inline", "For detached span elements, display should always be inline" );
span.remove();
});
diff --git a/test/unit/data.js b/test/unit/data.js
index 326fc5e2d..b01078da5 100644
--- a/test/unit/data.js
+++ b/test/unit/data.js
@@ -63,7 +63,7 @@ test( "jQuery.hasData no side effects", function() {
});
function dataTests (elem) {
- var oldCacheLength, dataObj, internalDataObj, expected, actual;
+ var dataObj, internalDataObj;
equal( jQuery.data(elem, "foo"), undefined, "No data exists initially" );
strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists initially" );
diff --git a/test/unit/deprecated.js b/test/unit/deprecated.js
index 330bda200..5839ceec3 100644
--- a/test/unit/deprecated.js
+++ b/test/unit/deprecated.js
@@ -1 +1,8 @@
-module("deprecated");
+module("deprecated", { teardown: moduleTeardown });
+
+if ( jQuery.fn.size ) {
+ test("size()", function() {
+ expect(1);
+ equal( jQuery("#qunit-fixture p").size(), 6, "Get Number of Elements Found" );
+ });
+}
diff --git a/test/unit/effects.js b/test/unit/effects.js
index e6c416198..e6d0bbb06 100644
--- a/test/unit/effects.js
+++ b/test/unit/effects.js
@@ -51,8 +51,6 @@ test("show()", 27, function () {
hiddendiv.css("display","");
- var displaysActual = [],
- displaysExpected = [];
div = jQuery("#fx-queue div").slice(0, 4);
div.show().each(function() {
notEqual(this.style.display, "none", "don't change any <div> with display block");
@@ -172,7 +170,7 @@ test("Persist correct display value", function() {
var $span = jQuery("#show-tests span"),
displayNone = $span.css("display"),
- display = "", num = 0;
+ display = "";
$span.show();
@@ -609,8 +607,7 @@ test("stop() - several in queue", function() {
expect( 5 );
var nw, time,
- $foo = jQuery( "#foo" ),
- w = 0;
+ $foo = jQuery( "#foo" );
// default duration is 400ms, so 800px ensures we aren't 0 or 1 after 1ms
$foo.hide().css( "width", 800 );
@@ -1283,17 +1280,18 @@ test("callbacks should fire in correct order (#9100)", function() {
stop();
var a = 1,
- cb = 0,
- $lis = jQuery("<p data-operation='*2'></p><p data-operation='^2'></p>").appendTo("#qunit-fixture")
- // The test will always pass if no properties are animated or if the duration is 0
- .animate({fontSize: 12}, 13, function() {
- a *= jQuery(this).data("operation") === "*2" ? 2 : a;
- cb++;
- if ( cb === 2 ) {
- equal( a, 4, "test value has been *2 and _then_ ^2");
- start();
- }
- });
+ cb = 0;
+
+ jQuery("<p data-operation='*2'></p><p data-operation='^2'></p>").appendTo("#qunit-fixture")
+ // The test will always pass if no properties are animated or if the duration is 0
+ .animate({fontSize: 12}, 13, function() {
+ a *= jQuery(this).data("operation") === "*2" ? 2 : a;
+ cb++;
+ if ( cb === 2 ) {
+ equal( a, 4, "test value has been *2 and _then_ ^2");
+ start();
+ }
+ });
});
asyncTest( "callbacks that throw exceptions will be removed (#5684)", function() {
@@ -1301,11 +1299,11 @@ asyncTest( "callbacks that throw exceptions will be removed (#5684)", function()
var foo = jQuery( "#foo" );
- function testException() {
+ function TestException() {
}
foo.animate({ height: 1 }, 1, function() {
- throw new testException();
+ throw new TestException();
});
// this test thoroughly abuses undocumented methods - please feel free to update
@@ -1317,7 +1315,7 @@ asyncTest( "callbacks that throw exceptions will be removed (#5684)", function()
setTimeout(function() {
// the first call to fx.tick should raise the callback exception
- raises( jQuery.fx.tick, testException, "Exception was thrown" );
+ raises( jQuery.fx.tick, TestException, "Exception was thrown" );
// the second call shouldn't
jQuery.fx.tick();
diff --git a/test/unit/queue.js b/test/unit/queue.js
index 4192c7169..5328d608a 100644
--- a/test/unit/queue.js
+++ b/test/unit/queue.js
@@ -27,7 +27,7 @@ test( "queue() with other types", 14, function() {
equal( ++counter, 4, "Dequeuing" );
});
- defer = $div.promise("foo").done(function() {
+ $div.promise("foo").done(function() {
equal( counter, 4, "Testing previous call to dequeue in deferred" );
start();
});
@@ -81,7 +81,6 @@ test("queue() passes in the next item in the queue as a parameter to fx queues",
div.queue(function(next) {
equal(++counter, 1, "Dequeueing");
- var self = this;
setTimeout(function() { next(); }, 500);
}).queue(function(next) {
equal(++counter, 2, "Next was called");
@@ -156,7 +155,7 @@ test("clearQueue(name) clears the queue", function() {
counter++;
jQuery(this).clearQueue("foo");
next();
- }).queue("foo", function(next) {
+ }).queue("foo", function( next ) {
counter++;
});
@@ -180,7 +179,7 @@ test("clearQueue() clears the fx queue", function() {
counter++;
var self = this;
setTimeout(function() { jQuery(self).clearQueue(); next(); }, 50);
- }).queue(function(next) {
+ }).queue(function( next ) {
counter++;
});
diff --git a/test/unit/traversing.js b/test/unit/traversing.js
index 1060e7e40..b600e130b 100644
--- a/test/unit/traversing.js
+++ b/test/unit/traversing.js
@@ -143,12 +143,13 @@ test("is() with :has() selectors", function() {
test("is() with positional selectors", function() {
expect(24);
- var html = jQuery(
- "<p id='posp'><a class='firsta' href='#'><em>first</em></a><a class='seconda' href='#'><b>test</b></a><em></em></p>"
- ).appendTo( "#qunit-fixture" ),
- isit = function(sel, match, expect) {
- equal( jQuery( sel ).is( match ), expect, "jQuery('" + sel + "').is('" + match + "')" );
- };
+ var isit = function(sel, match, expect) {
+ equal( jQuery( sel ).is( match ), expect, "jQuery('" + sel + "').is('" + match + "')" );
+ };
+
+ jQuery(
+ "<p id='posp'><a class='firsta' href='#'><em>first</em></a><a class='seconda' href='#'><b>test</b></a><em></em></p>"
+ ).appendTo( "#qunit-fixture" );
isit( "#posp", "#posp:first", true );
isit( "#posp", "#posp:eq(2)", false );
@@ -271,7 +272,11 @@ test("filter(jQuery)", function() {
test("filter() with positional selectors", function() {
expect(19);
- var html = jQuery( "" +
+ var filterit = function(sel, filter, length) {
+ equal( jQuery( sel ).filter( filter ).length, length, "jQuery( " + sel + " ).filter( " + filter + " )" );
+ };
+
+ jQuery( "" +
"<p id='posp'>" +
"<a class='firsta' href='#'>" +
"<em>first</em>" +
@@ -280,10 +285,7 @@ test("filter() with positional selectors", function() {
"<b>test</b>" +
"</a>" +
"<em></em>" +
- "</p>" ).appendTo( "#qunit-fixture" ),
- filterit = function(sel, filter, length) {
- equal( jQuery( sel ).filter( filter ).length, length, "jQuery( " + sel + " ).filter( " + filter + " )" );
- };
+ "</p>" ).appendTo( "#qunit-fixture" );
filterit( "#posp", "#posp:first", 1);
filterit( "#posp", "#posp:eq(2)", 0 );
@@ -424,7 +426,7 @@ test("has(Element)", function() {
deepEqual( detached.has( detached.find("i")[0] ).get(), detached.get(), "...Even when detached" );
var multipleParent = jQuery("#qunit-fixture, #header").has(jQuery("#sndp")[0]);
- deepEqual( obj.get(), q("qunit-fixture"), "Does not include elements that do not have the element as a descendant" );
+ deepEqual( multipleParent.get(), q("qunit-fixture"), "Does not include elements that do not have the element as a descendant" );
});
test("has(Selector)", function() {
@@ -459,7 +461,7 @@ test("has(Arrayish)", function() {
deepEqual( multipleParent.get(), q("qunit-fixture"), "Does not include elements that do not have an element in the jQuery list as a descendant" );
var multipleHas = jQuery("#qunit-fixture").has(jQuery("#sndp, #first"));
- deepEqual( simple.get(), q("qunit-fixture"), "Only adds elements once" );
+ deepEqual( multipleHas.get(), q("qunit-fixture"), "Only adds elements once" );
});
test("addBack()", function() {