diff options
author | Oleg Gaidarenko <markelog@gmail.com> | 2014-02-27 03:32:02 +0400 |
---|---|---|
committer | Oleg Gaidarenko <markelog@gmail.com> | 2014-04-15 17:46:26 +0400 |
commit | 0837e41509dd58cbb3c6dd82567900f9ec829e6b (patch) | |
tree | 5f585e9d12c8d2a06827ff103e8a59ce9eefde34 /test | |
parent | a4e83764f44d524d385bb8a04cff6e5a7556cc8e (diff) | |
download | jquery-0837e41509dd58cbb3c6dd82567900f9ec829e6b.tar.gz jquery-0837e41509dd58cbb3c6dd82567900f9ec829e6b.zip |
Tests: Copy some Sizzle combinators tests
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/selector.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/unit/selector.js b/test/unit/selector.js index 3293ea1db..c3cdd31db 100644 --- a/test/unit/selector.js +++ b/test/unit/selector.js @@ -100,6 +100,47 @@ test( "selectors with comma", function() { equal( fixture.find( "h2 , div p" ).filter( "h2" ).length, 1, "has to find one <h2>" ); }); +test("child and adjacent", function() { + expect( 27 ); + + var nothiddendiv; + + 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"] ); + t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] ); + t( "Child w/ Class", "p > a.blog", ["mark","simon"] ); + t( "All Children", "code > *", ["anchor1","anchor2"] ); + t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] ); + 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( "Element Preceded By", "#groups ~ a", ["mark"] ); + t( "Element Preceded By", "#length ~ input", ["idTest"] ); + t( "Element Preceded By", "#siblingfirst ~ em", ["siblingnext", "siblingthird"] ); + t( "Element Preceded By (multiple)", "#siblingTest em ~ em ~ em ~ span", ["siblingspan"] ); + t( "Element Preceded By, Containing", "#liveHandlerOrder ~ div em:contains('1')", ["siblingfirst"] ); + + t( "Multiple combinators selects all levels", "#siblingTest em *", ["siblingchild", "siblinggrandchild", "siblinggreatgrandchild"] ); + t( "Multiple combinators selects all levels", "#siblingTest > em *", ["siblingchild", "siblinggrandchild", "siblinggreatgrandchild"] ); + t( "Multiple sibling combinators doesn't miss general siblings", "#siblingTest > em:first-child + em ~ span", ["siblingspan"] ); + t( "Combinators are not skipped when mixing general and specific", "#siblingTest > em:contains('x') + em ~ span", [] ); + + equal( jQuery("#listWithTabIndex").length, 1, "Parent div for next test is found via ID (#8310)" ); + equal( jQuery("#listWithTabIndex li:eq(2) ~ li").length, 1, "Find by general sibling combinator (#8310)" ); + equal( jQuery("#__sizzle__").length, 0, "Make sure the temporary id assigned by sizzle is cleared out (#8310)" ); + equal( jQuery("#listWithTabIndex").length, 1, "Parent div for previous test is still found via ID (#8310)" ); + + t( "Verify deep class selector", "div.blah > p > a", [] ); + + t( "No element deep selector", "div.foo > span > a", [] ); + + nothiddendiv = document.getElementById("nothiddendiv"); + + t( "Non-existant ancestors", ".fototab > .thumbnails > a", [] ); +}); + test("attributes", function() { expect( 54 ); |