X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fcss.js;h=649db5966b57b34526a57a03b4f660d66ed54f93;hb=45dfa3b0fc49718c4f00600d1e25a129601d08ee;hp=a9171736c26bd1f4925f58050192aee48e3f661e;hpb=ec3ebd3e8a7dfda15d227ea3dd21361e534beac3;p=jquery.git diff --git a/test/unit/css.js b/test/unit/css.js index a917173..649db59 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -81,6 +81,72 @@ test("css(String, Object)", function() { equals( jQuery("#t2037 .hidden").css("display"), "none", "Make sure browser thinks it is hidden" ); }); +test("css(String, Function)", function() { + try { + expect(3); + + 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; + }); + + 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++; + }); + + } finally { + jQuery("#cssFunctionTest").remove(); + } +}); + +test("css(Object) where values are Functions", function() { + try { + expect(3); + + var sizes = ["10px", "20px", "30px"]; + + jQuery("
" + + "
" + + "
") + .appendTo("body"); + + var index = 0; + + 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++; + }); + + } finally { + jQuery("#cssFunctionTest").remove(); + } +}); + test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function () { expect(4);