For .show() with no arguments, only set display of elements in the second loop if...
[jquery.git] / test / unit / effects.js
1 module("effects");
2
3 test("sanity check", function() {
4         expect(1);
5         ok( jQuery("#dl:visible, #main:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects" );
6 });
7
8 test("show()", function() {
9         expect(26);
10
11         var hiddendiv = jQuery("div.hidden");
12
13         equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none");
14
15         hiddendiv.css("display", "block");
16         equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
17
18         hiddendiv.show();
19         equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
20
21         hiddendiv.css("display","");
22
23         var pass = true, div = jQuery("#main div");
24         div.show().each(function(){
25                 if ( this.style.display == "none" ) pass = false;
26         });
27         ok( pass, "Show" );
28
29         var speeds = {
30           "null speed": null,
31           "undefined speed": undefined,
32           "empty string speed": "",
33           "false speed": false
34         };
35
36         jQuery.each(speeds, function(name, speed) {
37     pass = true;
38         div.hide().show(speed).each(function() {
39                 if ( this.style.display == "none" ) pass = false;
40         });
41         ok( pass, "Show with " + name);
42   });
43
44
45         jQuery.each(speeds, function(name, speed) {
46     pass = true;
47         div.hide().show(speed, function() {
48                         pass = false;
49                 });
50                 ok( pass, "Show with " + name + " does not call animate callback" );
51         });
52
53         // #show-tests * is set display: none in CSS
54         jQuery("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id="test-table"></table>');
55         
56         var old = jQuery("#test-table").show().css("display") !== "table";
57         jQuery("#test-table").remove();
58
59         var test = {
60                 "div"      : "block",
61                 "p"        : "block",
62                 "a"        : "inline",
63                 "code"     : "inline",
64                 "pre"      : "block",
65                 "span"     : "inline",
66                 "table"    : old ? "block" : "table",
67                 "thead"    : old ? "block" : "table-header-group",
68                 "tbody"    : old ? "block" : "table-row-group",
69                 "tr"       : old ? "block" : "table-row",
70                 "th"       : old ? "block" : "table-cell",
71                 "td"       : old ? "block" : "table-cell",
72                 "ul"       : "block",
73                 "li"       : old ? "block" : "list-item"
74         };
75
76         jQuery.each(test, function(selector, expected) {
77                 var elem = jQuery(selector, "#show-tests").show();
78                 equals( elem.css("display"), expected, "Show using correct display type for " + selector );
79         });
80 });
81
82 test("show(Number) - other displays", function() {
83         expect(15);
84         QUnit.reset();
85         stop();
86
87         // #show-tests * is set display: none in CSS
88         jQuery("#main").append('<div id="show-tests"><div><p><a href="#"></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id="test-table"></table>');
89
90         var old = jQuery("#test-table").show().css("display") !== "table",
91                 num = 0;
92         jQuery("#test-table").remove();
93
94         var test = {
95                 "div"      : "block",
96                 "p"        : "block",
97                 "a"        : "inline",
98                 "code"     : "inline",
99                 "pre"      : "block",
100                 "span"     : "inline",
101                 "table"    : old ? "block" : "table",
102                 "thead"    : old ? "block" : "table-header-group",
103                 "tbody"    : old ? "block" : "table-row-group",
104                 "tr"       : old ? "block" : "table-row",
105                 "th"       : old ? "block" : "table-cell",
106                 "td"       : old ? "block" : "table-cell",
107                 "ul"       : "block",
108                 "li"       : old ? "block" : "list-item"
109         };
110
111         jQuery.each(test, function(selector, expected) {
112                 var elem = jQuery(selector, "#show-tests").show(1, function() {
113                         equals( elem.css("display"), expected, "Show using correct display type for " + selector );
114                         if ( ++num === 15 ) {
115                                 start();
116                         }
117                 });
118         });
119 });
120
121 test("animate(Hash, Object, Function)", function() {
122         expect(1);
123         stop();
124         var hash = {opacity: 'show'};
125         var hashCopy = jQuery.extend({}, hash);
126         jQuery('#foo').animate(hash, 0, function() {
127                 equals( hash.opacity, hashCopy.opacity, 'Check if animate changed the hash parameter' );
128                 start();
129         });
130 });
131
132 test("animate negative height", function() {
133         expect(1);
134         stop();
135         jQuery("#foo").animate({ height: -100 }, 100, function() {
136                 equals( this.offsetHeight, 0, "Verify height." );
137                 start();
138         });
139 });
140
141 test("animate block as inline width/height", function() {
142         expect(3);
143
144         var span = jQuery("<span>").css("display", "inline-block").appendTo("body"),
145                 expected = span.css("display");
146         
147         span.remove();
148
149         if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) {
150                 stop();
151
152                 jQuery("#foo").css({ display: "inline", width: '', height: '' }).animate({ width: 42, height: 42 }, 100, function() {
153                         equals( jQuery(this).css("display"), jQuery.support.inlineBlockNeedsLayout ? "inline" : "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
154                         equals( this.offsetWidth, 42, "width was animated" );
155                         equals( this.offsetHeight, 42, "height was animated" );
156                         start();
157                 });
158
159         // Browser doesn't support inline-block
160         } else {
161                 ok( true, "Browser doesn't support inline-block" );
162                 ok( true, "Browser doesn't support inline-block" );
163                 ok( true, "Browser doesn't support inline-block" );
164         }
165 });
166
167 test("animate native inline width/height", function() {
168         expect(3);
169
170         var span = jQuery("<span>").css("display", "inline-block").appendTo("body"),
171                 expected = span.css("display");
172         
173         span.remove();
174
175         if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) {
176                 stop();
177                 jQuery("#foo").css({ display: "", width: '', height: '' })
178                         .append('<span>text</span>')
179                         .children('span')
180                                 .animate({ width: 42, height: 42 }, 100, function() {
181                                         equals( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
182                                         equals( this.offsetWidth, 42, "width was animated" );
183                                         equals( this.offsetHeight, 42, "height was animated" );
184                                         start();
185                                 });
186
187         // Browser doesn't support inline-block
188         } else {
189                 ok( true, "Browser doesn't support inline-block" );
190                 ok( true, "Browser doesn't support inline-block" );
191                 ok( true, "Browser doesn't support inline-block" );
192         }
193 });
194
195 test("animate block width/height", function() {
196         expect(3);
197         stop();
198         jQuery("#foo").css({ display: "block", width: 20, height: 20 }).animate({ width: 42, height: 42 }, 100, function() {
199                 equals( jQuery(this).css("display"), "block", "inline-block was not set on block element when animating width/height" );
200                 equals( this.offsetWidth, 42, "width was animated" );
201                 equals( this.offsetHeight, 42, "height was animated" );
202                 start();
203         });
204 });
205
206 test("animate table width/height", function() {
207         expect(1);
208         stop();
209
210         var displayMode = jQuery("#table").css("display") !== "table" ? "block" : "table";
211
212         jQuery("#table").animate({ width: 42, height: 42 }, 100, function() {
213                 equals( jQuery(this).css("display"), displayMode, "display mode is correct" );
214                 start();
215         });
216 });
217
218 test("animate table-row width/height", function() {
219         expect(3);
220         stop();
221         var tr = jQuery("#table")
222                 .attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 })
223                 .html("<tr style='height:42px;'><td style='padding:0;'><div style='width:20px;height:20px;'></div></td></tr>")
224                 .find("tr");
225
226         // IE<8 uses “block” instead of the correct display type
227         var displayMode = tr.css("display") !== "table-row" ? "block" : "table-row";
228
229         tr.animate({ width: 10, height: 10 }, 100, function() {
230                 equals( jQuery(this).css("display"), displayMode, "display mode is correct" );
231                 equals( this.offsetWidth, 20, "width animated to shrink wrap point" );
232                 equals( this.offsetHeight, 20, "height animated to shrink wrap point" );
233                 start();
234         });
235 });
236
237 test("animate table-cell width/height", function() {
238         expect(3);
239         stop();
240         var td = jQuery("#table")
241                 .attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 })
242                 .html("<tr><td style='width:42px;height:42px;padding:0;'><div style='width:20px;height:20px;'></div></td></tr>")
243                 .find("td");
244
245         // IE<8 uses “block” instead of the correct display type
246         var displayMode = td.css("display") !== "table-cell" ? "block" : "table-cell";
247
248         td.animate({ width: 10, height: 10 }, 100, function() {
249                 equals( jQuery(this).css("display"), displayMode, "display mode is correct" );
250                 equals( this.offsetWidth, 20, "width animated to shrink wrap point" );
251                 equals( this.offsetHeight, 20, "height animated to shrink wrap point" );
252                 start();
253         });
254 });
255
256 test("animate resets overflow-x and overflow-y when finished", function() {
257         expect(2);
258         stop();
259         jQuery("#foo")
260                 .css({ display: "block", width: 20, height: 20, overflowX: "visible", overflowY: "auto" })
261                 .animate({ width: 42, height: 42 }, 100, function() {
262                         equals( this.style.overflowX, "visible", "overflow-x is visible" );
263                         equals( this.style.overflowY, "auto", "overflow-y is auto" );
264                         start();
265                 });
266 });
267
268 /* // This test ends up being flaky depending upon the CPU load
269 test("animate option (queue === false)", function () {
270         expect(1);
271         stop();
272
273         var order = [];
274
275         var $foo = jQuery("#foo");
276         $foo.animate({width:'100px'}, 3000, function () {
277                 // should finish after unqueued animation so second
278                 order.push(2);
279                 same( order, [ 1, 2 ], "Animations finished in the correct order" );
280                 start();
281         });
282         $foo.animate({fontSize:'2em'}, {queue:false, duration:10, complete:function () {
283                 // short duration and out of queue so should finish first
284                 order.push(1);
285         }});
286 });
287 */
288
289 test("animate with no properties", function() {
290         expect(2);
291
292         var divs = jQuery("div"), count = 0;
293
294         divs.animate({}, function(){
295                 count++;
296         });
297
298         equals( divs.length, count, "Make sure that callback is called for each element in the set." );
299
300         stop();
301
302         var foo = jQuery("#foo");
303
304         foo.animate({});
305         foo.animate({top: 10}, 100, function(){
306                 ok( true, "Animation was properly dequeued." );
307                 start();
308         });
309 });
310
311 test("animate duration 0", function() {
312         expect(11);
313
314         stop();
315
316         var $elems = jQuery([{ a:0 },{ a:0 }]), counter = 0;
317
318         equals( jQuery.timers.length, 0, "Make sure no animation was running from another test" );
319
320         $elems.eq(0).animate( {a:1}, 0, function(){
321                 ok( true, "Animate a simple property." );
322                 counter++;
323         });
324
325         // Failed until [6115]
326         equals( jQuery.timers.length, 0, "Make sure synchronic animations are not left on jQuery.timers" );
327
328         equals( counter, 1, "One synchronic animations" );
329
330         $elems.animate( { a:2 }, 0, function(){
331                 ok( true, "Animate a second simple property." );
332                 counter++;
333         });
334
335         equals( counter, 3, "Multiple synchronic animations" );
336
337         $elems.eq(0).animate( {a:3}, 0, function(){
338                 ok( true, "Animate a third simple property." );
339                 counter++;
340         });
341         $elems.eq(1).animate( {a:3}, 200, function(){
342                 counter++;
343                 // Failed until [6115]
344                 equals( counter, 5, "One synchronic and one asynchronic" );
345                 start();
346         });
347
348         var $elem = jQuery("<div />");
349         $elem.show(0, function(){
350                 ok(true, "Show callback with no duration");
351         });
352         $elem.hide(0, function(){
353                 ok(true, "Hide callback with no duration");
354         });
355 });
356
357 test("animate hyphenated properties", function(){
358         expect(1);
359         stop();
360
361         jQuery("#nothiddendiv")
362                 .css("font-size", 10)
363                 .animate({"font-size": 20}, 200, function(){
364                         equals( this.style.fontSize, "20px", "The font-size property was animated." );
365                         start();
366                 });
367 });
368
369 test("animate non-element", function(){
370         expect(1);
371         stop();
372
373         var obj = { test: 0 };
374
375         jQuery(obj).animate({test: 200}, 200, function(){
376                 equals( obj.test, 200, "The custom property should be modified." );
377                 start();
378         });
379 });
380
381 test("stop()", function() {
382         expect(3);
383         stop();
384
385         var $foo = jQuery("#nothiddendiv");
386         var w = 0;
387         $foo.hide().width(200).width();
388
389         $foo.animate({ width:'show' }, 1000);
390         setTimeout(function(){
391                 var nw = $foo.width();
392                 notEqual( nw, w, "An animation occurred " + nw + "px " + w + "px");
393                 $foo.stop();
394
395                 nw = $foo.width();
396                 notEqual( nw, w, "Stop didn't reset the animation " + nw + "px " + w + "px");
397                 setTimeout(function(){
398                         equals( nw, $foo.width(), "The animation didn't continue" );
399                         start();
400                 }, 100);
401         }, 100);
402 });
403
404 test("stop() - several in queue", function() {
405         expect(3);
406         stop();
407
408         var $foo = jQuery("#nothiddendivchild");
409         var w = 0;
410         $foo.hide().width(200).width();
411
412         $foo.animate({ width:'show' }, 1000);
413         $foo.animate({ width:'hide' }, 1000);
414         $foo.animate({ width:'show' }, 1000);
415         setTimeout(function(){
416                 equals( $foo.queue().length, 3, "All 3 still in the queue" );
417                 var nw = $foo.width();
418                 notEqual( nw, w, "An animation occurred " + nw + "px " + w + "px");
419                 $foo.stop();
420
421                 nw = $foo.width();
422                 notEqual( nw, w, "Stop didn't reset the animation " + nw + "px " + w + "px");
423
424                 $foo.stop(true);
425                 start();
426         }, 100);
427 });
428
429 test("stop(clearQueue)", function() {
430         expect(4);
431         stop();
432
433         var $foo = jQuery("#nothiddendiv");
434         var w = 0;
435         $foo.hide().width(200).width();
436
437         $foo.animate({ width:'show' }, 1000);
438         $foo.animate({ width:'hide' }, 1000);
439         $foo.animate({ width:'show' }, 1000);
440         setTimeout(function(){
441                 var nw = $foo.width();
442                 ok( nw != w, "An animation occurred " + nw + "px " + w + "px");
443                 $foo.stop(true);
444
445                 nw = $foo.width();
446                 ok( nw != w, "Stop didn't reset the animation " + nw + "px " + w + "px");
447
448                 equals( $foo.queue().length, 0, "The animation queue was cleared" );
449                 setTimeout(function(){
450                         equals( nw, $foo.width(), "The animation didn't continue" );
451                         start();
452                 }, 100);
453         }, 100);
454 });
455
456 test("stop(clearQueue, gotoEnd)", function() {
457         expect(1);
458         stop();
459
460         var $foo = jQuery("#nothiddendivchild");
461         var w = 0;
462         $foo.hide().width(200).width();
463
464         $foo.animate({ width:'show' }, 1000);
465         $foo.animate({ width:'hide' }, 1000);
466         $foo.animate({ width:'show' }, 1000);
467         $foo.animate({ width:'hide' }, 1000);
468         setTimeout(function(){
469                 var nw = $foo.width();
470                 ok( nw != w, "An animation occurred " + nw + "px " + w + "px");
471                 $foo.stop(false, true);
472
473                 nw = $foo.width();
474                 // Disabled, being flaky
475                 //equals( nw, 1, "Stop() reset the animation" );
476
477                 setTimeout(function(){
478                         // Disabled, being flaky
479                         //equals( $foo.queue().length, 2, "The next animation continued" );
480                         $foo.stop(true);
481                         start();
482                 }, 100);
483         }, 100);
484 });
485
486 test("toggle()", function() {
487         expect(6);
488         var x = jQuery("#nothiddendiv");
489         ok( x.is(":visible"), "is visible" );
490         x.toggle();
491         ok( x.is(":hidden"), "is hidden" );
492         x.toggle();
493         ok( x.is(":visible"), "is visible again" );
494
495         x.toggle(true);
496         ok( x.is(":visible"), "is visible" );
497         x.toggle(false);
498         ok( x.is(":hidden"), "is hidden" );
499         x.toggle(true);
500         ok( x.is(":visible"), "is visible again" );
501 });
502
503 jQuery.checkOverflowDisplay = function(){
504         var o = jQuery.css( this, "overflow" );
505
506         equals(o, "visible", "Overflow should be visible: " + o);
507         equals(jQuery.css( this, "display" ), "inline", "Display shouldn't be tampered with.");
508
509         start();
510 }
511
512 test("JS Overflow and Display", function() {
513         expect(2);
514         stop();
515         jQuery.makeTest( "JS Overflow and Display" )
516                 .addClass("widewidth")
517                 .css({ overflow: "visible", display: "inline" })
518                 .addClass("widewidth")
519                 .text("Some sample text.")
520                 .before("text before")
521                 .after("text after")
522                 .animate({ opacity: 0.5 }, "slow", jQuery.checkOverflowDisplay);
523 });
524
525 test("CSS Overflow and Display", function() {
526         expect(2);
527         stop();
528         jQuery.makeTest( "CSS Overflow and Display" )
529                 .addClass("overflow inline")
530                 .addClass("widewidth")
531                 .text("Some sample text.")
532                 .before("text before")
533                 .after("text after")
534                 .animate({ opacity: 0.5 }, "slow", jQuery.checkOverflowDisplay);
535 });
536
537 jQuery.each( {
538         "CSS Auto": function(elem,prop){
539                 jQuery(elem).addClass("auto" + prop)
540                         .text("This is a long string of text.");
541                 return "";
542         },
543         "JS Auto": function(elem,prop){
544                 jQuery(elem).css(prop,"")
545                         .text("This is a long string of text.");
546                 return "";
547         },
548         "CSS 100": function(elem,prop){
549                 jQuery(elem).addClass("large" + prop);
550                 return "";
551         },
552         "JS 100": function(elem,prop){
553                 jQuery(elem).css(prop,prop == "opacity" ? 1 : "100px");
554                 return prop == "opacity" ? 1 : 100;
555         },
556         "CSS 50": function(elem,prop){
557                 jQuery(elem).addClass("med" + prop);
558                 return "";
559         },
560         "JS 50": function(elem,prop){
561                 jQuery(elem).css(prop,prop == "opacity" ? 0.50 : "50px");
562                 return prop == "opacity" ? 0.5 : 50;
563         },
564         "CSS 0": function(elem,prop){
565                 jQuery(elem).addClass("no" + prop);
566                 return "";
567         },
568         "JS 0": function(elem,prop){
569                 jQuery(elem).css(prop,prop == "opacity" ? 0 : "0px");
570                 return 0;
571         }
572 }, function(fn, f){
573         jQuery.each( {
574                 "show": function(elem,prop){
575                         jQuery(elem).hide().addClass("wide"+prop);
576                         return "show";
577                 },
578                 "hide": function(elem,prop){
579                         jQuery(elem).addClass("wide"+prop);
580                         return "hide";
581                 },
582                 "100": function(elem,prop){
583                         jQuery(elem).addClass("wide"+prop);
584                         return prop == "opacity" ? 1 : 100;
585                 },
586                 "50": function(elem,prop){
587                         return prop == "opacity" ? 0.50 : 50;
588                 },
589                 "0": function(elem,prop){
590                         jQuery(elem).addClass("noback");
591                         return 0;
592                 }
593         }, function(tn, t){
594                 test(fn + " to " + tn, function() {
595                         var elem = jQuery.makeTest( fn + " to " + tn );
596
597                         var t_w = t( elem, "width" );
598                         var f_w = f( elem, "width" );
599                         var t_h = t( elem, "height" );
600                         var f_h = f( elem, "height" );
601                         var t_o = t( elem, "opacity" );
602                         var f_o = f( elem, "opacity" );
603
604                         var num = 0;
605
606                         if ( t_h == "show" ) num++;
607                         if ( t_w == "show" ) num++;
608                         if ( t_w == "hide"||t_w == "show" ) num++;
609                         if ( t_h == "hide"||t_h == "show" ) num++;
610                         if ( t_o == "hide"||t_o == "show" ) num++;
611                         if ( t_w == "hide" ) num++;
612                         if ( t_o.constructor == Number ) num += 2;
613                         if ( t_w.constructor == Number ) num += 2;
614                         if ( t_h.constructor == Number ) num +=2;
615
616                         expect(num);
617                         stop();
618
619                         var anim = { width: t_w, height: t_h, opacity: t_o };
620
621                         elem.animate(anim, 50, function(){
622                                 if ( t_w == "show" )
623                                         equals( this.style.display, "block", "Showing, display should block: " + this.style.display);
624
625                                 if ( t_w == "hide"||t_w == "show" )
626                                         ok(f_w === "" ? this.style.width === f_w : this.style.width.indexOf(f_w) === 0, "Width must be reset to " + f_w + ": " + this.style.width);
627
628                                 if ( t_h == "hide"||t_h == "show" )
629                                         ok(f_h === "" ? this.style.height === f_h : this.style.height.indexOf(f_h) === 0, "Height must be reset to " + f_h + ": " + this.style.height);
630
631                                 var cur_o = jQuery.style(this, "opacity");
632
633                                 if ( t_o == "hide" || t_o == "show" )
634                                         equals(cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o);
635
636                                 if ( t_w == "hide" )
637                                         equals(this.style.display, "none", "Hiding, display should be none: " + this.style.display);
638
639                                 if ( t_o.constructor == Number ) {
640                                         equals(cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o);
641
642                                         ok(jQuery.css(this, "opacity") != "" || cur_o == t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o);
643                                 }
644
645                                 if ( t_w.constructor == Number ) {
646                                         equals(this.style.width, t_w + "px", "Final width should be " + t_w + ": " + this.style.width);
647
648                                         var cur_w = jQuery.css(this,"width");
649
650                                         ok(this.style.width != "" || cur_w == t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w);
651                                 }
652
653                                 if ( t_h.constructor == Number ) {
654                                         equals(this.style.height, t_h + "px", "Final height should be " + t_h + ": " + this.style.height);
655
656                                         var cur_h = jQuery.css(this,"height");
657
658                                         ok(this.style.height != "" || cur_h == t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_w);
659                                 }
660
661                                 if ( t_h == "show" ) {
662                                         var old_h = jQuery.css(this, "height");
663                                         jQuery(this).append("<br/>Some more text<br/>and some more...");
664
665                                         if ( /Auto/.test( fn ) ) {
666                                                 notEqual(jQuery.css(this, "height"), old_h, "Make sure height is auto.");
667                                         } else {
668                                                 equals(jQuery.css(this, "height"), old_h, "Make sure height is not auto.");
669                                         }
670                                 }
671
672                                 start();
673                         });
674                 });
675         });
676 });
677
678 jQuery.fn.saveState = function(hiddenOverflow){
679         var check = ['opacity','height','width','display','overflow'];
680         expect(check.length);
681
682         stop();
683         return this.each(function(){
684                 var self = this;
685                 self.save = {};
686                 jQuery.each(check, function(i,c){
687                         self.save[c] = c === "overflow" && hiddenOverflow ? "hidden" : self.style[ c ] || jQuery.css(self,c);
688                 });
689         });
690 };
691
692 jQuery.checkState = function(){
693         var self = this;
694         jQuery.each(this.save, function(c,v){
695                 var cur = self.style[ c ] || jQuery.css(self, c);
696                 equals( cur, v, "Make sure that " + c + " is reset (Old: " + v + " Cur: " + cur + ")");
697         });
698         start();
699 }
700
701 // Chaining Tests
702 test("Chain fadeOut fadeIn", function() {
703         jQuery('#fadein div').saveState().fadeOut('fast').fadeIn('fast',jQuery.checkState);
704 });
705 test("Chain fadeIn fadeOut", function() {
706         jQuery('#fadeout div').saveState().fadeIn('fast').fadeOut('fast',jQuery.checkState);
707 });
708
709 test("Chain hide show", function() {
710         jQuery('#show div').saveState(jQuery.support.shrinkWrapBlocks).hide('fast').show('fast',jQuery.checkState);
711 });
712 test("Chain show hide", function() {
713         jQuery('#hide div').saveState(jQuery.support.shrinkWrapBlocks).show('fast').hide('fast',jQuery.checkState);
714 });
715 test("Chain show hide with easing and callback", function() {
716         jQuery('#hide div').saveState().show('fast').hide('fast','linear',jQuery.checkState);
717 });
718
719 test("Chain toggle in", function() {
720         jQuery('#togglein div').saveState(jQuery.support.shrinkWrapBlocks).toggle('fast').toggle('fast',jQuery.checkState);
721 });
722 test("Chain toggle out", function() {
723         jQuery('#toggleout div').saveState(jQuery.support.shrinkWrapBlocks).toggle('fast').toggle('fast',jQuery.checkState);
724 });
725 test("Chain toggle out with easing and callback", function() {
726  jQuery('#toggleout div').saveState(jQuery.support.shrinkWrapBlocks).toggle('fast').toggle('fast','linear',jQuery.checkState);
727 });
728 test("Chain slideDown slideUp", function() {
729         jQuery('#slidedown div').saveState(jQuery.support.shrinkWrapBlocks).slideDown('fast').slideUp('fast',jQuery.checkState);
730 });
731 test("Chain slideUp slideDown", function() {
732         jQuery('#slideup div').saveState(jQuery.support.shrinkWrapBlocks).slideUp('fast').slideDown('fast',jQuery.checkState);
733 });
734 test("Chain slideUp slideDown with easing and callback", function() {
735         jQuery('#slideup div').saveState(jQuery.support.shrinkWrapBlocks).slideUp('fast').slideDown('fast','linear',jQuery.checkState);
736 });
737
738 test("Chain slideToggle in", function() {
739         jQuery('#slidetogglein div').saveState(jQuery.support.shrinkWrapBlocks).slideToggle('fast').slideToggle('fast',jQuery.checkState);
740 });
741 test("Chain slideToggle out", function() {
742         jQuery('#slidetoggleout div').saveState(jQuery.support.shrinkWrapBlocks).slideToggle('fast').slideToggle('fast',jQuery.checkState);
743 });
744
745 test("Chain fadeToggle in", function() {
746         jQuery('#fadetogglein div').saveState().fadeToggle('fast').fadeToggle('fast',jQuery.checkState);
747 });
748 test("Chain fadeToggle out", function() {
749         jQuery('#fadetoggleout div').saveState().fadeToggle('fast').fadeToggle('fast',jQuery.checkState);
750 });
751
752 test("Chain fadeTo 0.5 1.0 with easing and callback)", function() {
753         jQuery('#fadeto div').saveState().fadeTo('fast',0.5).fadeTo('fast',1.0,'linear',jQuery.checkState);
754 });
755
756 jQuery.makeTest = function( text ){
757         var elem = jQuery("<div></div>")
758                 .attr("id", "test" + jQuery.makeTest.id++)
759                 .addClass("box");
760
761         jQuery("<h4></h4>")
762                 .text( text )
763                 .appendTo("#fx-tests")
764                 .click(function(){
765                         jQuery(this).next().toggle();
766                 })
767                 .after( elem );
768
769         return elem;
770 }
771
772 jQuery.makeTest.id = 1;
773
774 test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function () {
775         expect(4);
776   stop();
777
778         var $checkedtest = jQuery("#checkedtest");
779         // IE6 was clearing "checked" in jQuery(elem).show("fast");
780         $checkedtest.hide().show("fast", function() {
781         ok( !! jQuery(":radio:first", $checkedtest).attr("checked"), "Check first radio still checked." );
782         ok( ! jQuery(":radio:last", $checkedtest).attr("checked"), "Check last radio still NOT checked." );
783         ok( !! jQuery(":checkbox:first", $checkedtest).attr("checked"), "Check first checkbox still checked." );
784         ok( ! jQuery(":checkbox:last", $checkedtest).attr("checked"), "Check last checkbox still NOT checked." );
785         start();
786         });
787 });
788
789 test("animate with per-property easing", function(){
790
791         expect(3);
792         stop();
793
794         var _test1_called = false;
795         var _test2_called = false;
796         var _default_test_called = false;
797
798         jQuery.easing['_test1'] = function() {
799                 _test1_called = true;
800         };
801
802         jQuery.easing['_test2'] = function() {
803                 _test2_called = true;
804         };
805
806         jQuery.easing['_default_test'] = function() {
807                 _default_test_called = true;
808         };
809
810         jQuery({a:0,b:0,c:0}).animate({
811                 a: [100, '_test1'],
812                 b: [100, '_test2'],
813                 c: 100
814         }, 400, '_default_test', function(){
815                 start();
816                 ok(_test1_called, "Easing function (1) called");
817                 ok(_test2_called, "Easing function (2) called");
818                 ok(_default_test_called, "Easing function (_default) called");
819         });
820
821 });
822
823 test("hide hidden elements (bug #7141)", function() {
824         expect(3);
825         QUnit.reset();
826
827         var div = jQuery("<div style='display:none'></div>").appendTo("#main");
828         equals( div.css("display"), "none", "Element is hidden by default" );
829         div.hide();
830         ok( !div.data("olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
831         div.show();
832         equals( div.css("display"), "block", "Show a double-hidden element" );
833
834         div.remove();
835 });
836
837 test("hide hidden elements, with animation (bug #7141)", function() {
838         expect(3);
839         QUnit.reset();
840         stop();
841         
842         var div = jQuery("<div style='display:none'></div>").appendTo("#main");
843         equals( div.css("display"), "none", "Element is hidden by default" );
844         div.hide(1, function () {
845                 ok( !div.data("olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
846                 div.show(1, function () {
847                         equals( div.css("display"), "block", "Show a double-hidden element" );
848                         start();
849                 });
850         });
851 });