diff options
author | Timmy Willison <timmywillisn@gmail.com> | 2013-04-09 11:45:09 -0400 |
---|---|---|
committer | Timmy Willison <timmywillisn@gmail.com> | 2013-04-09 11:59:31 -0400 |
commit | 0fa52c11cbfe70780648b99717f1dd3502befaff (patch) | |
tree | 9cd6bfc3b17ae21385aeebd32205d7281934fa17 /test/unit/effects.js | |
parent | 0afc92bd73a61a0279a419647458e6ed89638ae0 (diff) | |
download | jquery-0fa52c11cbfe70780648b99717f1dd3502befaff.tar.gz jquery-0fa52c11cbfe70780648b99717f1dd3502befaff.zip |
Update jshintrc to conform to new style guide. Conform to onevar and unused in tests. Fixes #13755.
Diffstat (limited to 'test/unit/effects.js')
-rw-r--r-- | test/unit/effects.js | 160 |
1 files changed, 85 insertions, 75 deletions
diff --git a/test/unit/effects.js b/test/unit/effects.js index e6d0bbb06..b8e49ba45 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -38,7 +38,7 @@ test("show() basic", 2, function() { }); test("show()", 27, function () { - var div, + var div, speeds, old, test, hiddendiv = jQuery("div.hidden"); equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none"); @@ -56,7 +56,7 @@ test("show()", 27, function () { notEqual(this.style.display, "none", "don't change any <div> with display block"); }); - var speeds = { + speeds = { "null speed": null, "undefined speed": undefined, "false speed": false @@ -65,7 +65,7 @@ test("show()", 27, function () { jQuery.each(speeds, function(name, speed) { var pass = true; div.hide().show(speed).each(function() { - if ( this.style.display == "none" ) { + if ( this.style.display === "none" ) { pass = false; } }); @@ -86,10 +86,10 @@ test("show()", 27, function () { // #show-tests * is set display: none in CSS 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>"); - var old = jQuery("#test-table").show().css("display") !== "table"; + old = jQuery("#test-table").show().css("display") !== "table"; jQuery("#test-table").remove(); - var test = { + test = { "div" : "block", "p" : "block", "a" : "inline", @@ -126,11 +126,12 @@ test("show(Number) - other displays", function() { // #show-tests * is set display: none in CSS 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>"); - var old = jQuery("#test-table").show().css("display") !== "table", + var test, + old = jQuery("#test-table").show().css("display") !== "table", num = 0; jQuery("#test-table").remove(); - var test = { + test = { "div" : "block", "p" : "block", "a" : "inline", @@ -195,8 +196,8 @@ test("Persist correct display value", function() { test("animate(Hash, Object, Function)", function() { expect(1); stop(); - var hash = {opacity: "show"}; - var hashCopy = jQuery.extend({}, hash); + var hash = {opacity: "show"}, + hashCopy = jQuery.extend({}, hash); jQuery("#foo").animate(hash, 0, function() { equal( hash.opacity, hashCopy.opacity, "Check if animate changed the hash parameter" ); start(); @@ -310,13 +311,14 @@ test("animate table width/height", function() { test("animate table-row width/height", function() { expect(3); stop(); - var tr = jQuery("#table") - .attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 }) - .html("<tr style='height:42px;'><td style='padding:0;'><div style='width:20px;height:20px;'></div></td></tr>") - .find("tr"); + var displayMode, + tr = jQuery("#table") + .attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 }) + .html("<tr style='height:42px;'><td style='padding:0;'><div style='width:20px;height:20px;'></div></td></tr>") + .find("tr"); // IE<8 uses "block" instead of the correct display type - var displayMode = tr.css("display") !== "table-row" ? "block" : "table-row"; + displayMode = tr.css("display") !== "table-row" ? "block" : "table-row"; tr.animate({ width: 10, height: 10 }, 100, function() { equal( jQuery(this).css("display"), displayMode, "display mode is correct" ); @@ -329,13 +331,14 @@ test("animate table-row width/height", function() { test("animate table-cell width/height", function() { expect(3); stop(); - var td = jQuery("#table") - .attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 }) - .html("<tr><td style='width:42px;height:42px;padding:0;'><div style='width:20px;height:20px;'></div></td></tr>") - .find("td"); + var displayMode, + td = jQuery("#table") + .attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 }) + .html("<tr><td style='width:42px;height:42px;padding:0;'><div style='width:20px;height:20px;'></div></td></tr>") + .find("td"); // IE<8 uses "block" instead of the correct display type - var displayMode = td.css("display") !== "table-cell" ? "block" : "table-cell"; + displayMode = td.css("display") !== "table-cell" ? "block" : "table-cell"; td.animate({ width: 10, height: 10 }, 100, function() { equal( jQuery(this).css("display"), displayMode, "display mode is correct" ); @@ -445,7 +448,7 @@ asyncTest( "animate option { queue: 'name' }", function() { equal( parseFloat( foo.css("width") ), origWidth + 100, "Animation ended" ); equal( foo.queue("name").length, 1, "Queue length of 'name' queue" ); } - }).queue( "name", function( next ) { + }).queue( "name", function() { // last callback function deepEqual( order, [ 1, 2 ], "Callbacks in expected order" ); @@ -466,7 +469,9 @@ asyncTest( "animate option { queue: 'name' }", function() { test("animate with no properties", function() { expect(2); - var divs = jQuery("div"), count = 0; + var foo, + divs = jQuery("div"), + count = 0; divs.animate({}, function(){ count++; @@ -476,7 +481,7 @@ test("animate with no properties", function() { stop(); - var foo = jQuery("#foo"); + foo = jQuery("#foo"); foo.animate({}); foo.animate({top: 10}, 100, function(){ @@ -490,7 +495,9 @@ test("animate duration 0", function() { stop(); - var $elems = jQuery([{ a:0 },{ a:0 }]), counter = 0; + var $elem, + $elems = jQuery([{ a:0 },{ a:0 }]), + counter = 0; equal( jQuery.timers.length, 0, "Make sure no animation was running from another test" ); @@ -522,7 +529,7 @@ test("animate duration 0", function() { start(); }); - var $elem = jQuery("<div />"); + $elem = jQuery("<div />"); $elem.show(0, function(){ ok(true, "Show callback with no duration"); }); @@ -562,7 +569,8 @@ test("stop()", function() { expect( 4 ); stop(); - var $foo = jQuery("#foo"), + var $one, $two, + $foo = jQuery("#foo"), tests = 2, w = 0; @@ -586,8 +594,8 @@ test("stop()", function() { }, 100); }, 100); - var $one = jQuery("#fadein"); - var $two = jQuery("#show"); + $one = jQuery("#fadein"); + $two = jQuery("#show"); $one.fadeTo(100, 0, function() { $one.stop(); }); @@ -640,8 +648,8 @@ test("stop(clearQueue)", function() { expect(4); stop(); - var $foo = jQuery("#foo"); - var w = 0; + var $foo = jQuery("#foo"), + w = 0; $foo.hide().css( "width", 200 ).css("width"); $foo.animate({ "width": "show" }, 1000); @@ -649,11 +657,11 @@ test("stop(clearQueue)", function() { $foo.animate({ "width": "show" }, 1000); setTimeout(function(){ var nw = $foo.css("width"); - ok( parseFloat( nw ) != w, "An animation occurred " + nw + " " + w + "px"); + ok( parseFloat( nw ) !== w, "An animation occurred " + nw + " " + w + "px"); $foo.stop(true); nw = $foo.css("width"); - ok( parseFloat( nw ) != w, "Stop didn't reset the animation " + nw + " " + w + "px"); + ok( parseFloat( nw ) !== w, "Stop didn't reset the animation " + nw + " " + w + "px"); equal( $foo.queue().length, 0, "The animation queue was cleared" ); setTimeout(function(){ @@ -667,8 +675,8 @@ test("stop(clearQueue, gotoEnd)", function() { expect(1); stop(); - var $foo = jQuery("#foo"); - var w = 0; + var $foo = jQuery("#foo"), + w = 0; $foo.hide().css( "width", 200 ).css("width"); $foo.animate({ width: "show" }, 1000); @@ -677,7 +685,7 @@ test("stop(clearQueue, gotoEnd)", function() { $foo.animate({ width: "hide" }, 1000); setTimeout(function(){ var nw = $foo.css("width"); - ok( parseFloat( nw ) != w, "An animation occurred " + nw + " " + w + "px"); + ok( parseFloat( nw ) !== w, "An animation occurred " + nw + " " + w + "px"); $foo.stop(false, true); nw = $foo.css("width"); @@ -872,66 +880,67 @@ jQuery.each({ }, "100": function( elem, prop ) { jQuery( elem ).addClass( "wide" + prop ); - return prop == "opacity" ? 1 : 100; + return prop === "opacity" ? 1 : 100; }, "50": function( elem, prop ) { - return prop == "opacity" ? 0.50 : 50; + return prop === "opacity" ? 0.50 : 50; }, - "0": function( elem, prop ) { + "0": function( elem ) { jQuery( elem ).addClass( "noback" ); return 0; } }, function( tn, t ) { test(fn + " to " + tn, function() { - var elem = jQuery.makeTest( fn + " to " + tn ); - - var t_w = t( elem, "width" ); - var f_w = f( elem, "width" ); - var t_h = t( elem, "height" ); - var f_h = f( elem, "height" ); - var t_o = t( elem, "opacity" ); - var f_o = f( elem, "opacity" ); + var num, anim, + elem = jQuery.makeTest( fn + " to " + tn ), + t_w = t( elem, "width" ), + f_w = f( elem, "width" ), + t_h = t( elem, "height" ), + f_h = f( elem, "height" ), + t_o = t( elem, "opacity" ), + f_o = f( elem, "opacity" ); if ( f_o === "" ) { f_o = 1; } - var num = 0; + num = 0; // TODO: uncrowd this - if ( t_h == "show" ) {num++;} - if ( t_w == "show" ) {num++;} - if ( t_w == "hide" || t_w == "show" ) {num++;} - if ( t_h == "hide" || t_h == "show" ) {num++;} - if ( t_o == "hide" || t_o == "show" ) {num++;} - if ( t_w == "hide" ) {num++;} - if ( t_o.constructor == Number ) {num += 2;} - if ( t_w.constructor == Number ) {num += 2;} - if ( t_h.constructor == Number ) {num +=2;} + if ( t_h === "show" ) {num++;} + if ( t_w === "show" ) {num++;} + if ( t_w === "hide" || t_w === "show" ) {num++;} + if ( t_h === "hide" || t_h === "show" ) {num++;} + if ( t_o === "hide" || t_o === "show" ) {num++;} + if ( t_w === "hide" ) {num++;} + if ( t_o.constructor === Number ) {num += 2;} + if ( t_w.constructor === Number ) {num += 2;} + if ( t_h.constructor === Number ) {num +=2;} expect( num ); stop(); - var anim = { width: t_w, height: t_h, opacity: t_o }; + anim = { width: t_w, height: t_h, opacity: t_o }; elem.animate(anim, 50); jQuery.when( elem ).done(function( elem ) { + var cur_o, cur_w, cur_h, old_h; elem = elem[ 0 ]; - if ( t_w == "show" ) { + if ( t_w === "show" ) { equal( elem.style.display, "block", "Showing, display should block: " + elem.style.display ); } - if ( t_w == "hide" || t_w == "show" ) { + if ( t_w === "hide" || t_w === "show" ) { ok( f_w === "" ? elem.style.width === f_w : elem.style.width.indexOf( f_w ) === 0, "Width must be reset to " + f_w + ": " + elem.style.width ); } - if ( t_h == "hide" || t_h == "show" ) { + if ( t_h === "hide" || t_h === "show" ) { ok( f_h === "" ? elem.style.height === f_h : elem.style.height.indexOf( f_h ) === 0, "Height must be reset to " + f_h + ": " + elem.style.height ); } - var cur_o = jQuery.style(elem, "opacity"); + cur_o = jQuery.style(elem, "opacity"); if ( f_o !== jQuery.css(elem, "opacity") ) { f_o = f( elem, "opacity" ); @@ -947,38 +956,38 @@ jQuery.each({ cur_o = 1; } - if ( t_o == "hide" || t_o == "show" ) { + if ( t_o === "hide" || t_o === "show" ) { equal( cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o ); } - if ( t_w == "hide" ) { + if ( t_w === "hide" ) { equal( elem.style.display, "none", "Hiding, display should be none: " + elem.style.display ); } - if ( t_o.constructor == Number ) { + if ( t_o.constructor === Number ) { equal( cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o ); - ok( jQuery.css(elem, "opacity") !== "" || cur_o == t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o ); + ok( jQuery.css(elem, "opacity") !== "" || cur_o === t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o ); } - if ( t_w.constructor == Number ) { + if ( t_w.constructor === Number ) { equal( elem.style.width, t_w + "px", "Final width should be " + t_w + ": " + elem.style.width ); - var cur_w = jQuery.css( elem,"width" ); + cur_w = jQuery.css( elem,"width" ); - ok( elem.style.width !== "" || cur_w == t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w ); + ok( elem.style.width !== "" || cur_w === t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w ); } - if ( t_h.constructor == Number ) { + if ( t_h.constructor === Number ) { equal( elem.style.height, t_h + "px", "Final height should be " + t_h + ": " + elem.style.height ); - var cur_h = jQuery.css( elem,"height" ); + cur_h = jQuery.css( elem,"height" ); - ok( elem.style.height !== "" || cur_h == t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_h ); + ok( elem.style.height !== "" || cur_h === t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_h ); } - if ( t_h == "show" ) { - var old_h = jQuery.css( elem, "height" ); + if ( t_h === "show" ) { + old_h = jQuery.css( elem, "height" ); jQuery( elem ).append("<br/>Some more text<br/>and some more..."); if ( /Auto/.test( fn ) ) { @@ -1364,7 +1373,8 @@ test("Do not append px to 'fill-opacity' #9548", 1, function() { // Start 1.8 Animation tests asyncTest( "jQuery.Animation( object, props, opts )", 4, function() { - var testObject = { + var animation, + testObject = { "foo": 0, "bar": 1, "width": 100 @@ -1375,7 +1385,7 @@ asyncTest( "jQuery.Animation( object, props, opts )", 4, function() { "width": 200 }; - var animation = jQuery.Animation( testObject, testDest, { "duration": 1 }); + animation = jQuery.Animation( testObject, testDest, { "duration": 1 }); animation.done(function() { for ( var prop in testDest ) { equal( testObject[ prop ], testDest[ prop ], "Animated: " + prop ); @@ -2008,7 +2018,7 @@ test( ".finish( \"custom\" ) - custom queue animations", function() { }); test( ".finish() calls finish of custom queue functions", function() { - function queueTester( next ) { + function queueTester() { } var div = jQuery( "<div>" ); |