X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fattributes.js;h=c6007aacc8ab21df33757f1b2e970199baa3af18;hb=b03416954d8033e641bd658fb18631699db6cc51;hp=3326dfe890c8c6e4cfab1bae5b7dbd6269cd5d5d;hpb=0636dffc2481c14368464a22ffa1bd8017da2a26;p=jquery.git
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index 3326dfe..c6007aa 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -98,15 +98,18 @@ test("attr(Hash)", function() {
});
test("attr(String, Object)", function() {
- expect(23);
+ expect(24);
+
var div = jQuery("div").attr("foo", "bar"),
fail = false;
+
for ( var i = 0; i < div.size(); i++ ) {
if ( div.get(i).getAttribute('foo') != "bar" ){
fail = i;
break;
}
}
+
equals( fail, false, "Set Attribute, the #"+fail+" element didn't get the attribute 'foo'" );
// Fails on IE since recent changes to .attr()
@@ -114,6 +117,8 @@ test("attr(String, Object)", function() {
jQuery("#name").attr('name', 'something');
equals( jQuery("#name").attr('name'), 'something', 'Set name attribute' );
+ jQuery("#name").attr('name', null);
+ equals( jQuery("#name").attr('title'), '', 'Remove name attribute' );
jQuery("#check2").attr('checked', true);
equals( document.getElementById('check2').checked, true, 'Set checked attribute' );
jQuery("#check2").attr('checked', false);
@@ -302,7 +307,7 @@ test("removeAttr(String)", function() {
});
test("val()", function() {
- expect(20);
+ expect(23);
document.getElementById('text1').value = "bla";
equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" );
@@ -337,6 +342,14 @@ test("val()", function() {
jQuery('#select4').attr('disabled', true);
same( jQuery('#select4').val(), ['2', '3'], 'Call val() on disabled multiple="multiple" select' );
+ equals( jQuery('#select5').val(), "3", "Check value on ambiguous select." );
+
+ jQuery('#select5').val(1);
+ equals( jQuery('#select5').val(), "1", "Check value on ambiguous select." );
+
+ jQuery('#select5').val(3);
+ equals( jQuery('#select5').val(), "3", "Check value on ambiguous select." );
+
var checks = jQuery("").appendTo("#form");
same( checks.serialize(), "", "Get unchecked values." );
@@ -396,7 +409,19 @@ test("val(String/Number)", function() {
test("val(Function)", function() {
testVal(functionReturningObj);
-})
+});
+
+test( "val(Array of Numbers) (Bug #7123)", function() {
+ expect(4);
+ jQuery('#form').append('');
+ var elements = jQuery('input[name=arrayTest]').val([ 1, 2 ]);
+ ok( elements[0].checked, "First element was checked" );
+ ok( elements[1].checked, "Second element was checked" );
+ ok( !elements[2].checked, "Third element was unchecked" );
+ ok( !elements[3].checked, "Fourth element remained unchecked" );
+
+ elements.remove();
+});
test("val(Function) with incoming value", function() {
expect(10);