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