Tests: don't use deprecated argument in test declaration

Ref aabe94edb4
This commit is contained in:
Oleg Gaidarenko 2015-07-30 20:48:26 +03:00
parent 6af92cafca
commit b8b111e337
11 changed files with 191 additions and 64 deletions

View File

@ -20,7 +20,9 @@ module( "ajax", {
});
(function() {
test("Unit Testing Environment", 2, function () {
test("Unit Testing Environment", function () {
expect( 2 );
ok( hasPHP, "Running in an environment with PHP support. The AJAX tests only run if the environment supports PHP!" );
ok( !isLocal, "Unit tests are not ran from file:// (especially in Chrome. If you must test from file:// with Chrome, run it with the --allow-file-access-from-files flag!)" );
});
@ -1318,7 +1320,9 @@ module( "ajax", {
}
});
test( "#7531 - jQuery.ajax() - Location object as url", 1, function () {
test( "#7531 - jQuery.ajax() - Location object as url", function () {
expect( 1 );
var xhr,
success = false;
try {
@ -1424,7 +1428,9 @@ module( "ajax", {
});
});
test( "#9887 - jQuery.ajax() - Context with circular references (#9887)", 2, function () {
test( "#9887 - jQuery.ajax() - Context with circular references (#9887)", function () {
expect( 2 );
var success = false,
context = {};
context.field = context;
@ -1720,7 +1726,9 @@ module( "ajax", {
//----------- jQuery.domManip()
test( "#11264 - jQuery.domManip() - no side effect because of ajaxSetup or global events", 1, function() {
test( "#11264 - jQuery.domManip() - no side effect because of ajaxSetup or global events", function() {
expect( 1 );
jQuery.ajaxSetup({
type: "POST"
});
@ -2126,7 +2134,9 @@ module( "ajax", {
//----------- jQuery.active
test( "jQuery.active", 1, function() {
test( "jQuery.active", function() {
expect( 1 );
ok( jQuery.active === 0, "ajax active counter should be zero: " + jQuery.active );
});

View File

@ -732,7 +732,8 @@ test( "prop('tabindex')", function() {
equal( jQuery("#linkWithNoHrefWithNegativeTabIndex").prop("tabindex"), -1, "anchor without href, no tabindex set" );
});
test( "prop('tabindex', value)", 10, function() {
test( "prop('tabindex', value)", function() {
expect( 10 );
var clone,
element = jQuery("#divWithNoTabIndex");
@ -1450,7 +1451,9 @@ test( "coords returns correct values in IE6/IE7, see #10828", function() {
equal( area.attr("coords"), "0,0,0,0", "did not retrieve coords correctly" );
});
test( "should not throw at $(option).val() (#14686)", 1, function() {
test( "should not throw at $(option).val() (#14686)", function() {
expect( 1 );
try {
jQuery( "<option/>" ).val();
ok( true );

View File

@ -166,7 +166,9 @@ test( "globalEval", function() {
equal( window.globalEvalTest, 3, "Test context (this) is the window object" );
});
test( "globalEval execution after script injection (#7862)", 1, function() {
test( "globalEval execution after script injection (#7862)", function() {
expect( 1 );
var now,
script = document.createElement( "script" );
@ -1182,7 +1184,9 @@ test("jQuery.each(Object,Function)", function() {
equal( i, document.styleSheets.length, "Iteration over document.styleSheets" );
});
test("jQuery.each/map(undefined/null,Function)", 1, function() {
test("jQuery.each/map(undefined/null,Function)", function() {
expect( 1 );
try {
jQuery.each( undefined, jQuery.noop );
jQuery.each( null, jQuery.noop );
@ -1458,7 +1462,9 @@ test("jQuery.parseJSON", function() {
strictEqual( jQuery.parseJSON([ 0 ]), 0, "Input cast to string" );
});
test("jQuery.parseXML", 8, function(){
test("jQuery.parseXML", function(){
expect( 8 );
var xml, tmp;
try {
xml = jQuery.parseXML( "<p>A <b>well-formed</b> xml string</p>" );

View File

@ -119,7 +119,9 @@ test("css(String|Hash)", function() {
"Make sure that a string z-index is returned from css('z-index') (#14432)." );
});
test( "css(String) computed values", 3, function() {
test( "css(String) computed values", function() {
expect( 3 );
var div = jQuery( "<div/>" ).addClass( "get-computed-value" ),
fixture = document.getElementById( "qunit-fixture" );
@ -130,7 +132,9 @@ test( "css(String) computed values", 3, function() {
});
test( "css() explicit and relative values", 29, function() {
test( "css() explicit and relative values", function() {
expect( 29 );
var $elem = jQuery("#nothiddendiv");
$elem.css({ "width": 1, "height": 1, "paddingLeft": "1px", "opacity": 1 });
@ -217,7 +221,9 @@ test( "css() explicit and relative values", 29, function() {
equal( $elem.css("opacity"), "1", "'+=0.5' on opacity (params)" );
});
test( "css() non-px relative values (gh-1711)", 17, function() {
test( "css() non-px relative values (gh-1711)", function() {
expect( 17 );
var cssCurrent,
units = {},
$child = jQuery( "#nothiddendivchild" ),
@ -962,7 +968,9 @@ test("certain css values of 'normal' should be convertable to a number, see #862
// only run this test in IE9
if ( document.documentMode === 9 ) {
test( ".css('filter') returns a string in IE9, see #12537", 1, function() {
test( ".css('filter') returns a string in IE9, see #12537", function() {
expect( 1 );
equal( jQuery("<div style='-ms-filter:\"progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFFFFF, endColorstr=#ECECEC)\";'></div>").css("filter"), "progid:DXImageTransform.Microsoft.gradient(startColorstr=#FFFFFF, endColorstr=#ECECEC)", "IE9 returns the correct value from css('filter')." );
});
}
@ -1170,7 +1178,9 @@ asyncTest( "Clearing a Cloned Element's Style Shouldn't Clear the Original Eleme
window.setTimeout( start, 1000 );
});
test( "show() after hide() should always set display to initial value (#14750)", 1, function() {
test( "show() after hide() should always set display to initial value (#14750)", function() {
expect( 1 );
var div = jQuery( "<div />" ),
fixture = jQuery( "#qunit-fixture" );
@ -1189,7 +1199,9 @@ test( "show() after hide() should always set display to initial value (#14750)",
exist = "order" in style || "WebkitOrder" in style;
if ( exist ) {
test( "Don't append px to CSS \"order\" value (#14049)", 1, function() {
test( "Don't append px to CSS \"order\" value (#14049)", function() {
expect( 1 );
var $elem = jQuery( "<div/>" );
$elem.css( "order", 2 );
@ -1198,7 +1210,9 @@ test( "show() after hide() should always set display to initial value (#14750)",
}
})();
test( "Do not throw on frame elements from css method (#15098)", 1, function() {
test( "Do not throw on frame elements from css method (#15098)", function() {
expect( 1 );
var frameWin, frameDoc,
frameElement = document.createElement( "iframe" ),
frameWrapDiv = document.createElement( "div" );
@ -1221,7 +1235,9 @@ test( "Do not throw on frame elements from css method (#15098)", 1, function() {
}
});
test( "get upper case alpha opacity in IE8", 1, function() {
test( "get upper case alpha opacity in IE8", function() {
expect( 1 );
var div = document.createElement( "div" ),
fixture = document.getElementById( "qunit-fixture" );

View File

@ -70,7 +70,9 @@ function dataTests( elem ) {
equal( jQuery._data(elem, "foo"), "foo2", "(sanity check) jQuery.removeData for user data does not remove internal data" );
}
test("jQuery.data(div)", 25, function() {
test("jQuery.data(div)", function() {
expect( 25 );
var div = document.createElement("div");
dataTests( div );
@ -81,11 +83,15 @@ test("jQuery.data(div)", 25, function() {
QUnit.expectJqData( this, div, "foo" );
});
test("jQuery.data({})", 25, function() {
test("jQuery.data({})", function() {
expect( 25 );
dataTests( {} );
});
test("jQuery.data(window)", 25, function() {
test("jQuery.data(window)", function() {
expect( 25 );
// remove bound handlers from window object to stop potential false positives caused by fix for #5280 in
// transports/xhr.js
jQuery( window ).off( "unload" );
@ -93,13 +99,17 @@ test("jQuery.data(window)", 25, function() {
dataTests( window );
});
test("jQuery.data(document)", 25, function() {
test("jQuery.data(document)", function() {
expect( 25 );
dataTests( document );
QUnit.expectJqData( this, document, "foo" );
});
test("Expando cleanup", 4, function() {
test("Expando cleanup", function() {
expect( 4 );
var div = document.createElement("div");
function assertExpandoAbsent(message) {
@ -161,7 +171,9 @@ test("jQuery.acceptData", function() {
});
// attempting to access the data of an undefined jQuery element should be undefined
test("jQuery().data() === undefined (#14101)", 2, function() {
test("jQuery().data() === undefined (#14101)", function() {
expect( 2 );
strictEqual(jQuery().data(), undefined);
strictEqual(jQuery().data("key"), undefined);
});

View File

@ -306,7 +306,9 @@ test("getting dimensions shouldn't modify runtimeStyle see #9233", function() {
$div.remove();
});
test( "table dimensions", 2, function() {
test( "table dimensions", function() {
expect( 2 );
var table = jQuery("<table><colgroup><col/><col/></colgroup><tbody><tr><td></td><td>a</td></tr><tr><td></td><td>a</td></tr></tbody></table>").appendTo("#qunit-fixture"),
tdElem = table.find("td").first(),
colElem = table.find("col").first().width( 300 );
@ -475,7 +477,9 @@ testIframe( "dimensions/documentLarge", "window vs. large document", function( j
ok( jQuery( document ).width() > jQuery( window ).width(), "document width is larger than window width" );
});
test( "allow modification of coordinates argument (gh-1848)", 1, function() {
test( "allow modification of coordinates argument (gh-1848)", function() {
expect( 1 );
var offsetTop,
element = jQuery( "<div/>" ).appendTo( "#qunit-fixture" );

100
test/unit/effects.js vendored
View File

@ -30,7 +30,9 @@ test("sanity check", function() {
equal( jQuery("#dl:visible, #qunit-fixture:visible, #foo:visible").length, 3, "QUnit state is correct for testing effects" );
});
test("show() basic", 1, function() {
test("show() basic", function() {
expect( 1 );
var div = jQuery("<div>").hide().appendTo("#qunit-fixture").show();
equal( div.css("display"), "block", "Make sure pre-hidden divs show" );
@ -39,7 +41,9 @@ test("show() basic", 1, function() {
div.remove();
});
test("show()", 27, function () {
test("show()", function () {
expect( 27 );
var div, speeds, test,
displaysActual, displaysExpected,
hiddendiv = jQuery("div.hidden");
@ -788,7 +792,9 @@ test("toggle()", function() {
ok( x.is(":visible"), "is visible again" );
});
test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() {
test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", function() {
expect( 7 );
var div = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" ).css({
color: "#ABC",
border: "5px solid black",
@ -1271,7 +1277,9 @@ test("hide hidden elements, with animation (bug #7141)", function() {
this.clock.tick( 10 );
});
test("animate unit-less properties (#4966)", 2, function() {
test("animate unit-less properties (#4966)", function() {
expect( 2 );
var div = jQuery( "<div style='z-index: 0; position: absolute;'></div>" ).appendTo( "#qunit-fixture" );
equal( div.css( "z-index" ), "0", "z-index is 0" );
div.animate({ zIndex: 2 }, function() {
@ -1280,7 +1288,9 @@ test("animate unit-less properties (#4966)", 2, function() {
this.clock.tick( 400 );
});
test( "animate properties missing px w/ opacity as last (#9074)", 2, function() {
test( "animate properties missing px w/ opacity as last (#9074)", function() {
expect( 2 );
expect( 6 );
var ml, l,
div = jQuery( "<div style='position: absolute; margin-left: 0; left: 0px;'></div>" )
@ -1379,7 +1389,9 @@ test("animate will scale margin properties individually", function() {
});
});
test("Do not append px to 'fill-opacity' #9548", 1, function() {
test("Do not append px to 'fill-opacity' #9548", function() {
expect( 1 );
var $div = jQuery("<div>").appendTo("#qunit-fixture");
$div.css("fill-opacity", 0).animate({ "fill-opacity": 1.0 }, 0, function () {
@ -1393,7 +1405,9 @@ test("Do not append px to 'fill-opacity' #9548", 1, function() {
});
});
test("line-height animates correctly (#13855)", 12, function() {
test("line-height animates correctly (#13855)", function() {
expect( 12 );
var t0,
clock = this.clock,
longDuration = 2000,
@ -1455,7 +1469,9 @@ clock.tick( 50 );
});
// Start 1.8 Animation tests
test( "jQuery.Animation( object, props, opts )", 4, function() {
test( "jQuery.Animation( object, props, opts )", function() {
expect( 4 );
var animation,
testObject = {
"foo": 0,
@ -1480,7 +1496,9 @@ test( "jQuery.Animation( object, props, opts )", 4, function() {
this.clock.tick( 10 );
});
test( "Animate Option: step: function( percent, tween )", 1, function() {
test( "Animate Option: step: function( percent, tween )", function() {
expect( 1 );
var counter = {};
jQuery( "#foo" ).animate({
prop1: 1,
@ -1505,7 +1523,9 @@ test( "Animate Option: step: function( percent, tween )", 1, function() {
this.clock.tick( 10 );
});
test( "Animate callbacks have correct context", 2, function() {
test( "Animate callbacks have correct context", function() {
expect( 2 );
var foo = jQuery( "#foo" );
foo.animate({
height: 10
@ -1520,7 +1540,9 @@ test( "Animate callbacks have correct context", 2, function() {
this.clock.tick( 10 );
});
test( "User supplied callback called after show when fx off (#8892)", 2, function() {
test( "User supplied callback called after show when fx off (#8892)", function() {
expect( 2 );
var foo = jQuery( "#foo" );
jQuery.fx.off = true;
foo.hide();
@ -1580,7 +1602,9 @@ test( "animate should set display for disconnected nodes", function() {
clock.tick( 400 );
});
test("Animation callback should not show animated element as :animated (#7157)", 1, function() {
test("Animation callback should not show animated element as :animated (#7157)", function() {
expect( 1 );
var foo = jQuery( "#foo" );
foo.animate({
@ -1591,7 +1615,9 @@ test("Animation callback should not show animated element as :animated (#7157)",
this.clock.tick( 100 );
});
test("Initial step callback should show element as :animated (#14623)", 1, function() {
test("Initial step callback should show element as :animated (#14623)", function() {
expect( 1 );
var foo = jQuery( "#foo" );
foo.animate({
@ -1606,7 +1632,9 @@ test("Initial step callback should show element as :animated (#14623)", 1, funct
foo.stop();
});
test( "hide called on element within hidden parent should set display to none (#10045)", 3, function() {
test( "hide called on element within hidden parent should set display to none (#10045)", function() {
expect( 3 );
var hidden = jQuery(".hidden"),
elems = jQuery("<div>hide</div><div>hide0</div><div>hide1</div>");
@ -1626,7 +1654,9 @@ test( "hide called on element within hidden parent should set display to none (#
this.clock.tick( 10 );
});
test( "hide, fadeOut and slideUp called on element width height and width = 0 should set display to none", 5, function() {
test( "hide, fadeOut and slideUp called on element width height and width = 0 should set display to none", function() {
expect( 5 );
var foo = jQuery("#foo"),
i = 0,
elems = jQuery();
@ -1655,7 +1685,9 @@ test( "hide, fadeOut and slideUp called on element width height and width = 0 sh
this.clock.tick( 400 );
});
test( "hide should not leave hidden inline elements visible (#14848)", 2, function() {
test( "hide should not leave hidden inline elements visible (#14848)", function() {
expect( 2 );
var el = jQuery("#simon1");
el.hide( 1, function() {
@ -1668,7 +1700,9 @@ test( "hide should not leave hidden inline elements visible (#14848)", 2, functi
this.clock.tick( 100 );
});
test( "Handle queue:false promises", 10, function() {
test( "Handle queue:false promises", function() {
expect( 10 );
var foo = jQuery( "#foo" ).clone().addBack(),
step = 1;
@ -1719,7 +1753,9 @@ test( "Handle queue:false promises", 10, function() {
this.clock.tick( 10 );
});
test( "multiple unqueued and promise", 4, function() {
test( "multiple unqueued and promise", function() {
expect( 4 );
var foo = jQuery( "#foo" ),
step = 1;
foo.animate({
@ -1751,7 +1787,9 @@ test( "multiple unqueued and promise", 4, function() {
this.clock.tick( 1000 );
});
test( "animate does not change start value for non-px animation (#7109)", 1, function() {
test( "animate does not change start value for non-px animation (#7109)", function() {
expect( 1 );
var parent = jQuery( "<div><div></div></div>" ).css({ width: 284, height: 1 }).appendTo( "#qunit-fixture" ),
child = parent.children().css({ fontSize: "98.6in", width: "0.01em", height: 1 }),
actual = parseFloat( child.css( "width" ) ),
@ -1771,7 +1809,9 @@ test( "animate does not change start value for non-px animation (#7109)", 1, fun
this.clock.tick( 10 );
});
test( "non-px animation handles non-numeric start (#11971)", 2, function() {
test( "non-px animation handles non-numeric start (#11971)", function() {
expect( 2 );
var foo = jQuery("#foo"),
initial = foo.css("backgroundPositionX");
@ -1801,7 +1841,9 @@ test( "non-px animation handles non-numeric start (#11971)", 2, function() {
this.clock.tick( 10 );
});
test("Animation callbacks (#11797)", 15, function() {
test("Animation callbacks (#11797)", function() {
expect( 15 );
var targets = jQuery("#foo").children(),
done = false,
expectedProgress = 0;
@ -1882,7 +1924,9 @@ test("Animation callbacks (#11797)", 15, function() {
this.clock.tick( 10 );
});
test( "Animate properly sets overflow hidden when animating width/height (#12117)", 8, function() {
test( "Animate properly sets overflow hidden when animating width/height (#12117)", function() {
expect( 8 );
jQuery.each( [ "height", "width" ], function( _, prop ) {
jQuery.each( [ 100, 0 ], function( _, value ) {
var div = jQuery("<div>").css( "overflow", "auto" ),
@ -1923,7 +1967,9 @@ test( "Each tick of the timer loop uses a fresh time (#12837)", function() {
tmp.stop();
});
test( "Animations with 0 duration don't ease (#12273)", 1, function() {
test( "Animations with 0 duration don't ease (#12273)", function() {
expect( 1 );
jQuery.easing.test = function() {
ok( false, "Called easing" );
};
@ -2162,7 +2208,9 @@ test( ".finish() is applied correctly when multiple elements were animated (#139
this.clock.tick( 1500 );
});
test( "slideDown() after stop() (#13483)", 2, function() {
test( "slideDown() after stop() (#13483)", function() {
expect( 2 );
var ul = jQuery( "<ul style='height: 100px; display: block;'></ul>" )
.appendTo("#qunit-fixture"),
origHeight = ul.height(),
@ -2193,7 +2241,9 @@ test( "slideDown() after stop() (#13483)", 2, function() {
clock.tick( 10 );
});
test( "Respect display value on inline elements (#14824)", 2, function() {
test( "Respect display value on inline elements (#14824)", function() {
expect( 2 );
var clock = this.clock,
fromStyleSheet = jQuery( "<span id='span-14824' />" ),
fromStyleAttr = jQuery( "<span style='display: block;' />" );

View File

@ -447,7 +447,9 @@ test("on(), trigger change on select", function() {
}).trigger("change");
});
test("on(), namespaced events, cloned events", 18, function() {
test("on(), namespaced events, cloned events", function() {
expect( 18 );
var firstp = jQuery( "#firstp" );
firstp.on("custom.test",function(){
@ -2612,7 +2614,9 @@ test( "Namespace preserved when passed an Event (#12739)", function() {
equal( triggered, 3, "foo.bar triggered" );
});
test( "make sure events cloned correctly", 18, function() {
test( "make sure events cloned correctly", function() {
expect( 18 );
var clone,
fixture = jQuery("#qunit-fixture"),
checkbox = jQuery("#check1"),
@ -2817,7 +2821,9 @@ test( "originalEvent property for Chrome, Safari and FF of simulated event", fun
// This tests are unreliable in Firefox
if ( !(/firefox/i.test( window.navigator.userAgent )) ) {
test( "Check order of focusin/focusout events", 2, function() {
test( "Check order of focusin/focusout events", function() {
expect( 2 );
var focus, blur,
input = jQuery( "#name" );

View File

@ -1938,7 +1938,9 @@ test( "remove() with filters", function() {
equal( jQuery("#nonnodes").contents().length, 0, "Check node,textnode,comment remove works" );
});
test( "remove() event cleaning ", 1, function() {
test( "remove() event cleaning ", function() {
expect( 1 );
var count, first, cleanUp;
count = 0;
@ -1953,7 +1955,9 @@ test( "remove() event cleaning ", 1, function() {
cleanUp.remove();
});
test( "remove() in document order #13779", 1, function() {
test( "remove() in document order #13779", function() {
expect( 1 );
var last,
cleanData = jQuery.cleanData;
@ -2025,7 +2029,9 @@ test("detach() with filters", function () {
equal(jQuery("#nonnodes").contents().length, 0, "Check node,textnode,comment remove works");
});
test( "detach() event cleaning ", 1, function() {
test( "detach() event cleaning ", function() {
expect( 1 );
var count, first, cleanUp;
count = 0;
@ -2567,7 +2573,9 @@ test( "insertAfter, insertBefore, etc do not work when destination is original e
});
});
test( "Index for function argument should be received (#13094)", 2, function() {
test( "Index for function argument should be received (#13094)", function() {
expect( 2 );
var i = 0;
jQuery("<div/><div/>").before(function( index ) {
@ -2576,7 +2584,9 @@ test( "Index for function argument should be received (#13094)", 2, function() {
});
test( "Make sure jQuery.fn.remove can work on elements in documentFragment", 1, function() {
test( "Make sure jQuery.fn.remove can work on elements in documentFragment", function() {
expect( 1 );
var fragment = document.createDocumentFragment(),
div = fragment.appendChild( document.createElement("div") );

View File

@ -1,6 +1,8 @@
module( "queue", { teardown: moduleTeardown });
test( "queue() with other types", 14, function() {
test( "queue() with other types", function() {
expect( 14 );
stop();
var $div = jQuery({}),

View File

@ -149,7 +149,9 @@ test( "wrapAll(String)", function() {
});
test( "wrapAll(Function)", 5, function() {
test( "wrapAll(Function)", function() {
expect( 5 );
var prev = jQuery( "#firstp" )[ 0 ].previousSibling,
p = jQuery( "#firstp,#first" )[ 0 ].parentNode,
result = jQuery( "#firstp,#first" ).wrapAll(function() {
@ -163,7 +165,9 @@ test( "wrapAll(Function)", 5, function() {
strictEqual( jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
});
test( "wrapAll(Function) check execution characteristics", 3, function() {
test( "wrapAll(Function) check execution characteristics", function() {
expect( 3 );
var i = 0;
jQuery( "non-existent" ).wrapAll(function() {
@ -179,7 +183,9 @@ test( "wrapAll(Function) check execution characteristics", 3, function() {
});
});
test( "wrapAll(Function)", 5, function() {
test( "wrapAll(Function)", function() {
expect( 5 );
var prev = jQuery( "#firstp" )[ 0 ].previousSibling,
p = jQuery( "#firstp,#first" )[ 0 ].parentNode,
result = jQuery( "#firstp,#first" ).wrapAll(function() {
@ -193,7 +199,9 @@ test( "wrapAll(Function)", 5, function() {
strictEqual( jQuery( "#first" ).parent().parent()[ 0 ].previousSibling, prev, "Correct Previous Sibling" );
});
test( "wrapAll(Function) check execution characteristics", 3, function() {
test( "wrapAll(Function) check execution characteristics", function() {
expect( 3 );
var i = 0;
jQuery( "non-existent" ).wrapAll(function() {