Krinkle has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/322818

Change subject: jquery.color: Update test to not assume animiations use 
setTimeout
......................................................................

jquery.color: Update test to not assume animiations use setTimeout

As of jQuery 1.12, animiations use requestAnimationFrame in modern
browsers, which cannot be forced to finish synchronously by merely
mocking the 'setTimeout' and 'Date' clocks via Sinon.

Make the test asynchronous instead, and reduce duration from 10ms to 3ms.

Change-Id: Ie147fc2a91d2cd349b4031390f3c59b1bcfb65b5
---
M tests/qunit/suites/resources/jquery/jquery.color.test.js
1 file changed, 10 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/18/322818/1

diff --git a/tests/qunit/suites/resources/jquery/jquery.color.test.js 
b/tests/qunit/suites/resources/jquery/jquery.color.test.js
index 9afd793..ca6a512 100644
--- a/tests/qunit/suites/resources/jquery/jquery.color.test.js
+++ b/tests/qunit/suites/resources/jquery/jquery.color.test.js
@@ -1,18 +1,15 @@
 ( function ( $ ) {
-       QUnit.module( 'jquery.color', QUnit.newMwEnvironment( {
-               setup: function () {
-                       this.clock = this.sandbox.useFakeTimers();
-               }
-       } ) );
+       QUnit.module( 'jquery.color', QUnit.newMwEnvironment() );
 
-       QUnit.test( 'animate', 1, function ( assert ) {
-               var $canvas = $( '<div>' ).css( 'background-color', '#fff' );
+       QUnit.test( 'animate', function ( assert ) {
+               var done = assert.async(),
+                       $canvas = $( '<div>' ).css( 'background-color', '#fff' 
).appendTo( '#qunit-fixture' );
 
-               $canvas.animate( { backgroundColor: '#000' }, 10 
).promise().then( function () {
-                       var endColors = $.colorUtil.getRGB( $canvas.css( 
'background-color' ) );
-                       assert.deepEqual( endColors, [ 0, 0, 0 ], 'end state' );
-               } );
-
-               this.clock.tick( 20 );
+               $canvas.animate( { 'background-color': '#000' }, 3 ).promise()
+                       .done( function () {
+                               var endColors = $.colorUtil.getRGB( 
$canvas.css( 'background-color' ) );
+                               assert.deepEqual( endColors, [ 0, 0, 0 ], 'end 
state' );
+                       } )
+                       .always( done );
        } );
 }( jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/322818
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie147fc2a91d2cd349b4031390f3c59b1bcfb65b5
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Krinkle <krinklem...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to