jquery fx: removing a needless comment after the last commit.
[jquery.git] / test / unit / core.js
index 2827476..bfaceca 100644 (file)
@@ -121,10 +121,10 @@ test("isFunction", function() {
 \r
        // Check built-ins\r
        // Safari uses "(Internal Function)"\r
-       ok( jQuery.isFunction(String), "String Function" );\r
-       ok( jQuery.isFunction(Array), "Array Function" );\r
-       ok( jQuery.isFunction(Object), "Object Function" );\r
-       ok( jQuery.isFunction(Function), "Function Function" );\r
+       ok( jQuery.isFunction(String), "String Function("+String+")" );\r
+       ok( jQuery.isFunction(Array), "Array Function("+Array+")" );\r
+       ok( jQuery.isFunction(Object), "Object Function("+Object+")" );\r
+       ok( jQuery.isFunction(Function), "Function Function("+Function+")" );\r
 \r
        // When stringified, this could be misinterpreted\r
        var mystr = "function";\r
@@ -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
@@ -279,7 +279,13 @@ test("add(String|Element|Array|undefined)", function() {
        equals( x[1].id, "x2", "Check on-the-fly element2" );\r
        \r
        var notDefined;\r
-       equals( $([]).add(notDefined).length, 0, "Check that undefined adds nothing." );\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
@@ -294,16 +300,23 @@ test("each(Function)", function() {
 });\r
 \r
 test("index(Object)", function() {\r
-       expect(8);\r
-       equals( $([window, document]).index(window), 0, "Check for index of elements" );\r
-       equals( $([window, document]).index(document), 1, "Check for index of elements" );\r
-       var inputElements = $('#radio1,#radio2,#check1,#check2');\r
+       expect(10);\r
+       \r
+       var elements = $([window, document]),\r
+               inputElements = $('#radio1,#radio2,#check1,#check2');\r
+       \r
+       equals( elements.index(window), 0, "Check for index of elements" );\r
+       equals( elements.index(document), 1, "Check for index of elements" );\r
        equals( inputElements.index(document.getElementById('radio1')), 0, "Check for index of elements" );\r
        equals( inputElements.index(document.getElementById('radio2')), 1, "Check for index of elements" );\r
        equals( inputElements.index(document.getElementById('check1')), 2, "Check for index of elements" );\r
        equals( inputElements.index(document.getElementById('check2')), 3, "Check for index of elements" );\r
        equals( inputElements.index(window), -1, "Check for not found index" );\r
        equals( inputElements.index(document), -1, "Check for not found index" );\r
+       \r
+       // enabled since [5500]\r
+       equals( elements.index( elements ), 0, "Pass in a jQuery object" );\r
+       equals( elements.index( elements.eq(1) ), 1, "Pass in a jQuery object" );\r
 });\r
 \r
 test("attr(String)", function() {\r
@@ -361,13 +374,15 @@ test("attr(Hash)", function() {
 \r
 test("attr(String, Object)", function() {\r
        expect(17);\r
-       var div = $("div");\r
-       div.attr("foo", "bar");\r
-       var pass = true;\r
+       var div = $("div").attr("foo", "bar");\r
+               fail = false;\r
        for ( var i = 0; i < div.size(); i++ ) {\r
-               if ( div.get(i).getAttribute('foo') != "bar" ) pass = false;\r
+               if ( div.get(i).getAttribute('foo') != "bar" ){\r
+                       fail = i;\r
+                       break;\r
+               }\r
        }\r
-       ok( pass, "Set Attribute" );\r
+       equals( fail, false, "Set Attribute, the #"+fail+" element didn't get the attribute 'foo'" );\r
 \r
        ok( $("#foo").attr({"width": null}), "Try to set an attribute to nothing" );    \r
        \r
@@ -399,7 +414,7 @@ test("attr(String, Object)", function() {
 \r
        j.attr("name", "attrvalue");\r
        equals( j.attr("name"), "attrvalue", "Check node,textnode,comment for attr" );\r
-       j.removeAttr("name")\r
+       j.removeAttr("name");\r
 \r
        reset();\r
 \r
@@ -1148,6 +1163,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
@@ -1619,7 +1637,7 @@ test("contents()", function() {
 });\r
 \r
 test("$.makeArray", function(){\r
-       expect(14);\r
+       expect(15);\r
        \r
        equals( $.makeArray($('html>*'))[0].nodeName, "HEAD", "Pass makeArray a jQuery object" );\r
        \r
@@ -1649,4 +1667,6 @@ test("$.makeArray", function(){
        equals( $.makeArray(window)[0], window, "Pass makeArray the window" );\r
        \r
        equals( $.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );\r
-});
\ No newline at end of file
+       \r
+       ok( $.makeArray(document.getElementById('form')).length >= 13, "Pass makeArray a form (treat as elements)" );\r
+});\r