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