X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=ef36c4f784798aebe65ac85fb863c1626678e023;hb=d62875fb0181c44f8b34a8e842ae323801637b25;hp=f49b6766e03bd86d3bb9cde58a852cf2aba9991a;hpb=c6de039bb1568d8e6162b8152b8208eff1af282d;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index f49b676..ef36c4f 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -53,7 +53,7 @@ test("jQuery()", function() { }); test("selector state", function() { - expect(26); + expect(28); var test; @@ -80,6 +80,11 @@ test("selector state", function() { 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" ); @@ -141,7 +146,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,18 +256,16 @@ test("isFunction", function() { }); }); -var foo = false; - test("jQuery('html')", function() { 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" ); @@ -455,7 +458,7 @@ test("attr(Hash)", function() { test("attr(String, Object)", function() { expect(19); - var div = jQuery("div").attr("foo", "bar"); + var div = jQuery("div").attr("foo", "bar"), fail = false; for ( var i = 0; i < div.size(); i++ ) { if ( div.get(i).getAttribute('foo') != "bar" ){ @@ -562,7 +565,7 @@ test("attr('tabindex')", function() { equals(jQuery('#divWithNoTabIndex').attr('tabindex'), undefined, 'no tabindex, not tabbable by default'); // link without a tabindex - equals(jQuery('#linkWithNoTabIndex').attr('tabindex'), undefined, 'no tabindex, tabbable by default'); + equals(jQuery('#linkWithNoTabIndex').attr('tabindex'), 0, 'no tabindex, tabbable by default'); }); test("attr('tabindex', value)", function() { @@ -1168,10 +1171,12 @@ test("clone() on XML nodes", function() { stop(); jQuery.get("data/dashboard.xml", function (xml) { var root = jQuery(xml.documentElement).clone(); - jQuery("tab:first", xml).text("origval"); - jQuery("tab:first", root).text("cloneval"); - equals(jQuery("tab:first", xml).text(), "origval", "Check original XML node was correctly set"); - equals(jQuery("tab:first", root).text(), "cloneval", "Check cloned XML node was correctly set"); + var origTab = jQuery("tab", xml).eq(0); + var cloneTab = jQuery("tab", root).eq(0); + origTab.text("origval"); + cloneTab.text("cloneval"); + equals(origTab.text(), "origval", "Check original XML node was correctly set"); + equals(cloneTab.text(), "cloneval", "Check cloned XML node was correctly set"); start(); }); }); @@ -1343,10 +1348,11 @@ test("val(String/Number)", function() { j.removeAttr("value"); }); -var scriptorder = 0; - test("html(String)", function() { expect(13); + + jQuery.scriptorder = 0; + var div = jQuery("#main > div"); div.html("test"); var pass = true; @@ -1379,7 +1385,7 @@ test("html(String)", function() { 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("