From fe6afa8268e01f36bb0d1b88c13d704560039c3f Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Wed, 8 Jul 2015 13:31:09 -0400 Subject: [PATCH] Effects: fix failing tests in IE8 --- test/unit/animation.js | 5 +++-- test/unit/tween.js | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test/unit/animation.js b/test/unit/animation.js index 6bb070145..3aae7eab1 100644 --- a/test/unit/animation.js +++ b/test/unit/animation.js @@ -17,15 +17,16 @@ module( "animation", { this.sandbox = sinon.sandbox.create(); this.clock = this.sandbox.useFakeTimers( startTime ); this._oldInterval = jQuery.fx.interval; + this._oldNow = jQuery.now; jQuery.fx.step = {}; jQuery.fx.interval = 10; - jQuery.now = Date.now; + jQuery.now = Date.now || this._oldNow; jQuery.Animation.prefilters = [ defaultPrefilter ]; jQuery.Animation.tweeners = { "*": [ defaultTweener ] }; }, teardown: function() { this.sandbox.restore(); - jQuery.now = Date.now; + jQuery.now = this._oldNow; jQuery.fx.stop(); jQuery.fx.interval = this._oldInterval; window.requestAnimationFrame = oldRaf; diff --git a/test/unit/tween.js b/test/unit/tween.js index 39894c575..7d806fe6b 100644 --- a/test/unit/tween.js +++ b/test/unit/tween.js @@ -13,13 +13,14 @@ module( "tween", { this.sandbox = sinon.sandbox.create(); this.clock = this.sandbox.useFakeTimers( 505877050 ); this._oldInterval = jQuery.fx.interval; + this._oldNow = jQuery.now; jQuery.fx.step = {}; jQuery.fx.interval = 10; - jQuery.now = Date.now; + jQuery.now = Date.now || this._oldNow; }, teardown: function() { this.sandbox.restore(); - jQuery.now = Date.now; + jQuery.now = this._oldNow; jQuery.fx.stop(); jQuery.fx.interval = this._oldInterval; window.requestAnimationFrame = oldRaf; @@ -198,7 +199,7 @@ test( "jQuery.Tween - Element", function() { ok( easingSpy.calledWith( 0.1, 0.1 * testOptions.duration, 0, 1, testOptions.duration ), "...using jQuery.easing.linear with back-compat arguments" ); - equal( parseFloat( testElement.style.height ).toFixed( 2 ), eased.toFixed( 2 ), "Set value" ); + equal( Math.floor( parseFloat( testElement.style.height ) ), Math.floor( eased ), "Set value" ); tween.run( 1 ); equal( testElement.style.height, "0px", "Checking another value" ); -- 2.39.5