aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authortimmywil <timmywillisn@gmail.com>2011-09-19 23:14:37 -0400
committertimmywil <timmywillisn@gmail.com>2011-09-19 23:14:37 -0400
commit0ced30e3190b6fe2714d8f01ebf92d7eb48d424b (patch)
tree1034e4743231cd7cb09f50bdf20f10410d38589d /test
parent11c9de477c5fe005a2487c761c257653aaf97a37 (diff)
downloadjquery-0ced30e3190b6fe2714d8f01ebf92d7eb48d424b.tar.gz
jquery-0ced30e3190b6fe2714d8f01ebf92d7eb48d424b.zip
Move filter tests to proper location
Diffstat (limited to 'test')
-rw-r--r--test/unit/traversing.js89
1 files changed, 45 insertions, 44 deletions
diff --git a/test/unit/traversing.js b/test/unit/traversing.js
index 18f9ad9f8..1c415c02e 100644
--- a/test/unit/traversing.js
+++ b/test/unit/traversing.js
@@ -101,49 +101,6 @@ test("is(jQuery)", function() {
ok( !jQuery("#simon").is( jQuery(".blogTest")[0] ), "Check for multiple classes: Expected classes 'blog' and 'link', but not 'blogTest'" );
});
-test("filter() with positional selectors", function() {
- expect(19);
-
- var html = jQuery('' +
- '<p id="posp">' +
- '<a class="firsta" href="#">' +
- '<em>first</em>' +
- '</a>' +
- '<a class="seconda" href="#">' +
- '<b>test</b>' +
- '</a>' +
- '<em></em>' +
- '</p>').appendTo( "body" ),
- filterit = function(sel, filter, length) {
- equal( jQuery( sel ).filter( filter ).length, length, "jQuery( " + sel + " ).filter( " + filter + " )" );
- };
-
- filterit( "#posp", "#posp:first", 1);
- filterit( "#posp", "#posp:eq(2)", 0 );
- filterit( "#posp", "#posp a:first", 0 );
-
- // Keep in mind this is within the selection and
- // not in relation to other elements (.is() is a different story)
- filterit( "#posp .firsta", "#posp a:first", 1 );
- filterit( "#posp .firsta", "#posp a:last", 1 );
- filterit( "#posp .firsta", "#posp a:last-child", 0 );
- filterit( "#posp .firsta", "#posp a:even", 1 );
- filterit( "#posp .firsta", "#posp a:odd", 0 );
- filterit( "#posp .firsta", "#posp a:eq(0)", 1 );
- filterit( "#posp .firsta", "#posp a:eq(9)", 0 );
- filterit( "#posp .firsta", "#posp em:eq(0)", 0 );
- filterit( "#posp .firsta", "#posp em:first", 0 );
- filterit( "#posp .firsta", "#posp:first", 0 );
-
- filterit( "#posp .seconda", "#posp a:first", 1 );
- filterit( "#posp .seconda", "#posp em:first", 0 );
- filterit( "#posp .seconda", "#posp a:last", 1 );
- filterit( "#posp .seconda", "#posp a:gt(0)", 0 );
- filterit( "#posp .seconda", "#posp a:lt(5)", 1 );
- filterit( "#posp .seconda", "#posp a:lt(1)", 1 );
- html.remove();
-});
-
test("index()", function() {
expect( 2 );
@@ -227,7 +184,51 @@ test("filter(jQuery)", function() {
var elements = jQuery("#text1");
same( jQuery("#form input").filter(elements).get(), q("text1"), "filter(Element)" );
-})
+});
+
+
+test("filter() with positional selectors", function() {
+ expect(19);
+
+ var html = jQuery('' +
+ '<p id="posp">' +
+ '<a class="firsta" href="#">' +
+ '<em>first</em>' +
+ '</a>' +
+ '<a class="seconda" href="#">' +
+ '<b>test</b>' +
+ '</a>' +
+ '<em></em>' +
+ '</p>').appendTo( "body" ),
+ filterit = function(sel, filter, length) {
+ equal( jQuery( sel ).filter( filter ).length, length, "jQuery( " + sel + " ).filter( " + filter + " )" );
+ };
+
+ filterit( "#posp", "#posp:first", 1);
+ filterit( "#posp", "#posp:eq(2)", 0 );
+ filterit( "#posp", "#posp a:first", 0 );
+
+ // Keep in mind this is within the selection and
+ // not in relation to other elements (.is() is a different story)
+ filterit( "#posp .firsta", "#posp a:first", 1 );
+ filterit( "#posp .firsta", "#posp a:last", 1 );
+ filterit( "#posp .firsta", "#posp a:last-child", 0 );
+ filterit( "#posp .firsta", "#posp a:even", 1 );
+ filterit( "#posp .firsta", "#posp a:odd", 0 );
+ filterit( "#posp .firsta", "#posp a:eq(0)", 1 );
+ filterit( "#posp .firsta", "#posp a:eq(9)", 0 );
+ filterit( "#posp .firsta", "#posp em:eq(0)", 0 );
+ filterit( "#posp .firsta", "#posp em:first", 0 );
+ filterit( "#posp .firsta", "#posp:first", 0 );
+
+ filterit( "#posp .seconda", "#posp a:first", 1 );
+ filterit( "#posp .seconda", "#posp em:first", 0 );
+ filterit( "#posp .seconda", "#posp a:last", 1 );
+ filterit( "#posp .seconda", "#posp a:gt(0)", 0 );
+ filterit( "#posp .seconda", "#posp a:lt(5)", 1 );
+ filterit( "#posp .seconda", "#posp a:lt(1)", 1 );
+ html.remove();
+});
test("closest()", function() {
expect(13);