Added support for class selectors and class attribute selectors on XML documents...
[jquery.git] / test / unit / selector.js
index 341d59b..c4c1360 100644 (file)
@@ -35,10 +35,12 @@ test("element", function() {
 
 if ( location.protocol != "file:" ) {
        test("XML Document Selectors", function() {
-               expect(5);
+               expect(7);
                stop();
                jQuery.get("data/with_fries.xml", function(xml) {
                        equals( jQuery("foo_bar", xml).length, 1, "Element Selector with underscore" );
+                       equals( jQuery(".component", xml).length, 1, "Class selector" );
+                       equals( jQuery("[class*=component]", xml).length, 1, "Attribute selector for class" );
                        equals( jQuery("property[name=prop2]", xml).length, 1, "Attribute selector with name" );
                        equals( jQuery("[name=prop2]", xml).length, 1, "Attribute selector with name" );
                        equals( jQuery("#seite1", xml).length, 1, "Attribute selector with ID" );
@@ -180,7 +182,7 @@ test("multiple", function() {
 });
 
 test("child and adjacent", function() {
-       expect(45);
+       expect(49);
        t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
        t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
        t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
@@ -193,6 +195,9 @@ test("child and adjacent", function() {
        t( "Adjacent", "a+ a", ["groups"] );
        t( "Adjacent", "a+a", ["groups"] );
        t( "Adjacent", "p + p", ["ap","en","sap"] );
+       t( "Adjacent", "p#firstp + p", ["ap"] );
+       t( "Adjacent", "p[lang=en] + p", ["sap"] );
+       t( "Adjacent", "a.GROUPS + code + a", ["mark"] );
        t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
 
        t( "Verify deep class selector", "div.blah > p > a", [] );
@@ -208,6 +213,7 @@ test("child and adjacent", function() {
        
        t( "First Child", "p:first-child", ["firstp","sndp"] );
        t( "Nth Child", "p:nth-child(1)", ["firstp","sndp"] );
+       t( "Not Nth Child", "p:not(:nth-child(1))", ["ap","en","sap","first"] );
 
        // Verify that the child position isn't being cached improperly
        jQuery("p:first-child").after("<div></div>");
@@ -305,7 +311,7 @@ test("attributes", function() {
 });
 
 test("pseudo (:) selectors", function() {
-       expect(67);
+       expect(70);
        t( "First Child", "p:first-child", ["firstp","sndp"] );
        t( "Last Child", "p:last-child", ["sap"] );
        t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2","liveLink1","liveLink2"] );
@@ -351,8 +357,11 @@ test("pseudo (:) selectors", function() {
        t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
        t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
        t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
-       t( "Is Visible", "#form input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );
-       t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] );
+       t( "Is Visible", "#form input:visible", [] );
+       t( "Is Visible", "div:visible:not(.testrunner-toolbar)", ["nothiddendiv", "nothiddendivchild"] );
+       t( "Is Hidden", "#form input:hidden", ["text1","text2","radio1","radio2","check1","check2","hidden1","hidden2","name"] );
+       t( "Is Hidden", "#main:hidden", ["main"] );
+       t( "Is Hidden", "#dl:hidden", ["dl"] );
 
        t( "Check position filtering", "div#nothiddendiv:eq(0)", ["nothiddendiv"] );
        t( "Check position filtering", "div#nothiddendiv:last", ["nothiddendiv"] );