@@ -152,7 +152,43 @@ test("not(jQuery)", function() {
152152 expect ( 1 ) ;
153153
154154 same ( jQuery ( "p" ) . not ( jQuery ( "#ap, #sndp, .result" ) ) . get ( ) , q ( "firstp" , "en" , "sap" , "first" ) , "not(jQuery)" ) ;
155- } )
155+ } ) ;
156+
157+ test ( "has(Element)" , function ( ) {
158+ expect ( 2 ) ;
159+
160+ var obj = jQuery ( "#main" ) . has ( jQuery ( "#sndp" ) [ 0 ] ) ;
161+ same ( obj . get ( ) , q ( "main" ) , "Keeps elements that have the element as a descendant" ) ;
162+
163+ var multipleParent = jQuery ( "#main, #header" ) . has ( jQuery ( "#sndp" ) [ 0 ] ) ;
164+ same ( obj . get ( ) , q ( "main" ) , "Does not include elements that do not have the element as a descendant" ) ;
165+ } ) ;
166+
167+ test ( "has(Selector)" , function ( ) {
168+ expect ( 3 ) ;
169+
170+ var obj = jQuery ( "#main" ) . has ( "#sndp" ) ;
171+ same ( obj . get ( ) , q ( "main" ) , "Keeps elements that have any element matching the selector as a descendant" ) ;
172+
173+ var multipleParent = jQuery ( "#main, #header" ) . has ( "#sndp" ) ;
174+ same ( obj . get ( ) , q ( "main" ) , "Does not include elements that do not have the element as a descendant" ) ;
175+
176+ var multipleHas = jQuery ( "#main" ) . has ( "#sndp, #first" ) ;
177+ same ( multipleHas . get ( ) , q ( "main" ) , "Only adds elements once" ) ;
178+ } ) ;
179+
180+ test ( "has(Arrayish)" , function ( ) {
181+ expect ( 3 ) ;
182+
183+ var simple = jQuery ( "#main" ) . has ( jQuery ( "#sndp" ) ) ;
184+ same ( simple . get ( ) , q ( "main" ) , "Keeps elements that have any element in the jQuery list as a descendant" ) ;
185+
186+ var multipleParent = jQuery ( "#main, #header" ) . has ( jQuery ( "#sndp" ) ) ;
187+ same ( multipleParent . get ( ) , q ( "main" ) , "Does not include elements that do not have an element in the jQuery list as a descendant" ) ;
188+
189+ var multipleHas = jQuery ( "#main" ) . has ( jQuery ( "#sndp, #first" ) ) ;
190+ same ( simple . get ( ) , q ( "main" ) , "Only adds elements once" ) ;
191+ } ) ;
156192
157193test ( "andSelf()" , function ( ) {
158194 expect ( 4 ) ;
0 commit comments