X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=sidebyside;f=test%2Funit%2Fcore.js;h=fccf8e4590b4867355791b6b3ad8be12b87d138b;hb=0a794ed5fc651dbcce7eb9ff780656ea31c996d5;hp=ea13de2c71c8f62fdb19610c0b6681ff941042d8;hpb=9f0c0cfec5412dee5d7843e0b0b130d58038853c;p=jquery.git
diff --git a/test/unit/core.js b/test/unit/core.js
index ea13de2..fccf8e4 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -261,7 +261,7 @@ test("get(Number)", function() {
});
test("add(String|Element|Array|undefined)", function() {
- expect(8);
+ expect(12);
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" );
@@ -280,6 +280,12 @@ test("add(String|Element|Array|undefined)", function() {
var notDefined;
equals( $([]).add(notDefined).length, 0, "Check that undefined adds nothing" );
+
+ // Added after #2811
+ equals( $([]).add([window,document,document.body,document]).length, 3, "Pass an array" );
+ equals( $(document).add(document).length, 1, "Check duplicated elements" );
+ equals( $(window).add(window).length, 1, "Check duplicated elements using the window" );
+ ok( $([]).add( document.getElementById('form') ).length >= 13, "Add a form (adds the elements)" );
});
test("each(Function)", function() {
@@ -294,16 +300,23 @@ test("each(Function)", function() {
});
test("index(Object)", function() {
- expect(8);
- equals( $([window, document]).index(window), 0, "Check for index of elements" );
- equals( $([window, document]).index(document), 1, "Check for index of elements" );
- var inputElements = $('#radio1,#radio2,#check1,#check2');
+ expect(10);
+
+ var elements = $([window, document]),
+ inputElements = $('#radio1,#radio2,#check1,#check2');
+
+ equals( elements.index(window), 0, "Check for index of elements" );
+ equals( elements.index(document), 1, "Check for index of elements" );
equals( inputElements.index(document.getElementById('radio1')), 0, "Check for index of elements" );
equals( inputElements.index(document.getElementById('radio2')), 1, "Check for index of elements" );
equals( inputElements.index(document.getElementById('check1')), 2, "Check for index of elements" );
equals( inputElements.index(document.getElementById('check2')), 3, "Check for index of elements" );
equals( inputElements.index(window), -1, "Check for not found index" );
equals( inputElements.index(document), -1, "Check for not found index" );
+
+ // enabled since [5500]
+ equals( elements.index( elements ), 0, "Pass in a jQuery object" );
+ equals( elements.index( elements.eq(1) ), 1, "Pass in a jQuery object" );
});
test("attr(String)", function() {
@@ -1148,6 +1161,9 @@ test("html(String)", function() {
// using contents will get comments regular, text, and comment nodes
var j = $("#nonnodes").contents();
j.html("bold");
+
+ // this is needed, or the expando added by jQuery unique will yield a different html
+ j.find('b').removeData();
equals( j.html().toLowerCase(), "bold", "Check node,textnode,comment with html()" );
$("#main").html("");
@@ -1651,4 +1667,4 @@ test("$.makeArray", function(){
equals( $.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" );
ok( $.makeArray(document.getElementById('form')).length >= 13, "Pass makeArray a form (treat as elements)" );
-});
\ No newline at end of file
+});