X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fattributes.js;h=21d3d94bcb96a23cc5ad952820537223ad89fdfc;hb=8effe3a7dee91c833cc1774646da9d743600c64c;hp=70ae50dbda77870571ab18f213f368060d19e782;hpb=e76ba32cebc26108e15b2e0e03c5152624c1bad9;p=jquery.git diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 70ae50d..21d3d94 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -4,7 +4,7 @@ var bareObj = function(value) { return value; }; var functionReturningObj = function(value) { return (function() { return value; }); }; test("attr(String)", function() { - expect(28); + expect(30); // This one sometimes fails randomly ?! equals( jQuery('#text1').attr('value'), "Test", 'Check for value attribute' ); @@ -61,6 +61,9 @@ test("attr(String)", function() { select.appendChild( optgroup ); equals( jQuery(option).attr("selected"), true, "Make sure that a single option is selected, even when in an optgroup." ); + + 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." ); }); if ( !isLocal ) { @@ -435,7 +438,7 @@ test("val(Function) with incoming value", function() { }); var testAddClass = function(valueObj) { - expect(2); + expect(5); var div = jQuery("div"); div.addClass( valueObj("test") ); var pass = true; @@ -448,6 +451,19 @@ var testAddClass = function(valueObj) { var j = jQuery("#nonnodes").contents(); j.addClass( valueObj("asdf") ); ok( j.hasClass("asdf"), "Check node,textnode,comment for addClass" ); + + div = jQuery("
"); + + div.addClass( valueObj("test") ); + equals( div.attr("class"), "test", "Make sure there's no extra whitespace." ); + + div.attr("class", " foo"); + div.addClass( valueObj("test") ); + equals( div.attr("class"), "foo test", "Make sure there's no extra whitespace." ); + + div.attr("class", "foo"); + div.addClass( valueObj("bar baz") ); + equals( div.attr("class"), "foo bar baz", "Make sure there isn't too much trimming." ); }; test("addClass(String)", function() { @@ -466,8 +482,10 @@ test("addClass(Function) with incoming value", function() { }); div.addClass(function(i, val) { - equals( val, old[i], "Make sure the incoming value is correct." ); - return "test"; + if ( this.id !== "_firebugConsole" ) { + equals( val, old[i], "Make sure the incoming value is correct." ); + return "test"; + } }); var pass = true; @@ -537,8 +555,10 @@ test("removeClass(Function) with incoming value", function() { }); $divs.removeClass(function(i, val) { - equals( val, old[i], "Make sure the incoming value is correct." ); - return "test"; + if ( this.id !== "_firebugConsole" ) { + equals( val, old[i], "Make sure the incoming value is correct." ); + return "test"; + } }); ok( !$divs.is('.test'), "Remove Class" );