Fixed a couple problems found in the test suite. First, IE doesn't like it when...
[jquery.git] / test / unit / core.js
index 170be21..932d0a5 100644 (file)
@@ -473,12 +473,55 @@ test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", funct
 });
 
 test("width()", function() {
-       expect(2);
+       expect(9);
+
+       var $div = $("#nothiddendiv");
+       $div.width(30);
+       equals($div.width(), 30, "Test set to 30 correctly");
+       $div.width(-1); // handle negative numbers by ignoring #1599
+       equals($div.width(), 30, "Test negative width ignored");
+       $div.css("padding", "20px");
+       equals($div.width(), 30, "Test padding specified with pixels");
+       $div.css("border", "2px solid #fff");
+       equals($div.width(), 30, "Test border specified with pixels");
+       $div.css("padding", "2em");
+       equals($div.width(), 30, "Test padding specified with ems");
+       $div.css("border", "1em solid #fff");
+       equals($div.width(), 30, "Test border specified with ems");
+       $div.css("padding", "2%");
+       equals($div.width(), 30, "Test padding specified with percent");
+       $div.hide();
+       equals($div.width(), 30, "Test hidden div");
+       
+       $div.css({ display: "", border: "", padding: "" });
+       
+       $("#nothiddendivchild").css({ padding: "3px", border: "2px solid #fff" });
+       equals($("#nothiddendivchild").width(), 20, "Test child width with border and padding");
+       $("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", width: "" });
+});
+
+test("height()", function() {
+       expect(8);
 
-       $("#nothiddendiv").width(30);
-       equals($("#nothiddendiv").width(), 30, "Test set to 30 correctly");
-       $("#nothiddendiv").width(-1); // handle negative numbers by ignoring #1599
-       equals($("#nothiddendiv").width(), 30, "Test negative width ignored");
+       var $div = $("#nothiddendiv");
+       $div.height(30);
+       equals($div.height(), 30, "Test set to 30 correctly");
+       $div.height(-1); // handle negative numbers by ignoring #1599
+       equals($div.height(), 30, "Test negative height ignored");
+       $div.css("padding", "20px");
+       equals($div.height(), 30, "Test padding specified with pixels");
+       $div.css("border", "2px solid #fff");
+       equals($div.height(), 30, "Test border specified with pixels");
+       $div.css("padding", "2em");
+       equals($div.height(), 30, "Test padding specified with ems");
+       $div.css("border", "1em solid #fff");
+       equals($div.height(), 30, "Test border specified with ems");
+       $div.css("padding", "2%");
+       equals($div.height(), 30, "Test padding specified with percent");
+       $div.hide();
+       equals($div.height(), 30, "Test hidden div");
+       
+       $div.css({ display: "", border: "", padding: "", height: "1px" });
 });
 
 test("text()", function() {
@@ -986,11 +1029,12 @@ test("$.extend(Object, Object)", function() {
 });
 
 test("val()", function() {
-       expect(3);
+       expect(4);
        ok( $("#text1").val() == "Test", "Check for value of input element" );
        ok( !$("#text1").val() == "", "Check for value of input element" );
        // ticket #1714 this caused a JS error in IE
        ok( $("#first").val() == "", "Check a paragraph element to see if it has a value" );
+       ok( $([]).val() === undefined, "Check an empty jQuery object will return undefined from val" );
 });
 
 test("val(String)", function() {
@@ -1068,7 +1112,7 @@ test("not()", function() {
        isSet( $("#form option").not("option.emptyopt:contains('Nothing'),[selected],[value='1']").get(), q("option1c", "option1d", "option2c", "option3d" ), "not('complex selector')");
        
        var selects = $("#form select");
-       isSet( selects.not( selects[1] ), ["select1", "select3"], "filter out DOM element");
+       isSet( selects.not( selects[1] ), q("select1", "select3"), "filter out DOM element");
 });
 
 test("andSelf()", function() {