Added a fix, and tests, for appending empty sets of elements/strings.
[jquery.git] / src / jquery / coreTest.js
index ed7b52b..f736d4d 100644 (file)
@@ -192,7 +192,7 @@ test("wrap(String|Element)", function() {
 });\r
 \r
 test("append(String|Element|Array<Element>|jQuery)", function() {\r
-       expect(5);\r
+       expect(9);\r
        var defaultText = 'Try them out:'\r
        var result = $('#first').append('<b>buga</b>');\r
        ok( result.text() == defaultText + 'buga', 'Check if text appending works' );\r
@@ -212,6 +212,15 @@ test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {
        expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
        $('#sap').append($("#first, #yahoo"));\r
        ok( expected == $('#sap').text(), "Check for appending of jQuery object" );\r
+\r
+       reset();\r
+       $("#sap").append( 5 );\r
+       ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );\r
+\r
+       reset();\r
+       ok( $("#sap").append([]), "Check for appending an empty array." );\r
+       ok( $("#sap").append(""), "Check for appending an empty string." );\r
+       ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );\r
 });\r
 \r
 test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
@@ -472,9 +481,8 @@ test("html(String)", function() {
 });\r
 \r
 test("filter()", function() {\r
-       expect(5);\r
+       expect(4);\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
@@ -483,7 +491,7 @@ test("filter()", function() {
 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
+       isSet( $("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );\r
 });\r
 \r
 \r
@@ -644,7 +652,7 @@ test("empty()", function() {
 \r
 test("eq(), gt(), lt(), contains()", function() {\r
        ok( $("#ap a").eq(1)[0].id == "groups", "eq()" );\r
-       ok( $("#ap a").gt(1).get(), q("groups", "anchor1", "mark"), "gt()" );\r
-       ok( $("#ap a").lt(2).get(), q("google", "groups", "anchor1"), "lt()" );\r
-       ok( $("#foo a").contains("log").get(), q("anchor2", "simon"), "contains()" );\r
-});
\ No newline at end of file
+       isSet( $("#ap a").gt(0).get(), q("groups", "anchor1", "mark"), "gt()" );\r
+       isSet( $("#ap a").lt(3).get(), q("google", "groups", "anchor1"), "lt()" );\r
+       isSet( $("#foo a").contains("log").get(), q("anchor2", "simon"), "contains()" );\r
+});\r