X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=b6dc2064f2b38e4075f3627da3cba5ee9e440b0c;hb=bddd1837bb512b0ed537fbbdecf3ac3f6067adba;hp=a6f490c4739ddb5c2c131a640c5ae932fd6bdd56;hpb=8e54b167cf60a6efa0e572d31f3886c3cfe74c0b;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index a6f490c..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("
some p
\nmore text\r\n