X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=test%2Funit%2Fcss.js;h=5f8a74ae4faad718f6620193121d86966e188033;hb=323270f6dcc4fdbef0e6d81f5e37b315fbffc599;hp=f50a21c1c949fa2e649889e660c7591e1bf4272b;hpb=de659859333c4e1a7840cc8d43765f47fcf53e9f;p=jquery.git
diff --git a/test/unit/css.js b/test/unit/css.js
index f50a21c..5f8a74a 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -1,7 +1,7 @@
module("css");
test("css(String|Hash)", function() {
- expect(28);
+ expect(30);
equals( jQuery('#main').css("display"), 'none', 'Check for css property "display"');
@@ -44,7 +44,9 @@ test("css(String|Hash)", function() {
var div = jQuery('#nothiddendiv'), child = jQuery('#nothiddendivchild');
equals( parseInt(div.css("fontSize")), 16, "Verify fontSize px set." );
+ equals( parseInt(div.css("font-size")), 16, "Verify fontSize px set." );
equals( parseInt(child.css("fontSize")), 16, "Verify fontSize px set." );
+ equals( parseInt(child.css("font-size")), 16, "Verify fontSize px set." );
child.attr("class", "em");
equals( parseInt(child.css("fontSize")), 32, "Verify fontSize em set." );
@@ -118,69 +120,123 @@ if(jQuery.browser.msie) {
}
test("css(String, Function)", function() {
- try {
- expect(3);
+ expect(3);
- var sizes = ["10px", "20px", "30px"];
+ var sizes = ["10px", "20px", "30px"];
- jQuery("
")
- .appendTo("body");
+ jQuery("")
+ .appendTo("body");
- var index = 0;
+ var index = 0;
- jQuery("#cssFunctionTest div").css("font-size", function() {
- var size = sizes[index];
- index++;
- return size;
- });
+ jQuery("#cssFunctionTest div").css("font-size", function() {
+ var size = sizes[index];
+ index++;
+ return size;
+ });
- index = 0;
+ index = 0;
+
+ jQuery("#cssFunctionTest div").each(function() {
+ var computedSize = jQuery(this).css("font-size")
+ var expectedSize = sizes[index]
+ equals( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
+ index++;
+ });
+
+ jQuery("#cssFunctionTest").remove();
+});
+
+test("css(String, Function) with incoming value", function() {
+ expect(3);
- jQuery("#cssFunctionTest div").each(function() {
- var computedSize = jQuery(this).css("font-size")
- var expectedSize = sizes[index]
- equals( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
- index++;
- });
+ var sizes = ["10px", "20px", "30px"];
+
+ jQuery("")
+ .appendTo("body");
+
+ var index = 0;
+
+ jQuery("#cssFunctionTest div").css("font-size", function() {
+ var size = sizes[index];
+ index++;
+ return size;
+ });
- } finally {
- jQuery("#cssFunctionTest").remove();
- }
+ index = 0;
+
+ jQuery("#cssFunctionTest div").css("font-size", function(i, computedSize) {
+ var expectedSize = sizes[index]
+ equals( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
+ index++;
+ return computedSize;
+ });
+
+ jQuery("#cssFunctionTest").remove();
});
test("css(Object) where values are Functions", function() {
- try {
- expect(3);
+ expect(3);
- var sizes = ["10px", "20px", "30px"];
+ var sizes = ["10px", "20px", "30px"];
+
+ jQuery("")
+ .appendTo("body");
+
+ var index = 0;
- jQuery("")
- .appendTo("body");
+ jQuery("#cssFunctionTest div").css({fontSize: function() {
+ var size = sizes[index];
+ index++;
+ return size;
+ }});
+
+ index = 0;
+
+ jQuery("#cssFunctionTest div").each(function() {
+ var computedSize = jQuery(this).css("font-size")
+ var expectedSize = sizes[index]
+ equals( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
+ index++;
+ });
+
+ jQuery("#cssFunctionTest").remove();
+});
+
+test("css(Object) where values are Functions with incoming values", function() {
+ expect(3);
+
+ var sizes = ["10px", "20px", "30px"];
- var index = 0;
+ jQuery("")
+ .appendTo("body");
+
+ var index = 0;
- jQuery("#cssFunctionTest div").css({fontSize: function() {
- var size = sizes[index];
- index++;
- return size;
- }});
+ jQuery("#cssFunctionTest div").css({fontSize: function() {
+ var size = sizes[index];
+ index++;
+ return size;
+ }});
- index = 0;
+ index = 0;
- jQuery("#cssFunctionTest div").each(function() {
- var computedSize = jQuery(this).css("font-size")
- var expectedSize = sizes[index]
- equals( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
- index++;
- });
+ jQuery("#cssFunctionTest div").css({"font-size": function(i, computedSize) {
+ var expectedSize = sizes[index]
+ equals( computedSize, expectedSize, "Div #" + index + " should be " + expectedSize );
+ index++;
+ return computedSize;
+ }});
- } finally {
- jQuery("#cssFunctionTest").remove();
- }
+ jQuery("#cssFunctionTest").remove();
});
test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function () {