Move size() test to deprecated.js and avoid in other tests. Close gh-1237.

This commit is contained in:
Michał Gołębiowski 2013-04-09 00:18:45 +02:00 committed by Dave Methvin
parent bea0d9a49d
commit 52394ba986
9 changed files with 48 additions and 48 deletions

View File

@ -1799,8 +1799,7 @@ module( "ajax", {
}); });
asyncTest( "jQuery.fn.load() - callbacks get the correct parameters", 8, function() { asyncTest( "jQuery.fn.load() - callbacks get the correct parameters", 8, function() {
var slice = [].slice, var completeArgs = {};
completeArgs = {};
jQuery.ajaxSetup({ jQuery.ajaxSetup({
success: function( _, status, jqXHR ) { success: function( _, status, jqXHR ) {

View File

@ -1017,7 +1017,7 @@ var testAddClass = function( valueObj ) {
var div = jQuery("#qunit-fixture div"); var div = jQuery("#qunit-fixture div");
div.addClass( valueObj("test") ); div.addClass( valueObj("test") );
var pass = true; 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") ) { if ( !~div.get( i ).className.indexOf("test") ) {
pass = false; pass = false;
} }

View File

@ -677,11 +677,6 @@ test("length", function() {
equal( jQuery("#qunit-fixture p").length, 6, "Get Number of Elements Found" ); 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() { test("get()", function() {
expect(1); expect(1);
deepEqual( jQuery("#qunit-fixture p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" ); 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"); var div = jQuery("div");
div.each(function(){this.foo = "zoo";}); div.each(function(){this.foo = "zoo";});
var pass = true; 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" ) { if ( div.get(i).foo != "zoo" ) {
pass = false; pass = false;
} }

View File

@ -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" ); equal( tr[ 0 ].style.display, trDisplay, "For detached tr elements, display should always be like for attached trs" );
tr.remove(); 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" ); equal( span[ 0 ].style.display, "inline", "For detached span elements, display should always be inline" );
span.remove(); span.remove();
}); });

View File

@ -63,7 +63,7 @@ test( "jQuery.hasData no side effects", function() {
}); });
function dataTests (elem) { function dataTests (elem) {
var oldCacheLength, dataObj, internalDataObj, expected, actual; var dataObj, internalDataObj;
equal( jQuery.data(elem, "foo"), undefined, "No data exists initially" ); equal( jQuery.data(elem, "foo"), undefined, "No data exists initially" );
strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists initially" ); strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists initially" );

View File

@ -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" );
});
}

36
test/unit/effects.js vendored
View File

@ -51,8 +51,6 @@ test("show()", 27, function () {
hiddendiv.css("display",""); hiddendiv.css("display","");
var displaysActual = [],
displaysExpected = [];
div = jQuery("#fx-queue div").slice(0, 4); div = jQuery("#fx-queue div").slice(0, 4);
div.show().each(function() { div.show().each(function() {
notEqual(this.style.display, "none", "don't change any <div> with display block"); 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"), var $span = jQuery("#show-tests span"),
displayNone = $span.css("display"), displayNone = $span.css("display"),
display = "", num = 0; display = "";
$span.show(); $span.show();
@ -609,8 +607,7 @@ test("stop() - several in queue", function() {
expect( 5 ); expect( 5 );
var nw, time, var nw, time,
$foo = jQuery( "#foo" ), $foo = jQuery( "#foo" );
w = 0;
// default duration is 400ms, so 800px ensures we aren't 0 or 1 after 1ms // default duration is 400ms, so 800px ensures we aren't 0 or 1 after 1ms
$foo.hide().css( "width", 800 ); $foo.hide().css( "width", 800 );
@ -1283,17 +1280,18 @@ test("callbacks should fire in correct order (#9100)", function() {
stop(); stop();
var a = 1, var a = 1,
cb = 0, 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 jQuery("<p data-operation='*2'></p><p data-operation='^2'></p>").appendTo("#qunit-fixture")
.animate({fontSize: 12}, 13, function() { // The test will always pass if no properties are animated or if the duration is 0
a *= jQuery(this).data("operation") === "*2" ? 2 : a; .animate({fontSize: 12}, 13, function() {
cb++; a *= jQuery(this).data("operation") === "*2" ? 2 : a;
if ( cb === 2 ) { cb++;
equal( a, 4, "test value has been *2 and _then_ ^2"); if ( cb === 2 ) {
start(); equal( a, 4, "test value has been *2 and _then_ ^2");
} start();
}); }
});
}); });
asyncTest( "callbacks that throw exceptions will be removed (#5684)", function() { 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" ); var foo = jQuery( "#foo" );
function testException() { function TestException() {
} }
foo.animate({ height: 1 }, 1, function() { foo.animate({ height: 1 }, 1, function() {
throw new testException(); throw new TestException();
}); });
// this test thoroughly abuses undocumented methods - please feel free to update // 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() { setTimeout(function() {
// the first call to fx.tick should raise the callback exception // 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 // the second call shouldn't
jQuery.fx.tick(); jQuery.fx.tick();

View File

@ -27,7 +27,7 @@ test( "queue() with other types", 14, function() {
equal( ++counter, 4, "Dequeuing" ); 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" ); equal( counter, 4, "Testing previous call to dequeue in deferred" );
start(); 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) { div.queue(function(next) {
equal(++counter, 1, "Dequeueing"); equal(++counter, 1, "Dequeueing");
var self = this;
setTimeout(function() { next(); }, 500); setTimeout(function() { next(); }, 500);
}).queue(function(next) { }).queue(function(next) {
equal(++counter, 2, "Next was called"); equal(++counter, 2, "Next was called");
@ -156,7 +155,7 @@ test("clearQueue(name) clears the queue", function() {
counter++; counter++;
jQuery(this).clearQueue("foo"); jQuery(this).clearQueue("foo");
next(); next();
}).queue("foo", function(next) { }).queue("foo", function( next ) {
counter++; counter++;
}); });
@ -180,7 +179,7 @@ test("clearQueue() clears the fx queue", function() {
counter++; counter++;
var self = this; var self = this;
setTimeout(function() { jQuery(self).clearQueue(); next(); }, 50); setTimeout(function() { jQuery(self).clearQueue(); next(); }, 50);
}).queue(function(next) { }).queue(function( next ) {
counter++; counter++;
}); });

View File

@ -143,12 +143,13 @@ test("is() with :has() selectors", function() {
test("is() with positional selectors", function() { test("is() with positional selectors", function() {
expect(24); expect(24);
var html = jQuery( var isit = function(sel, match, expect) {
"<p id='posp'><a class='firsta' href='#'><em>first</em></a><a class='seconda' href='#'><b>test</b></a><em></em></p>" equal( jQuery( sel ).is( match ), expect, "jQuery('" + sel + "').is('" + match + "')" );
).appendTo( "#qunit-fixture" ), };
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:first", true );
isit( "#posp", "#posp:eq(2)", false ); isit( "#posp", "#posp:eq(2)", false );
@ -271,7 +272,11 @@ test("filter(jQuery)", function() {
test("filter() with positional selectors", function() { test("filter() with positional selectors", function() {
expect(19); 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'>" + "<p id='posp'>" +
"<a class='firsta' href='#'>" + "<a class='firsta' href='#'>" +
"<em>first</em>" + "<em>first</em>" +
@ -280,10 +285,7 @@ test("filter() with positional selectors", function() {
"<b>test</b>" + "<b>test</b>" +
"</a>" + "</a>" +
"<em></em>" + "<em></em>" +
"</p>" ).appendTo( "#qunit-fixture" ), "</p>" ).appendTo( "#qunit-fixture" );
filterit = function(sel, filter, length) {
equal( jQuery( sel ).filter( filter ).length, length, "jQuery( " + sel + " ).filter( " + filter + " )" );
};
filterit( "#posp", "#posp:first", 1); filterit( "#posp", "#posp:first", 1);
filterit( "#posp", "#posp:eq(2)", 0 ); 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" ); deepEqual( detached.has( detached.find("i")[0] ).get(), detached.get(), "...Even when detached" );
var multipleParent = jQuery("#qunit-fixture, #header").has(jQuery("#sndp")[0]); 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() { 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" ); 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")); 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() { test("addBack()", function() {