Added some more tests around the name tests to catch possible regressions.
[jquery.git] / test / unit / selector.js
index 3332b1b..b8fab08 100644 (file)
@@ -148,7 +148,7 @@ test("class", function() {
 });
 
 test("name", function() {
-       expect(11);
+       expect(14);
 
        t( "Name selector", "input[name=action]", ["text1"] );
        t( "Name selector with single quotes", "input[name='action']", ["text1"] );
@@ -163,10 +163,14 @@ test("name", function() {
        same( jQuery("#form").find("input[name=action]").get(), q("text1"), "Name selector within the context of another element" );
        same( jQuery("#form").find("input[name='foo[bar]']").get(), q("hidden2"), "Name selector for grouped form element within the context of another element" );
 
-       var a = jQuery('<a id="tName1ID" name="tName1">tName1 A</a><a id="tName2ID" name="tName2">tName2 A</a><div id="tName1">tName1 Div</div>').appendTo('#main');
+       var a = jQuery('<div><a id="tName1ID" name="tName1">tName1 A</a><a id="tName2ID" name="tName2">tName2 A</a><div id="tName1">tName1 Div</div></div>').appendTo('#main').children();
+
+       equals( a.length, 3, "Make sure the right number of elements were inserted." );
+       equals( a[1].id, "tName2ID", "Make sure the right number of elements were inserted." );
 
        t( "Find elements that have similar IDs", "[name=tName1]", ["tName1ID"] );
        t( "Find elements that have similar IDs", "[name=tName2]", ["tName2ID"] );
+       t( "Find elements that have similar IDs", "#tName2ID", ["tName2ID"] );
 
        a.remove();
 });
@@ -379,20 +383,18 @@ test("pseudo - position", function() {
        t( "Check element position", "div#nothiddendiv:first > div:first", ["nothiddendivchild"] );
 });
 
+if ( (window.Sizzle || jQuery.find).selectors.filters.visibility ) {
 test("pseudo - visibility", function() {
-       expect(13);
+       expect(11);
 
        t( "Is Visible", "#form input:visible", [] );
        t( "Is Visible", "div:visible:not(#qunit-testrunner-toolbar):lt(2)", ["nothiddendiv", "nothiddendivchild"] );
        t( "Is Hidden", "#form input:hidden", ["text1","text2","radio1","radio2","check1","check2","hidden1","hidden2","name","search"] );
        t( "Is Hidden", "#main:hidden", ["main"] );
        t( "Is Hidden", "#dl:hidden", ["dl"] );
-       
-       var $div = jQuery('#nothiddendivchild');
+
+       var $div = jQuery('<div/>').appendTo("body");
        $div.css({ fontSize: 0, lineHeight: 0 });// IE also needs to set font-size and line-height to 0
-       $div.width(0).height(0);
-       t( "Is Hidden", '#nothiddendivchild:hidden', ['nothiddendivchild'] );
-       t( "Is Not Hidden", '#nothiddendivchild:visible', [] );
        $div.width(1).height(0);
        t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
        t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
@@ -402,8 +404,9 @@ test("pseudo - visibility", function() {
        $div.width(1).height(1);
        t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
        t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
-       $div.width('').height('').css({ fontSize: '', lineHeight: '' });
+       $div.remove();
 });
+}
 
 test("pseudo - form", function() {
        expect(8);