From: Timo Tijhof Date: Thu, 6 Mar 2014 02:35:18 +0000 (+0100) Subject: jquery.color.test: Use fake timers X-Git-Tag: 1.31.0-rc.0~16440^2~1 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=53448477538fe9c1ed8d83aa8094101a5db8e9f9;p=lhc%2Fweb%2Fwiklou.git jquery.color.test: Use fake timers Also simplified test by asserting the rgb array directly instead of each of index separately. Change-Id: I1ffdd6d5dad3feeb2c6e3dedbb9fc6dbabe8e7c5 --- diff --git a/tests/qunit/suites/resources/jquery/jquery.color.test.js b/tests/qunit/suites/resources/jquery/jquery.color.test.js index 839c5d5072..c8e8ac70e0 100644 --- a/tests/qunit/suites/resources/jquery/jquery.color.test.js +++ b/tests/qunit/suites/resources/jquery/jquery.color.test.js @@ -1,15 +1,18 @@ ( function ( $ ) { - QUnit.module( 'jquery.color', QUnit.newMwEnvironment() ); + QUnit.module( 'jquery.color', QUnit.newMwEnvironment( { + setup: function () { + this.clock = this.sandbox.useFakeTimers(); + } + } ) ); - QUnit.asyncTest( 'animate', 3, function ( assert ) { + QUnit.test( 'animate', 1, function ( assert ) { var $canvas = $( '
' ).css( 'background-color', '#fff' ); - $canvas.animate( { backgroundColor: '#000' }, 4 ).promise().then( function () { + $canvas.animate( { backgroundColor: '#000' }, 10 ).promise().then( function () { var endColors = $.colorUtil.getRGB( $canvas.css( 'background-color' ) ); - assert.strictEqual( endColors[0], 0 ); - assert.strictEqual( endColors[1], 0 ); - assert.strictEqual( endColors[2], 0 ); - QUnit.start(); + assert.deepEqual( endColors, [0, 0, 0], 'end state' ); } ); + + this.clock.tick( 20 ); } ); }( jQuery ) );