X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2FcoreTest.js;h=5c982ee225b56eb6edb30c58d9d9686b8f785ca4;hb=0f7c89cd97de6ca644a834a119dda1e057fd724e;hp=aa2932bf3c2fac8b630d398178c8afcf065a228b;hpb=7d0a84193f539d85267d1458aba35a42d7dbd03b;p=jquery.git diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index aa2932b..5c982ee 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') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" ); + $('#foo').css({opacity: parseFloat(n)}); + ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(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') == parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" ); + $('#foo').css('opacity', parseFloat(n)); + ok( $('#foo').css('opacity') == parseFloat(n), "Assert opacity is " + parseFloat(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() { @@ -289,7 +316,7 @@ test("wrap(String|Element)", function() { }); test("append(String|Element|Array<Element>|jQuery)", function() { - expect(11); + expect(12); var defaultText = 'Try them out:' var result = $('#first').append('buga'); ok( result.text() == defaultText + 'buga', 'Check if text appending works' ); @@ -326,6 +353,16 @@ test("append(String|Element|Array<Element>|jQuery)", function() { reset(); $("#sap").append(document.getElementById('form')); ok( $("#sap>form").size() == 1, "Check for appending a form" ); // Bug #910 + + reset(); + var pass = true; + try { + $( $("iframe")[0].contentWindow.document.body ).append("
test
"); + } catch(e) { + pass = false; + } + + ok( pass, "Test for appending a DOM node to the contents of an IFrame" ); });