X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fselector.js;h=f4b5b68f5ecbcc0960131bd0a1e4ac36e584a6dc;hb=5586fedf2932dc17b303c860d9f0a7604223f865;hp=2539e4d3b87522b02c9506489e9fcd0503bd1357;hpb=f9a7cfacf7d609620fd5ce8a939268e93ef423a1;p=jquery.git diff --git a/test/unit/selector.js b/test/unit/selector.js index 2539e4d..f4b5b68 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -69,7 +69,7 @@ test("broken", function() { }); test("id", function() { - expect(27); + expect(28); t( "ID Selector", "#body", ["body"] ); t( "ID Selector w/ Element", "body#body", ["body"] ); t( "ID Selector w/ Element", "ul#first", [] ); @@ -105,6 +105,8 @@ test("id", function() { t( "Underscore ID", "#types_all", ["types_all"] ); t( "Dash ID", "#fx-queue", ["fx-queue"] ); + + t( "ID with weird characters in it", "#name\\+value", ["name+value"] ); }); test("class", function() { @@ -144,7 +146,7 @@ test("class", function() { }); test("name", function() { - expect(9); + expect(11); t( "Name selector", "input[name=action]", ["text1"] ); t( "Name selector with single quotes", "input[name='action']", ["text1"] ); @@ -158,6 +160,13 @@ test("name", function() { isSet( jQuery("#form").find("input[name=action]"), q("text1"), "Name selector within the context of another element" ); isSet( jQuery("#form").find("input[name='foo[bar]']"), q("hidden2"), "Name selector for grouped form element within the context of another element" ); + + var a = jQuery('tName1 AtName2 A
tName1 Div
').appendTo('#main'); + + t( "Find elements that have similar IDs", "[name=tName1]", ["tName1ID"] ); + t( "Find elements that have similar IDs", "[name=tName2]", ["tName2ID"] ); + + a.remove(); }); @@ -171,7 +180,7 @@ test("multiple", function() { }); test("child and adjacent", function() { - expect(45); + expect(48); 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"] ); @@ -184,6 +193,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", [] ); @@ -296,7 +308,7 @@ test("attributes", function() { }); test("pseudo (:) selectors", function() { - expect(53); + expect(67); 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"] ); @@ -316,6 +328,22 @@ test("pseudo (:) selectors", function() { 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"] ); t( "Not - recursive", "#form option:not(:not(:selected))[id^='option3']", [ "option3b", "option3c"] ); + + t( ":not() failing interior", "p:not(.foo)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not() failing interior", "p:not(div.foo)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not() failing interior", "p:not(p.foo)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not() failing interior", "p:not(#blargh)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not() failing interior", "p:not(div#blargh)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not() failing interior", "p:not(p#blargh)", ["firstp","ap","sndp","en","sap","first"] ); + + t( ":not Multiple", "p:not(a)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not Multiple", "p:not(a, b)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not Multiple", "p:not(a, b, div)", ["firstp","ap","sndp","en","sap","first"] ); + t( ":not Multiple", "p:not(p)", [] ); + t( ":not Multiple", "p:not(a,p)", [] ); + t( ":not Multiple", "p:not(p,a)", [] ); + t( ":not Multiple", "p:not(a,p,b)", [] ); + t( ":not Multiple", ":input:not(:image,:input,:submit)", [] ); t( "nth Element", "p:nth(1)", ["ap"] ); t( "First Element", "p:first", ["firstp"] );