Discontinued the test for $(form.elements).
[jquery.git] / test / unit / core.js
index 7213010..a5a59c3 100644 (file)
@@ -217,6 +217,7 @@ test("$('html', context)", function() {
        equals($span.length, 1, "Verify a span created with a div context works, #1763");
 });
 
+if ( !isLocal ) {
 test("$(selector, xml).text(str) - Loaded via XML document", function() {
        expect(2);
        stop();
@@ -228,6 +229,7 @@ test("$(selector, xml).text(str) - Loaded via XML document", function() {
                start();
        });
 });
+}
 
 test("length", function() {
        expect(1);
@@ -250,11 +252,14 @@ test("get(Number)", function() {
 });
 
 test("add(String|Element|Array|undefined)", function() {
-       expect(9);
+       expect(8);
        isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );
        isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );
        ok( $([]).add($("#form")[0].elements).length >= 13, "Check elements from array" );
-       equals( $([]).add($("#form")[0].elements).length, $($("#form")[0].elements).length, "Array in constructor must equals array in add()" );
+
+       // For the time being, we're discontinuing support for $(form.elements) since it's ambiguous in IE
+       // use $([]).add(form.elements) instead.
+       //equals( $([]).add($("#form")[0].elements).length, $($("#form")[0].elements).length, "Array in constructor must equals array in add()" );
        
        var x = $([]).add($("<p id='x1'>xxx</p>")).add($("<p id='x2'>xxx</p>"));
        ok( x[0].id == "x1", "Check on-the-fly element1" );
@@ -950,7 +955,7 @@ test("find(String)", function() {
 });
 
 test("clone()", function() {
-       expect(6);
+       expect(4);
        ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' );
        var clone = $('#yahoo').clone();
        ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' );
@@ -958,7 +963,11 @@ test("clone()", function() {
        // using contents will get comments regular, text, and comment nodes
        var cl = $("#nonnodes").contents().clone();
        ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" );
+});
 
+if (!isLocal) {
+test("clone() on XML nodes", function() {
+       expect(2);
        stop();
        $.get("data/dashboard.xml", function (xml) {
                var root = $(xml.documentElement).clone();
@@ -969,6 +978,7 @@ test("clone()", function() {
                start();
        });
 });
+}
 
 test("is(String)", function() {
        expect(26);
@@ -1314,7 +1324,7 @@ test("text(String)", function() {
 });
 
 test("$.each(Object,Function)", function() {
-       expect(8);
+       expect(12);
        $.each( [0,1,2], function(i, n){
                ok( i == n, "Check array iteration" );
        });
@@ -1326,6 +1336,19 @@ test("$.each(Object,Function)", function() {
        $.each( { name: "name", lang: "lang" }, function(i, n){
                ok( i == n, "Check object iteration" );
        });
+
+        var total = 0;
+        jQuery.each([1,2,3], function(i,v){ total += v; });
+        ok( total == 6, "Looping over an array" );
+        total = 0;
+        jQuery.each([1,2,3], function(i,v){ total += v; if ( i == 1 ) return false; });
+        ok( total == 3, "Looping over an array, with break" );
+        total = 0;
+        jQuery.each({"a":1,"b":2,"c":3}, function(i,v){ total += v; });
+        ok( total == 6, "Looping over an object" );
+        total = 0;
+        jQuery.each({"a":3,"b":3,"c":3}, function(i,v){ total += v; return false; });
+        ok( total == 3, "Looping over an object, with break" );
 });
 
 test("$.prop", function() {