@@ -603,28 +603,37 @@ test("stop()", function() {
603
603
} ) ;
604
604
605
605
test ( "stop() - several in queue" , function ( ) {
606
- expect ( 3 ) ;
607
- stop ( ) ;
606
+ expect ( 5 ) ;
608
607
609
- var $foo = jQuery ( "#foo" ) ;
610
- var w = 0 ;
611
- $foo . hide ( 1000 ) . css ( "width" , 200 ) . css ( "width" ) ;
608
+ var nw , time ,
609
+ $foo = jQuery ( "#foo" ) ,
610
+ w = 0 ;
612
611
613
- $foo . animate ( { "width" : "show" } , 1500 ) ;
614
- $foo . animate ( { "width" : "hide" } , 1000 ) ;
615
- $foo . animate ( { "width" : "show" } , 1000 ) ;
616
- setTimeout ( function ( ) {
617
- equal ( $foo . queue ( ) . length , 3 , "All 3 still in the queue" ) ;
618
- var nw = $foo . css ( "width" ) ;
619
- notEqual ( parseFloat ( nw ) , w , "An animation occurred " + nw + " " + w + "px" ) ;
620
- $foo . stop ( ) ;
612
+ // default duration is 400ms, so 800px ensures we aren't 0 or 1 after 1ms
613
+ $foo . hide ( ) . css ( "width" , 800 ) ;
621
614
622
- nw = $foo . css ( "width" ) ;
623
- notEqual ( parseFloat ( nw ) , w , "Stop didn't reset the animation " + nw + " " + w + "px" ) ;
615
+ $foo . animate ( { "width" : "show" } , 400 , "linear" ) ;
616
+ $foo . animate ( { "width" : "hide" } ) ;
617
+ $foo . animate ( { "width" : "show" } ) ;
624
618
625
- $foo . stop ( true ) ;
626
- start ( ) ;
627
- } , 200 ) ;
619
+ // could be replaced by something nicer using sinon.
620
+ time = jQuery . now ( ) ;
621
+ while ( time === jQuery . now ( ) ) { }
622
+
623
+ jQuery . fx . tick ( ) ;
624
+ equal ( $foo . queue ( ) . length , 3 , "3 in the queue" ) ;
625
+
626
+ nw = $foo . css ( "width" ) ;
627
+ notEqual ( parseFloat ( nw ) , 1 , "An animation occurred " + nw ) ;
628
+ $foo . stop ( ) ;
629
+
630
+ equal ( $foo . queue ( ) . length , 2 , "2 in the queue" ) ;
631
+ nw = $foo . css ( "width" ) ;
632
+ notEqual ( parseFloat ( nw ) , 1 , "Stop didn't reset the animation " + nw ) ;
633
+
634
+ $foo . stop ( true ) ;
635
+
636
+ equal ( $foo . queue ( ) . length , 0 , "0 in the queue" ) ;
628
637
} ) ;
629
638
630
639
test ( "stop(clearQueue)" , function ( ) {
0 commit comments