X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=939e1b83785f37987866c7f519e2dfc845f5f5bb;hb=d415e0adb8f89a00768091795860daa5f2c29835;hp=679d50425e4506426b49018c2706e9700cb79459;hpb=4b25b147ab60a026ba1841b313d713fe57530b04;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index 679d504..939e1b8 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -53,34 +53,43 @@ test("jQuery()", function() { }); test("selector state", function() { - expect(26); + expect(30); var test; - + test = jQuery(); equals( test.selector, "", "Empty jQuery Selector" ); - equals( test.context, document, "Empty jQuery Context" ); - + equals( test.context, undefined, "Empty jQuery Context" ); + test = jQuery(document); equals( test.selector, "", "Document Selector" ); equals( test.context, document, "Document Context" ); - + test = jQuery(document.body); equals( test.selector, "", "Body Selector" ); equals( test.context, document.body, "Body Context" ); - + test = jQuery("#main"); equals( test.selector, "#main", "#main Selector" ); equals( test.context, document, "#main Context" ); - + + test = jQuery("#notfoundnono"); + equals( test.selector, "#notfoundnono", "#notfoundnono Selector" ); + equals( test.context, document, "#notfoundnono Context" ); + test = jQuery("#main", document); equals( test.selector, "#main", "#main Selector" ); equals( test.context, document, "#main Context" ); - + test = jQuery("#main", document.body); equals( test.selector, "#main", "#main Selector" ); equals( test.context, document.body, "#main Context" ); - + + // Test cloning + test = jQuery(test); + equals( test.selector, "#main", "#main Selector" ); + equals( test.context, document.body, "#main Context" ); + test = jQuery(document.body).find("#main"); equals( test.selector, "#main", "#main find Selector" ); equals( test.context, document.body, "#main find Context" ); @@ -88,23 +97,23 @@ test("selector state", function() { test = jQuery("#main").filter("div"); equals( test.selector, "#main.filter(div)", "#main filter Selector" ); equals( test.context, document, "#main filter Context" ); - + test = jQuery("#main").not("div"); equals( test.selector, "#main.not(div)", "#main not Selector" ); equals( test.context, document, "#main not Context" ); - + test = jQuery("#main").filter("div").not("div"); equals( test.selector, "#main.filter(div).not(div)", "#main filter, not Selector" ); equals( test.context, document, "#main filter, not Context" ); - + test = jQuery("#main").filter("div").not("div").end(); equals( test.selector, "#main.filter(div)", "#main filter, not, end Selector" ); equals( test.context, document, "#main filter, not, end Context" ); - + test = jQuery("#main").parent("body"); equals( test.selector, "#main.parent(body)", "#main parent Selector" ); equals( test.context, document, "#main parent Context" ); - + test = jQuery("#main").eq(0); equals( test.selector, "#main.slice(0,1)", "#main eq Selector" ); equals( test.context, document, "#main eq Context" ); @@ -141,7 +150,7 @@ test("browser", function() { }; for (var i in browsers) { var v = i.toLowerCase().match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ); // RegEx from Core jQuery.browser.version check - version = v ? v[1] : null; + var version = v ? v[1] : null; equals( version, browsers[i], "Checking UA string" ); } }); @@ -251,23 +260,23 @@ test("isFunction", function() { }); }); -var foo = false; - test("jQuery('html')", function() { - expect(6); + expect(8); reset(); - foo = false; - var s = jQuery("")[0]; + jQuery.foo = false; + var s = jQuery("")[0]; ok( s, "Creating a script" ); - ok( !foo, "Make sure the script wasn't executed prematurely" ); - jQuery("body").append(""); - ok( foo, "Executing a scripts contents in the right context" ); + ok( !jQuery.foo, "Make sure the script wasn't executed prematurely" ); + jQuery("body").append(""); + ok( jQuery.foo, "Executing a scripts contents in the right context" ); reset(); ok( jQuery("")[0], "Creating a link" ); - reset(); + ok( !jQuery("'); - - jQuery("#main").html('foo
'); - - // it was decided that waiting to execute ALL scripts makes sense since nested ones have to wait anyway so this test case is changed, see #1959 - jQuery("#main").html("