Fix for bug #1549, where the DOM conversion of <code/> and similar elements would...
[jquery.git] / src / jquery / coreTest.js
index bb51acb..18fed64 100644 (file)
@@ -12,7 +12,7 @@ test("Basic requirements", function() {
 });
 
 test("$()", function() {
-       expect(2);
+       expect(5);
        
        var main = $("#main");
        isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
@@ -29,6 +29,13 @@ test("$()", function() {
                pass = false;
        }
        ok( pass, "$('&lt;tag&gt;') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/
+
+       var code = $("<code/>");
+       equals( code.length, 1, "Correct number of elements generated for code" );
+       var img = $("<img/>");
+       equals( img.length, 1, "Correct number of elements generated for img" );
+       var div = $("<div/><hr/><code/><b/>");
+       equals( div.length, 4, "Correct number of elements generated for div hr code b" );
 });
 
 test("isFunction", function() {
@@ -232,7 +239,7 @@ test("attr(Hash)", function() {
 });
 
 test("attr(String, Object)", function() {
-       expect(8);
+       expect(12);
        var div = $("div");
        div.attr("foo", "bar");
        var pass = true;
@@ -255,6 +262,28 @@ test("attr(String, Object)", function() {
        ok( document.getElementById('text1').readOnly == false, 'Set readonly attribute' );
        $("#name").attr('maxlength', '5');
        ok( document.getElementById('name').maxLength == '5', 'Set maxlength attribute' );
+
+       reset();
+
+       var type = $("#check2").attr('type');
+       var thrown = false;
+       try {
+               $("#check2").attr('type','hidden');
+       } catch(e) {
+               thrown = true;
+       }
+       ok( thrown, "Exception thrown when trying to change type property" );
+       equals( type, $("#check2").attr('type'), "Verify that you can't change the type of an input element" );
+
+       var check = document.createElement("input");
+       var thrown = true;
+       try {
+               $(check).attr('type','checkbox');
+       } catch(e) {
+               thrown = false;
+       }
+       ok( thrown, "Exception thrown when trying to change type property" );
+       equals( "checkbox", $(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" );
 });
 
 test("attr(String, Object) - Loaded via XML document", function() {