aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/traversing.js
diff options
context:
space:
mode:
authorMike Sherov <mike.sherov@gmail.com>2012-10-30 13:32:53 -0400
committerDave Methvin <dave.methvin@gmail.com>2012-10-30 13:32:53 -0400
commite8f91514a6f353e85d8117998087903dc7331210 (patch)
tree9574915a5e6eff125ae846a36f1e386ed032b733 /test/unit/traversing.js
parentc78a3ba6577b6735137abcd5c01a35ca28c33660 (diff)
downloadjquery-e8f91514a6f353e85d8117998087903dc7331210.tar.gz
jquery-e8f91514a6f353e85d8117998087903dc7331210.zip
Fix #12009. $().find( DOMElement ) should pushStack properly. Close gh-927.
Diffstat (limited to 'test/unit/traversing.js')
-rw-r--r--test/unit/traversing.js24
1 files changed, 13 insertions, 11 deletions
diff --git a/test/unit/traversing.js b/test/unit/traversing.js
index 0facd2e6e..f374f53c2 100644
--- a/test/unit/traversing.js
+++ b/test/unit/traversing.js
@@ -1,20 +1,21 @@
module("traversing", { teardown: moduleTeardown });
-test("find(String)", function() {
- expect(5);
+test( "find(String)", function() {
+ expect( 6 );
equal( "Yahoo", jQuery("#foo").find(".blogTest").text(), "Check for find" );
// using contents will get comments regular, text, and comment nodes
var j = jQuery("#nonnodes").contents();
equal( j.find("div").length, 0, "Check node,textnode,comment to find zero divs" );
+ equal( j.find("div").andSelf().length, 3, "Check node,textnode,comment to find zero divs, but preserves pushStack" );
- deepEqual( jQuery("#qunit-fixture").find("> div").get(), q("foo", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest", "fx-test-group"), "find child elements" );
- deepEqual( jQuery("#qunit-fixture").find("> #foo, > #moretests").get(), q("foo", "moretests"), "find child elements" );
- deepEqual( jQuery("#qunit-fixture").find("> #foo > p").get(), q("sndp", "en", "sap"), "find child elements" );
+ deepEqual( jQuery("#qunit-fixture").find("> div").get(), q( "foo", "moretests", "tabindex-tests", "liveHandlerOrder", "siblingTest", "fx-test-group" ), "find child elements" );
+ deepEqual( jQuery("#qunit-fixture").find("> #foo, > #moretests").get(), q( "foo", "moretests" ), "find child elements" );
+ deepEqual( jQuery("#qunit-fixture").find("> #foo > p").get(), q( "sndp", "en", "sap" ), "find child elements" );
});
-test("find(node|jQuery object)", function() {
- expect( 11 );
+test( "find(node|jQuery object)", function() {
+ expect( 12 );
var $foo = jQuery("#foo"),
$blog = jQuery(".blogTest"),
@@ -23,18 +24,19 @@ test("find(node|jQuery object)", function() {
$fooTwo = $foo.add( $blog );
equal( $foo.find( $blog ).text(), "Yahoo", "Find with blog jQuery object" );
- equal( $foo.find( $blog[0] ).text(), "Yahoo", "Find with blog node" );
+ equal( $foo.find( $blog[ 0 ] ).text(), "Yahoo", "Find with blog node" );
equal( $foo.find( $first ).length, 0, "#first is not in #foo" );
- equal( $foo.find( $first[0]).length, 0, "#first not in #foo (node)" );
+ equal( $foo.find( $first[ 0 ]).length, 0, "#first not in #foo (node)" );
ok( $foo.find( $two ).is(".blogTest"), "Find returns only nodes within #foo" );
ok( $fooTwo.find( $blog ).is(".blogTest"), "Blog is part of the collection, but also within foo" );
- ok( $fooTwo.find( $blog[0] ).is(".blogTest"), "Blog is part of the collection, but also within foo(node)" );
+ ok( $fooTwo.find( $blog[ 0 ] ).is(".blogTest"), "Blog is part of the collection, but also within foo(node)" );
equal( $two.find( $foo ).length, 0, "Foo is not in two elements" );
- equal( $two.find( $foo[0] ).length, 0, "Foo is not in two elements(node)" );
+ equal( $two.find( $foo[ 0 ] ).length, 0, "Foo is not in two elements(node)" );
equal( $two.find( $first ).length, 0, "first is in the collection and not within two" );
equal( $two.find( $first ).length, 0, "first is in the collection and not within two(node)" );
+ equal( $two.find( $foo[ 0 ] ).andSelf().length, 2, "find preserves the pushStack, see #12009" );
});
test("is(String|undefined)", function() {