X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fselector.js;h=3e70481af2e11e8e67d40d8e3001b099895b227a;hb=811891785f5bfa3f42ec9cb18e68fc3a114935e9;hp=341d59b9e0ade7703393ea091b061c2de045a9a5;hpb=f0189d618181409ac628b9bbdecd77338127b9b1;p=jquery.git diff --git a/test/unit/selector.js b/test/unit/selector.js index 341d59b..3e70481 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -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("
"); @@ -305,12 +311,12 @@ test("attributes", function() { }); test("pseudo (:) selectors", function() { - expect(67); + expect(78); 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"] ); t( "Empty", "ul:empty", ["firstUL"] ); - t( "Enabled UI Element", "#form input:not([type=hidden]):enabled", ["text1","radio1","radio2","check1","check2","hidden2","name"] ); + t( "Enabled UI Element", "#form input:not([type=hidden]):enabled", ["text1","radio1","radio2","check1","check2","hidden2","name","search"] ); t( "Disabled UI Element", "#form input:disabled", ["text2"] ); t( "Checked UI Element", "#form input:checked", ["radio2","check1"] ); t( "Selected Option Element", "#form option:selected", ["option1a","option2d","option3b","option3c"] ); @@ -320,7 +326,7 @@ test("pseudo (:) selectors", function() { t( "Text Contains", "a:contains('Google Groups (Link)')", ["groups"] ); t( "Text Contains", "a:contains('(Link)')", ["groups"] ); - t( "Element Preceded By", "p ~ div", ["foo","fx-queue","fx-tests", "moretests","tabindex-tests", "liveHandlerOrder"] ); + t( "Element Preceded By", "p ~ div", ["foo", "moretests","tabindex-tests", "liveHandlerOrder"] ); t( "Not", "a.blog:not(.link)", ["mark"] ); t( "Not - multiple", "#form option:not(:contains('Nothing'),#option1b,:selected)", ["option1c", "option1d", "option2b", "option2c", "option3d", "option3e"] ); //t( "Not - complex", "#form option:not([id^='opt']:nth-child(-n+3))", [ "option1a", "option1d", "option2d", "option3d", "option3e"] ); @@ -351,8 +357,27 @@ 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):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'); + $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', [] ); + $div.width(0).height(1); + t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] ); + t( "Is Not Visible", '#nothiddendivchild:hidden', [] ); + $div.width(1).height(1); + t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] ); + t( "Is Not Visible", '#nothiddendivchild:hidden', [] ); + $div.width('').height('').css({ fontSize: '', lineHeight: '' }); t( "Check position filtering", "div#nothiddendiv:eq(0)", ["nothiddendiv"] ); t( "Check position filtering", "div#nothiddendiv:last", ["nothiddendiv"] ); @@ -365,18 +390,18 @@ test("pseudo (:) selectors", function() { t( "Check position filtering", "div.nothiddendiv:not(:lt(0))", ["nothiddendiv"] ); t( "Check element position", "div div:eq(0)", ["nothiddendivchild"] ); - t( "Check element position", "div div:eq(5)", ["fadeout"] ); - t( "Check element position", "div div:eq(27)", ["t2037"] ); + t( "Check element position", "div div:eq(5)", ["t2037"] ); + t( "Check element position", "div div:eq(27)", ["hide"] ); t( "Check element position", "div div:first", ["nothiddendivchild"] ); t( "Check element position", "div > div:first", ["nothiddendivchild"] ); t( "Check element position", "#dl div:first div:first", ["foo"] ); t( "Check element position", "#dl div:first > div:first", ["foo"] ); t( "Check element position", "div#nothiddendiv:first > div:first", ["nothiddendivchild"] ); - t( "Form element :input", "#form :input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3"] ); + t( "Form element :input", "#form :input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "search", "button", "area1", "select1", "select2", "select3"] ); t( "Form element :radio", "#form :radio", ["radio1", "radio2"] ); t( "Form element :checkbox", "#form :checkbox", ["check1", "check2"] ); - t( "Form element :text", "#form :text", ["text1", "text2", "hidden2", "name"] ); + t( "Form element :text", "#form :text:not(#search)", ["text1", "text2", "hidden2", "name"] ); t( "Form element :radio:checked", "#form :radio:checked", ["radio2"] ); t( "Form element :checkbox:checked", "#form :checkbox:checked", ["check1"] ); t( "Form element :radio:checked, :checkbox:checked", "#form :radio:checked, #form :checkbox:checked", ["radio2", "check1"] );