X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fattributes.js;h=3eb2474dda0184451fe976ff6501d89d2b989b6c;hb=e2d0671f4c260f2bd97fe76269188d5d6fc19dcd;hp=de7754b8a5482f2e01e96c658c8d520b89d8b914;hpb=c7c067723006b0dfbb123c1a36885580a587d091;p=jquery.git diff --git a/test/unit/attributes.js b/test/unit/attributes.js index de7754b..3eb2474 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -3,8 +3,33 @@ module("attributes"); var bareObj = function(value) { return value; }; var functionReturningObj = function(value) { return (function() { return value; }); }; +test("jQuery.props: itegrity test", function() { + + expect(1); + + // This must be maintained and equal jQuery.props + // Ensure that accidental or erroneous property + // overwrites don't occur + // This is simply for better code coverage and future proofing. + var propsShouldBe = { + "for": "htmlFor", + "class": "className", + readonly: "readOnly", + maxlength: "maxLength", + cellspacing: "cellSpacing", + rowspan: "rowSpan", + colspan: "colSpan", + tabindex: "tabIndex", + usemap: "useMap", + frameborder: "frameBorder" + }; + + same(propsShouldBe, jQuery.props, "jQuery.props passes integrity check"); + +}); + test("attr(String)", function() { - expect(30); + expect(31); // This one sometimes fails randomly ?! equals( jQuery('#text1').attr('value'), "Test", 'Check for value attribute' ); @@ -65,6 +90,8 @@ test("attr(String)", function() { ok( jQuery("
").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." ); ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." ); + + equals( jQuery(document).attr("nodeName"), "#document", "attr works correctly on document nodes (bug #7451)." ); }); if ( !isLocal ) { @@ -307,7 +334,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" ); @@ -342,6 +369,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." ); @@ -401,7 +436,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); @@ -492,7 +539,7 @@ test("addClass(Function)", function() { }); test("addClass(Function) with incoming value", function() { - expect(41); + expect(45); var div = jQuery("div"), old = div.map(function(){ return jQuery(this).attr("class"); @@ -565,7 +612,7 @@ test("removeClass(Function) - simple", function() { }); test("removeClass(Function) with incoming value", function() { - expect(41); + expect(45); var $divs = jQuery('div').addClass("test"), old = $divs.map(function(){ return jQuery(this).attr("class");