X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=b6dc2064f2b38e4075f3627da3cba5ee9e440b0c;hb=18a6fbbb6ab0bdabbbd377d23385650e45c30e74;hp=8aa883aed0c4143bba00426f438c2a1524e787b4;hpb=a38a5cd531a328319f8b7f3f33a84044b54591ce;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index 8aa883a..b6dc206 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -12,7 +12,7 @@ test("Basic requirements", function() { }); test("jQuery()", function() { - expect(11); + expect(12); // Basic constructor's behavior @@ -21,6 +21,9 @@ test("jQuery()", function() { equals( jQuery(null).length, 0, "jQuery(null) === jQuery([])" ); equals( jQuery("").length, 0, "jQuery('') === jQuery([])" ); + var obj = jQuery("div") + equals( jQuery(obj).selector, "div", "jQuery(jQueryObj) == jQueryObj" ); + // can actually yield more than one, when iframes are included, the window is an array as well equals( 1, jQuery(window).length, "Correct number of elements generated for jQuery(window)" ); @@ -266,8 +269,41 @@ test("isFunction", function() { }); }); +test("isXMLDoc - HTML", function() { + expect(4); + + ok( !jQuery.isXMLDoc( document ), "HTML document" ); + ok( !jQuery.isXMLDoc( document.documentElement ), "HTML documentElement" ); + ok( !jQuery.isXMLDoc( document.body ), "HTML Body Element" ); + + var iframe = document.createElement("iframe"); + document.body.appendChild( iframe ); + + try { + var body = jQuery(iframe).contents().find("body")[0]; + ok( !jQuery.isXMLDoc( body ), "Iframe body element" ); + } catch(e){ + ok( false, "Iframe body element" ); + } + + document.body.removeChild( iframe ); +}); + +if ( !isLocal ) { +test("isXMLDoc - XML", function() { + expect(3); + stop(); + jQuery.get('data/dashboard.xml', function(xml) { + ok( jQuery.isXMLDoc( xml ), "XML document" ); + ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" ); + ok( jQuery.isXMLDoc( jQuery("tab", xml)[0] ), "XML Tab Element" ); + start(); + }); +}); +} + test("jQuery('html')", function() { - expect(8); + expect(13); reset(); jQuery.foo = false; @@ -277,6 +313,14 @@ test("jQuery('html')", function() { jQuery("body").append(""); ok( jQuery.foo, "Executing a scripts contents in the right context" ); + // Test multi-line HTML + var div = jQuery("
\r\nsome text\n

some p

\nmore text\r\n
")[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("")[0], "Creating a link" ); @@ -608,4 +652,4 @@ test("jQuery.isEmptyObject", function(){ // What about this ? // equals(true, jQuery.isEmptyObject(null), "isEmptyObject on null" ); -}); \ No newline at end of file +});