test runner: extra tests for $.fn.add enabled by [5503] and a small fix for an html...
authorAriel Flesler <aflesler@gmail.com>
Thu, 8 May 2008 17:11:03 +0000 (17:11 +0000)
committerAriel Flesler <aflesler@gmail.com>
Thu, 8 May 2008 17:11:03 +0000 (17:11 +0000)
test/unit/core.js

index ea13de2..d4cc165 100644 (file)
@@ -261,7 +261,7 @@ test("get(Number)", function() {
 });\r
 \r
 test("add(String|Element|Array|undefined)", function() {\r
-       expect(8);\r
+       expect(12);\r
        isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );\r
        isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );\r
        ok( $([]).add($("#form")[0].elements).length >= 13, "Check elements from array" );\r
@@ -280,6 +280,12 @@ test("add(String|Element|Array|undefined)", function() {
        \r
        var notDefined;\r
        equals( $([]).add(notDefined).length, 0, "Check that undefined adds nothing" );\r
+       \r
+       // Added after #2811\r
+       equals( $([]).add([window,document,document.body,document]).length, 3, "Pass an array" );\r
+       equals( $(document).add(document).length, 1, "Check duplicated elements" );\r
+       equals( $(window).add(window).length, 1, "Check duplicated elements using the window" );\r
+       ok( $([]).add( document.getElementById('form') ).length >= 13, "Add a form (adds the elements)" );\r
 });\r
 \r
 test("each(Function)", function() {\r
@@ -1148,6 +1154,9 @@ test("html(String)", function() {
        // using contents will get comments regular, text, and comment nodes\r
        var j = $("#nonnodes").contents();\r
        j.html("<b>bold</b>");\r
+       \r
+       // this is needed, or the expando added by jQuery unique will yield a different html\r
+       j.find('b').removeData();       \r
        equals( j.html().toLowerCase(), "<b>bold</b>", "Check node,textnode,comment with html()" );\r
 \r
        $("#main").html("<select/>");\r
@@ -1651,4 +1660,4 @@ test("$.makeArray", function(){
        equals( $.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );\r
        \r
        ok( $.makeArray(document.getElementById('form')).length >= 13, "Pass makeArray a form (treat as elements)" );\r
-});
\ No newline at end of file
+});\r