diff options
author | timmywil <tim.willison@thisismedium.com> | 2011-03-21 20:59:20 -0400 |
---|---|---|
committer | timmywil <tim.willison@thisismedium.com> | 2011-03-21 20:59:20 -0400 |
commit | e09d8898d8a8df27bb72ebc64a4cd08c11f21ddd (patch) | |
tree | 5dbf3dbc5a47f64e83b1d055f53f8285b8dcc0f9 /test | |
parent | eb1497c1fb5a5e529e83c3597c7d212eae129ab7 (diff) | |
download | jquery-e09d8898d8a8df27bb72ebc64a4cd08c11f21ddd.tar.gz jquery-e09d8898d8a8df27bb72ebc64a4cd08c11f21ddd.zip |
Add node and jQuery object support to $.fn.closest
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/traversing.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/unit/traversing.js b/test/unit/traversing.js index 76b93d841..bd05f470c 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -182,6 +182,20 @@ test("closest(Array)", function() { same( jQuery("body").closest(["span","html"]), [{selector:"html", elem:document.documentElement, level:2}], "closest([body, html])" ); }); +test("closest(jQuery)", function() { + expect(7); + var $child = jQuery("#nothiddendivchild"), + $parent = jQuery("#nothiddendiv"), + $main = jQuery("#main"); + ok( $child.closest( $parent ).is('#nothiddendiv'), "closest( jQuery('#nothiddendiv') )" ); + ok( $child.closest( $parent[0] ).is('#nothiddendiv'), "closest( jQuery('#nothiddendiv') ) :: node" ); + ok( $child.closest( $child ).is('#nothiddendivchild'), "child is included" ); + ok( $child.closest( $child[0] ).is('#nothiddendivchild'), "child is included :: node" ); + equals( $child.closest( document.createElement('div') ).length, 0, "created element is not related" ); + equals( $child.closest( $main ).length, 0, "Main not a parent of child" ); + equals( $child.closest( $main[0] ).length, 0, "Main not a parent of child :: node" ); +}); + test("not(Selector)", function() { expect(7); equals( jQuery("#main > p#ap > a").not("#google").length, 2, "not('selector')" ); |