X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=test%2Funit%2Fcore.js;h=494917e081839335356df6e23963ba3901ad60bf;hb=0066ba3f823fdf3e41aa805f54876312c8bd915a;hp=e1c373301b3098118b5ff5eaa349d2058596cb11;hpb=d3141dcdba883ef87c8cd0b51a1ff9b61d153ffa;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index e1c3733..494917e 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() { @@ -896,7 +899,7 @@ test("append(String|Element|Array<Element>|jQuery)", function() { }); test("appendTo(String|Element|Array<Element>|jQuery)", function() { - expect(6); + expect(7); var defaultText = 'Try them out:' jQuery('buga').appendTo('#first'); equals( jQuery("#first").text(), defaultText + 'buga', 'Check if text appending works' ); @@ -913,6 +916,9 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() { equals( expected, jQuery('#sap').text(), "Check for appending of array of elements" ); reset(); + ok( jQuery(document.createElement("script")).appendTo("body").length, "Make sure a disconnected script can be appended." ); + + reset(); expected = document.querySelectorAll ? "This link has class=\"blog\": Simon Willison's WeblogYahooTry them out:" : "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo"; @@ -1345,10 +1351,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; @@ -1381,7 +1388,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("