X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2FcoreTest.js;h=4370e9da82391c08b696eab9a66cf3354180b406;hb=26034c4a2985c18c6c702f1c609001f859e33654;hp=aa2932bf3c2fac8b630d398178c8afcf065a228b;hpb=7d0a84193f539d85267d1458aba35a42d7dbd03b;p=jquery.git diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index aa2932b..4370e9d 100644 --- a/src/jquery/coreTest.js +++ b/src/jquery/coreTest.js @@ -20,7 +20,7 @@ test("$()", function() { }); test("isFunction", function() { - expect(20); + expect(21); // Make sure that false values return false ok( !jQuery.isFunction(), "No Value" ); @@ -79,6 +79,15 @@ test("isFunction", function() { document.body.removeChild( input ); + var a = document.createElement("a"); + a.href = "some-function"; + document.body.appendChild( a ); + + // This serializes with the word 'function' in it + ok( !jQuery.isFunction(a), "Anchor Element" ); + + document.body.removeChild( a ); + // Recursive function calls have lengths and array-like properties function callme(callback){ function fn(response){ @@ -231,7 +240,7 @@ if ( location.protocol != "file:" ) { } test("css(String|Hash)", function() { - expect(8); + expect(19); ok( $('#main').css("display") == 'none', 'Check for css property "display"'); @@ -249,10 +258,19 @@ test("css(String|Hash)", function() { ok( $('#floatTest').css('float') == 'right', 'Modified CSS float using "float": Assert float is right'); $('#floatTest').css({'font-size': '30px'}); ok( $('#floatTest').css('font-size') == '30px', 'Modified CSS font-size: Assert font-size is 30px'); + + $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) { + $('#foo').css({opacity: n}); + ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a String" ); + $('#foo').css({opacity: parseFloat(n)}); + ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a Number" ); + }); + $('#foo').css({opacity: ''}); + ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" ); }); test("css(String, Object)", function() { - expect(7); + expect(18); ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible'); $('#foo').css('display', 'none'); ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden'); @@ -267,6 +285,15 @@ test("css(String, Object)", function() { ok( $('#floatTest').css('float') == 'left', 'Modified CSS float using "float": Assert float is left'); $('#floatTest').css('font-size', '20px'); ok( $('#floatTest').css('font-size') == '20px', 'Modified CSS font-size: Assert font-size is 20px'); + + $.each("0,0.25,0.5,0.75,1".split(','), function(i, n) { + $('#foo').css('opacity', n); + ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a String" ); + $('#foo').css('opacity', parseFloat(n)); + ok( $('#foo').css('opacity') == n, "Assert opacity is " + n + " as a Number" ); + }); + $('#foo').css('opacity', ''); + ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" ); }); test("text()", function() {