jquery core: Fixed #5202. Fixing selector generation when a manipulation function...
[jquery.git] / test / unit / core.js
index c58f13f..d3e0a44 100644 (file)
@@ -62,7 +62,7 @@ test("jQuery()", function() {
 });
 
 test("selector state", function() {
-       expect(30);
+       expect(31);
 
        var test;
 
@@ -126,6 +126,13 @@ test("selector state", function() {
        test = jQuery("#main").eq(0);
        equals( test.selector, "#main.slice(0,1)", "#main eq Selector" );
        equals( test.context, document, "#main eq Context" );
+       
+       var d = "<div />";
+       equals(
+               jQuery(d).appendTo(jQuery(d)).selector,
+               jQuery(d).appendTo(d).selector,
+               "manipulation methods make same selector for jQuery objects"
+       );
 });
 
 test("browser", function() {
@@ -280,10 +287,10 @@ test("isXMLDoc - HTML", function() {
        document.body.appendChild( iframe );
 
        try {
-               var body = jQuery(iframe).contents().find("body")[0];
+               var body = jQuery(iframe).contents()[0];
                ok( !jQuery.isXMLDoc( body ), "Iframe body element" );
        } catch(e){
-               ok( false, "Iframe body element" );
+               ok( false, "Iframe body element exception" );
        }
 
        document.body.removeChild( iframe );
@@ -303,7 +310,7 @@ test("isXMLDoc - XML", function() {
 }
 
 test("jQuery('html')", function() {
-       expect(8);
+       expect(13);
 
        reset();
        jQuery.foo = false;
@@ -313,6 +320,14 @@ test("jQuery('html')", function() {
        jQuery("body").append("<script>jQuery.foo='test';</script>");
        ok( jQuery.foo, "Executing a scripts contents in the right context" );
 
+       // Test multi-line HTML
+       var div = jQuery("<div>\r\nsome text\n<p>some p</p>\nmore text\r\n</div>")[0];
+       equals( div.nodeName.toUpperCase(), "DIV", "Make sure we're getting a div." );
+       equals( div.firstChild.nodeType, 3, "Text node." );
+       equals( div.lastChild.nodeType, 3, "Text node." );
+       equals( div.childNodes[1].nodeType, 1, "Paragraph." );
+       equals( div.childNodes[1].firstChild.nodeType, 3, "Paragraph text." );
+
        reset();
        ok( jQuery("<link rel='stylesheet'/>")[0], "Creating a link" );
 
@@ -329,7 +344,7 @@ test("jQuery('html')", function() {
 test("jQuery('html', context)", function() {
        expect(1);
 
-       var $div = jQuery("<div/>");
+       var $div = jQuery("<div/>")[0];
        var $span = jQuery("<span/>", $div);
        equals($span.length, 1, "Verify a span created with a div context works, #1763");
 });