diff options
author | Corey Frang <gnarf@gnarf.net> | 2012-04-23 15:05:12 -0400 |
---|---|---|
committer | Dave Methvin <dave.methvin@gmail.com> | 2012-04-23 15:05:12 -0400 |
commit | 58ed62ed12cb48d9224f699e86e197804ca5ece4 (patch) | |
tree | 9acdcb4ccb6e4ef4d2d20b887b82a476aa3e8e47 /test/unit | |
parent | 8ad22a2b152f55b12385b126305383e2c5ba1994 (diff) | |
download | jquery-58ed62ed12cb48d9224f699e86e197804ca5ece4.tar.gz jquery-58ed62ed12cb48d9224f699e86e197804ca5ece4.zip |
Effects: 1.8 Animation Rewrite - thanks @mikesherov and @gibson042
Diffstat (limited to 'test/unit')
-rw-r--r-- | test/unit/css.js | 6 | ||||
-rw-r--r-- | test/unit/effects.js | 63 |
2 files changed, 65 insertions, 4 deletions
diff --git a/test/unit/css.js b/test/unit/css.js index 6d0b39f81..a192c1b5b 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -37,13 +37,13 @@ test("css(String|Hash)", function() { div2.remove(); - // handle negative numbers by ignoring #1599, #4216 + // handle negative numbers by setting to zero #11604 jQuery("#nothiddendiv").css( {width: 1, height: 1} ); var width = parseFloat(jQuery("#nothiddendiv").css("width")), height = parseFloat(jQuery("#nothiddendiv").css("height")); jQuery("#nothiddendiv").css({ width: -1, height: -1 }); - equal( parseFloat(jQuery("#nothiddendiv").css("width")), width, "Test negative width ignored"); - equal( parseFloat(jQuery("#nothiddendiv").css("height")), height, "Test negative height ignored"); + equal( parseFloat(jQuery("#nothiddendiv").css("width")), 0, "Test negative width set to 0"); + equal( parseFloat(jQuery("#nothiddendiv").css("height")), 0, "Test negative height set to 0"); equal( jQuery("<div style='display: none;'>").css("display"), "none", "Styles on disconnected nodes"); diff --git a/test/unit/effects.js b/test/unit/effects.js index 25c9834e4..74f83e7c4 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -792,7 +792,7 @@ jQuery.checkOverflowDisplay = function(){ start(); }; -test( "jQuery.fx.prototype.cur()", 6, function() { +test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() { var div = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" ).css({ color: "#ABC", border: "5px solid black", @@ -814,6 +814,8 @@ test( "jQuery.fx.prototype.cur()", 6, function() { // backgroundPosition actually returns 0% 0% in most browser // this fakes a "" return + // hook now gets called twice because Tween will grab the current + // value as it is being newed jQuery.cssHooks.backgroundPosition = { get: function() { ok( true, "hook used" ); @@ -1387,3 +1389,62 @@ test("animate will scale margin properties individually", function() { }); start(); }); + +// Start 1.8 Animation tests +asyncTest( "jQuery.Animation( object, props, opts )", 1, function() { + var testObject = { + foo: 0, + bar: 1, + width: 100 + }, + testDest = { + foo: 1, + bar: 0, + width: 200 + }; + + jQuery.Animation( testObject, testDest, { duration: 1 }) + .done( function() { + deepEqual( testObject, testDest, "Animated foo and bar" ); + start(); + }); +}); + +asyncTest( "Animate Option: step: function( percent, tween )", 1, function() { + var counter = {}; + jQuery( "#foo" ).animate({ + prop1: 1, + prop2: 2, + prop3: 3 + }, { + duration: 1, + step: function( value, tween ) { + calls = counter[ tween.prop ] = counter[ tween.prop ] || []; + calls.push( value ); + } + }).queue( function( next ) { + deepEqual( counter, { + prop1: [0, 1], + prop2: [0, 2], + prop3: [0, 3] + }, "Step function was called once at 0% and once at 100% for each property"); + next(); + start(); + }); +}); + + +asyncTest( "Animate callbacks have correct context", 2, function() { + var foo = jQuery( "#foo" ); + foo.animate({ + height: 10 + }, 10, function() { + equal( foo[ 0 ], this, "Complete callback after stop(true) `this` is element" ); + }).stop( true, true ); + foo.animate({ + height: 100 + }, 10, function() { + equal( foo[ 0 ], this, "Complete callback `this` is element" ); + start(); + }); +}); |