X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=7942548692b0bce7ce9f94426a54aa01238b5288;hb=96152559e0e2fa1afc70f8994e664f5805aebad5;hp=ae8490ec2ed8ea215a2368667a1a05583953f321;hpb=4694e537bc911d843524d5f54c65f29c8a60fc5c;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index ae8490e..7942548 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" ); @@ -291,9 +294,10 @@ test("jQuery(selector, xml).text(str) - Loaded via XML document", function() { stop(); jQuery.get('data/dashboard.xml', function(xml) { // tests for #1419 where IE was a problem - equals( jQuery("tab:first", xml).text(), "blabla", "Verify initial text correct" ); - jQuery("tab:first", xml).text("newtext"); - equals( jQuery("tab:first", xml).text(), "newtext", "Verify new text correct" ); + var tab = jQuery("tab", xml).eq(0); + equals( tab.text(), "blabla", "Verify initial text correct" ); + tab.text("newtext"); + equals( tab.text(), "newtext", "Verify new text correct" ); start(); }); }); @@ -379,7 +383,7 @@ test("index(Object)", function() { }); test("attr(String)", function() { - expect(26); + expect(27); equals( jQuery('#text1').attr('value'), "Test", 'Check for value attribute' ); equals( jQuery('#text1').attr('value', "Test2").attr('defaultValue'), "Test", 'Check for defaultValue attribute' ); equals( jQuery('#text1').attr('type'), "text", 'Check for type attribute' ); @@ -403,6 +407,8 @@ test("attr(String)", function() { jQuery('').attr('href', '#5').appendTo('#main'); // using innerHTML in IE causes href attribute to be serialized to the full path equals( jQuery('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' ); + equals( jQuery("