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