X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=test%2Funit%2Fcore.js;h=abd4f679dfb1de4c44b31b6f235e21c677e592af;hb=4460d5ad5949e5c9bf58d5de72b1d8b308181bf7;hp=7218bd041410635f12dc73e65c10a8ba378bbe05;hpb=ffd457d4561eb1a6653aaef90f92a3b3010b9139;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index 7218bd0..abd4f67 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -12,8 +12,19 @@ test("Basic requirements", function() { }); test("jQuery()", function() { - expect(8); - + expect(11); + + // Basic constructor's behavior + + equals( jQuery().length, 1, "jQuery() === jQuery(document)" ); + equals( jQuery(undefined).length, 0, "jQuery(undefined) === jQuery([])" ); + equals( jQuery(null).length, 0, "jQuery(null) === jQuery([])" ); + equals( jQuery("").length, 0, "jQuery('') === jQuery([])" ); + + // 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)" ); + + var main = jQuery("#main"); isSet( jQuery("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" ); @@ -42,11 +53,6 @@ test("jQuery()", function() { var div = jQuery("

"); equals( div.length, 4, "Correct number of elements generated for div hr code b" ); - // can actually yield more than one, when iframes are included, the window is an array as well - equals( jQuery(window).length, 1, "Correct number of elements generated for window" ); - - equals( jQuery(document).length, 1, "Correct number of elements generated for document" ); - equals( jQuery([1,2,3]).get(1), 2, "Test passing an array to the factory" ); equals( jQuery(document.body).get(0), jQuery('body').get(0), "Test passing an html node to the factory" ); @@ -57,7 +63,7 @@ test("selector state", function() { var test; - test = jQuery(); + test = jQuery(undefined); equals( test.selector, "", "Empty jQuery Selector" ); equals( test.context, undefined, "Empty jQuery Context" ); @@ -389,7 +395,7 @@ test("index(Object|String|undefined)", function() { equals( jQuery("#form :radio").index( jQuery("#radio2") ), 1, "Pass in a jQuery object" ); // Passing a selector or nothing - // enabled since [6329] + // enabled since [6330] equals( jQuery('#text2').index(), 2, "Check for index amongst siblings" ); equals( jQuery('#form').children().eq(4).index(), 4, "Check for index amongst siblings" ); equals( jQuery('#radio2').index('#form :radio') , 1, "Check for index within a selector" );