X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Ftraversing.js;h=46a49bb9788c771f8d0412a580471cc37c093ea2;hb=a2731202917f8e90cad94ee574241d1626dc7fb6;hp=16f6043e8fac958a7baf1f3cda12baf2cfb15afd;hpb=cae93c39eb57ccc2acc5e101eda7a56e0a734cdf;p=jquery.git diff --git a/test/unit/traversing.js b/test/unit/traversing.js index 16f6043..46a49bb 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -101,10 +101,10 @@ test("closest()", function() { isSet( jQuery("div").closest("body:first div:last").get(), q("fx-tests"), "closest(body:first div:last)" ); // Test .closest() limited by the context - var jq = jQuery("#nothiddendivchild", document.body); - isSet( jq.closest("html").get(), [], "Context limited." ); - isSet( jq.closest("body").get(), [], "Context limited." ); - isSet( jq.closest("#nothiddendiv").get(), q("nothiddendiv"), "Context not reached." ); + var jq = jQuery("#nothiddendivchild"); + isSet( jq.closest("html", document.body).get(), [], "Context limited." ); + isSet( jq.closest("body", document.body).get(), [], "Context limited." ); + isSet( jq.closest("#nothiddendiv", document.body).get(), q("nothiddendiv"), "Context not reached." ); }); test("not(Selector)", function() { @@ -203,7 +203,7 @@ test("prev([String])", function() { }); test("slice()", function() { - expect(6); + expect(7); var $links = jQuery("#ap a"); @@ -213,8 +213,20 @@ test("slice()", function() { isSet( $links.slice(-1), q("mark"), "slice(-1)" ); isSet( $links.eq(1), q("groups"), "eq(1)" ); - isSet( $links.eq('2'), q("anchor1"), "eq('2')" ); + isSet( $links.eq(-1), q("mark"), "eq(-1)" ); +}); + +test("first()/last()", function() { + expect(4); + + var $links = jQuery("#ap a"), $none = jQuery("asdf"); + + isSet( $links.first(), q("google"), "first()" ); + isSet( $links.last(), q("mark"), "last()" ); + + isSet( $none.first(), [], "first() none" ); + isSet( $none.last(), [], "last() none" ); }); test("map()", function() {