});
asyncTest( "jQuery.fn.load() - callbacks get the correct parameters", 8, function() {
- var slice = [].slice,
- completeArgs = {};
+ var completeArgs = {};
jQuery.ajaxSetup({
success: function( _, status, jqXHR ) {
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;
}
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" );
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;
}
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();
});
});
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" );
-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" );
+ });
+}
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");
var $span = jQuery("#show-tests span"),
displayNone = $span.css("display"),
- display = "", num = 0;
+ display = "";
$span.show();
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 );
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() {
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
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();
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();
});
div.queue(function(next) {
equal(++counter, 1, "Dequeueing");
- var self = this;
setTimeout(function() { next(); }, 500);
}).queue(function(next) {
equal(++counter, 2, "Next was called");
counter++;
jQuery(this).clearQueue("foo");
next();
- }).queue("foo", function(next) {
+ }).queue("foo", function( next ) {
counter++;
});
counter++;
var self = this;
setTimeout(function() { jQuery(self).clearQueue(); next(); }, 50);
- }).queue(function(next) {
+ }).queue(function( next ) {
counter++;
});
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 );
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>" +
"<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 );
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() {
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() {