@@ -2495,4 +2495,89 @@ QUnit.test( "Show/hide/toggle and display: inline", function( assert ) {
24952495 } ) ;
24962496} ) ;
24972497
2498+ function testEasing ( assert , speed , easing , complete ) {
2499+ assert . expect ( 4 ) ;
2500+ var options = jQuery . speed ( speed , easing , complete ) ;
2501+
2502+ assert . equal ( options . duration , 10 , "Duration set properly" ) ;
2503+ assert . equal (
2504+ jQuery . isFunction ( options . easing ) ? options . easing ( ) : options . easing ,
2505+ "linear" ,
2506+ "Easing set properly"
2507+ ) ;
2508+ assert . equal ( options . queue , "fx" , "Queue defaults to fx" ) ;
2509+ options . complete ( ) ;
2510+ }
2511+
2512+ QUnit . test ( "jQuery.speed( speed, easing, complete )" , function ( assert ) {
2513+ testEasing ( assert , 10 , "linear" , function ( ) {
2514+ assert . ok ( true , "Complete called" ) ;
2515+ } ) ;
2516+ } ) ;
2517+
2518+ QUnit . test ( "jQuery.speed( speed, easing, complete ) - with easing function" , function ( assert ) {
2519+ testEasing (
2520+ assert ,
2521+ 10 ,
2522+ function ( ) {
2523+ return "linear" ;
2524+ } ,
2525+ function ( ) {
2526+ assert . ok ( true , "Complete called" ) ;
2527+ }
2528+ ) ;
2529+ } ) ;
2530+
2531+ QUnit . test ( "jQuery.speed( options )" , function ( assert ) {
2532+ testEasing ( assert , {
2533+ duration : 10 ,
2534+ easing : "linear" ,
2535+ complete : function ( ) {
2536+ assert . ok ( true , "Complete called" ) ;
2537+ }
2538+ } ) ;
2539+ } ) ;
2540+
2541+ QUnit . test ( "jQuery.speed( options ) - with easing function" , function ( assert ) {
2542+ testEasing ( assert , {
2543+ duration : 10 ,
2544+ easing : function ( ) {
2545+ return "linear" ;
2546+ } ,
2547+ complete : function ( ) {
2548+ assert . ok ( true , "Complete called" ) ;
2549+ }
2550+ } ) ;
2551+ } ) ;
2552+
2553+ QUnit . test ( "jQuery.speed( options ) - queue values" , function ( assert ) {
2554+ assert . expect ( 5 ) ;
2555+
2556+ var get = function ( queue ) {
2557+ return jQuery . speed ( { queue : queue } ) . queue ;
2558+ } ;
2559+
2560+ assert . equal ( get ( null ) , "fx" , "null defaults to 'fx'" ) ;
2561+ assert . equal ( get ( undefined ) , "fx" , "undefined defaults to 'fx'" ) ;
2562+ assert . equal ( get ( true ) , "fx" , "true defaults to 'fx'" ) ;
2563+ assert . equal ( get ( "fx" ) , "fx" , "'fx' passed through" ) ;
2564+ assert . equal ( get ( "custom" ) , "custom" , "'custom' passed through" ) ;
2565+ } ) ;
2566+
2567+ QUnit . test ( "jQuery.speed() - durations" , function ( assert ) {
2568+ assert . expect ( 5 ) ;
2569+
2570+ var get = function ( duration ) {
2571+ return jQuery . speed ( duration ) . duration ;
2572+ } ;
2573+
2574+ assert . equal ( get ( 100 ) , 100 , "jQuery.speed sets number duration" ) ;
2575+ assert . equal ( get ( ) , jQuery . fx . speeds . _default , "jQuery.speed falls back default duration" ) ;
2576+ assert . equal ( get ( "slow" ) , jQuery . fx . speeds . slow , "jQuery.speed uses preset speeds" ) ;
2577+ assert . equal ( get ( "fast" ) , jQuery . fx . speeds . fast , "jQuery.speed uses preset speeds" ) ;
2578+ jQuery . fx . off = true ;
2579+ assert . equal ( get ( 100 ) , 0 , "jQuery.speed defaults duration to zero if fx is off" ) ;
2580+ jQuery . fx . off = false ;
2581+ } ) ;
2582+
24982583} ) ( ) ;
0 commit comments