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