Added tests for comma-separated expressions in filter, not, parent, parents, siblings...
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Tue, 9 Jan 2007 16:14:22 +0000 (16:14 +0000)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Tue, 9 Jan 2007 16:14:22 +0000 (16:14 +0000)
src/jquery/coreTest.js

index 6efaa84..7466c4c 100644 (file)
@@ -285,18 +285,6 @@ test("clone()", function() {
        ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' );\r
 });\r
 \r
-test("filter()", function() {\r
-       isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );\r
-       isSet( $("p").filter(["#ap", "#sndp"]).get(), q("ap", "sndp"), "filter(Array&lt;String&gt;)" );\r
-       isSet( $("p").filter(function() { return !$("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );\r
-});\r
-\r
-test("not(String)", function() {\r
-       ok($("#main > p#ap > a").not("#google").length == 2, "not('selector')")\r
-       // TODO: Comma-based selector\r
-       //isSet( $("p").not("#ap, #sndp").get(), q("firstp", "en", "sap", "first", "result"), "not('selector, selector')" );\r
-});\r
-\r
 test("is(String)", function() {\r
        expect(22);\r
        ok( $('#form').is('form'), 'Check for element: A form must be a form' );\r
@@ -375,37 +363,61 @@ test("html(String)", function() {
        ok( pass, "Set HTML" );\r
 });\r
 \r
+test("filter()", function() {\r
+       expect(5);\r
+       isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );\r
+       isSet( $("p").filter(["#ap", "#sndp"]).get(), q("ap", "sndp"), "filter(Array&lt;String&gt;)" );\r
+       isSet( $("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );\r
+       isSet( $("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );\r
+       isSet( $("p").filter(function() { return !$("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );\r
+});\r
+\r
+test("not(String)", function() {\r
+       expect(2);\r
+       ok( $("#main > p#ap > a").not("#google").length == 2, "not('selector')" );\r
+       isSet( $("p").not("#ap, #sndp").get(), q("firstp", "en", "sap", "first", "result"), "not('selector, selector')" );\r
+});\r
+\r
+\r
 test("siblings([String])", function() {\r
-       expect(3);\r
+       expect(4);\r
        isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );\r
        isSet( $("#sndp").siblings("[code]").get(), q("sap"), "Check for filtered siblings (has code child element)" ); \r
        isSet( $("#sndp").siblings("[a]").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );\r
+       isSet( $("#foo").siblings("form, b").get(), q("form", "floatTest"), "Check for multiple filters" );\r
 });\r
 \r
 test("children([String])", function() {\r
-       expect(2);\r
+       expect(3);\r
        isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" );\r
        isSet( $("#foo").children("[code]").get(), q("sndp", "sap"), "Check for filtered children" );\r
+       isSet( $("#foo").children("#en, #sap").get(), q("en", "sap"), "Check for multiple filters" );\r
 });\r
 \r
 test("parent[s]([String])", function() {\r
+       expect(8);\r
        ok( $("#groups").parent()[0].id == "ap", "Simple parent check" );\r
        ok( $("#groups").parent("p")[0].id == "ap", "Filtered parent check" );\r
        ok( $("#groups").parent("div").length == 0, "Filtered parent check, no match" );\r
+       ok( $("#groups").parent("div, p")[0].id == "ap", "Check for multiple filters" );\r
        \r
        ok( $("#groups").parents()[0].id == "ap", "Simple parents check" );\r
        ok( $("#groups").parents("p")[0].id == "ap", "Filtered parents check" );\r
        ok( $("#groups").parents("div")[0].id == "main", "Filtered parents check2" );\r
+       isSet( $("#groups").parents("p, div").get(), q("ap", "main"), "Check for multiple filters" );\r
 });\r
 \r
 test("next/prev([String])", function() {\r
+       expect(8);\r
        ok( $("#ap").next()[0].id == "foo", "Simple next check" );\r
        ok( $("#ap").next("div")[0].id == "foo", "Filtered next check" );\r
        ok( $("#ap").next("p").length == 0, "Filtered next check, no match" );\r
+       ok( $("#ap").next("div, p")[0].id == "foo", "Multiple filters" );\r
        \r
        ok( $("#foo").prev()[0].id == "ap", "Simple prev check" );\r
        ok( $("#foo").prev("p")[0].id == "ap", "Filtered prev check" );\r
        ok( $("#foo").prev("div").length == 0, "Filtered prev check, no match" );\r
+       ok( $("#foo").prev("p, div")[0].id == "ap", "Multiple filters" );\r
 });\r
 \r
 test("show()", function() {\r