added tests for show/hide with falsy, non-zero values
authorKarl Swedberg <karl@englishrules.com>
Tue, 19 Jan 2010 23:27:20 +0000 (07:27 +0800)
committerJohn Resig <jeresig@gmail.com>
Sat, 23 Jan 2010 17:25:22 +0000 (01:25 +0800)
test/unit/effects.js

index cefcc15..e44739b 100644 (file)
@@ -1,18 +1,37 @@
 module("effects");
 
 test("show()", function() {
-       expect(16);
+       expect(23);
        var pass = true, div = jQuery("#main div");
        div.show().each(function(){
                if ( this.style.display == "none" ) pass = false;
        });
        ok( pass, "Show" );
 
-       pass = true;
-       div.hide().show(null).each(function() {
-               if ( this.style.display == "none" ) pass = false;
+       var speeds = {
+         "null speed": null,
+         "undefined speed": undefined,
+         "empty string speed": "",
+         "false speed": false
+       };
+
+       jQuery.each(speeds, function(name, speed) {
+    pass = true;
+       div.hide().show(speed).each(function() {
+               if ( this.style.display == "none" ) pass = false;
+       });
+       ok( pass, "Show with " + name);
+  });
+
+
+       jQuery.each(speeds, function(name, speed) {
+    pass = true;
+       div.hide().show(speed, function() {
+                       pass = false;
+               });
+               ok( pass, "Show with " + name + " does not call animate callback");
        });
-       ok( pass, "Show will null speed");
+       
 
        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>');