]> source.dussan.org Git - jquery-ui.git/commitdiff
Added some better queue order testing
authorgnarf <gnarf@gnarf.net>
Wed, 4 May 2011 06:54:47 +0000 (01:54 -0500)
committergnarf <gnarf@gnarf.net>
Wed, 4 May 2011 06:54:47 +0000 (01:54 -0500)
tests/unit/effects/effects_core.js

index 3da0b6f470f6d5a6192e42f6eab14cd0176c6a50..0359b73d3142b74ec6ef4902ee25a69fd3e08fbd 100644 (file)
@@ -12,16 +12,34 @@ $.each( $.effects.effect, function( effect ) {
        module( "effect."+effect );
        test( "show/hide", function() {
                var hidden = $( "div.hidden" );
-               expect( 3 );
+               expect( 8 );
                stop();
-               hidden.show( effect, animateTime, function() {
+
+               var count = 0,
+                       test = 0;
+
+               function queueTest( fn ) {
+                       count++;
+                       var point = count;
+                       return function( next ) {
+                               test++;
+                               equals( point, test, "Queue function fired in order" );
+                               if ( fn ) {
+                                       fn ()
+                               } else {
+                                       setTimeout( next, animateTime );
+                               }
+                       }
+               }
+               
+               hidden.queue( queueTest() ).show( effect, animateTime, queueTest(function() {
                        equal( hidden.css("display"), "block", "Hidden is shown after .show(\"" +effect+ "\", time)" );
-               }).hide( effect, animateTime, function() {
+               })).queue( queueTest() ).hide( effect, animateTime, queueTest(function() {
                        equal( hidden.css("display"), "none", "Back to hidden after .hide(\"" +effect+ "\", time)" );
-               }).queue( function(next) {
+               })).queue( queueTest(function(next) {
                        deepEqual( hidden.queue(), ["inprogress"], "Only the inprogress sentinel remains")
                        start();
-               });
+               }));
        });
 });