X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=bc1def38928c2509a109e9d1a218245db0f19e7f;hb=12ef255ffdb3c2d045ee37beb9419f14d9c30217;hp=a1ebb1ba428d111a38e93a5e7576c98f7d4c00ea;hpb=37902e86b158eaa90f44d0932063d22df3050326;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index a1ebb1b..bc1def3 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -12,14 +12,19 @@ test("Basic requirements", function() { }); test("$()", function() { - expect(5); + expect(4); var main = $("#main"); isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" ); +/* + // disabled since this test was doing nothing. i tried to fix it but i'm not sure + // what the expected behavior should even be. FF returns "\n" for the text node // make sure this is handled - $('

\r\n

'); - ok( true, "Check for \\r and \\n in jQuery()" ); + var crlfContainer = $('

\r\n

'); + var x = crlfContainer.contents().get(0).nodeValue; + equals( x, what???, "Check for \\r and \\n in jQuery()" ); +*/ /* // Disabled until we add this functionality in var pass = true; @@ -148,7 +153,7 @@ var foo = false; test("$('html')", function() { expect(4); - + reset(); foo = false; var s = $("")[0]; @@ -163,6 +168,26 @@ test("$('html')", function() { reset(); }); +test("$('html', context)", function() { + expect(1); + + var $div = $("
"); + var $span = $("", $div); + equals($span.length, 1, "Verify a span created with a div context works, #1763"); +}); + +test("$(selector, xml).text(str) - Loaded via XML document", function() { + expect(2); + stop(); + $.get('data/dashboard.xml', function(xml) { + // tests for #1419 where IE was a problem + equals( $("tab:first", xml).text(), "blabla", "Verify initial text correct" ); + $("tab:first", xml).text("newtext"); + equals( $("tab:first", xml).text(), "newtext", "Verify new text correct" ); + start(); + }); +}); + test("length", function() { expect(1); ok( $("p").length == 6, "Get Number of Elements Found" ); @@ -183,8 +208,8 @@ test("get(Number)", function() { ok( $("p").get(0) == document.getElementById("firstp"), "Get A Single Element" ); }); -test("add(String|Element|Array)", function() { - expect(7); +test("add(String|Element|Array|undefined)", function() { + expect(8); isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" ); isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" ); ok( $([]).add($("#form")[0].elements).length >= 13, "Check elements from array" ); @@ -196,6 +221,9 @@ test("add(String|Element|Array)", function() { var x = $([]).add("

xxx

").add("

xxx

"); ok( x[0].id == "x1", "Check on-the-fly element1" ); ok( x[1].id == "x2", "Check on-the-fly element2" ); + + var notDefined; + equals( $([]).add(notDefined).length, 0, "Check that undefined adds nothing." ); }); test("each(Function)", function() { @@ -342,8 +370,8 @@ if ( !isLocal ) { $('tab', xml).each(function() { titles.push($(this).attr('title')); }); - ok( titles[0] == 'Location', 'attr() in XML context: Check first title' ); - ok( titles[1] == 'Users', 'attr() in XML context: Check second title' ); + equals( titles[0], 'Location', 'attr() in XML context: Check first title' ); + equals( titles[1], 'Users', 'attr() in XML context: Check second title' ); start(); }); }); @@ -380,7 +408,7 @@ test("css(String|Hash)", function() { }); test("css(String, Object)", function() { - expect(18); + expect(19); 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'); @@ -404,6 +432,11 @@ test("css(String, Object)", function() { }); $('#foo').css('opacity', ''); ok( $('#foo').css('opacity') == '1', "Assert opacity is 1 when set to an empty String" ); + // for #1438, IE throws JS error when filter exists but doesn't have opacity in it + if (jQuery.browser.msie) { + $('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');"); + } + equals( $('#foo').css('opacity'), '1', "Assert opacity is 1 when a different filter is set in IE, #1438" ); }); test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", function () { @@ -533,7 +566,7 @@ test("append(String|Element|Array<Element>|jQuery)", function() { reset(); var pass = true; try { - $( $("iframe")[0].contentWindow.document.body ).append("
test
"); + $( $("#iframe")[0].contentWindow.document.body ).append("
test
"); } catch(e) { pass = false; } @@ -1170,9 +1203,28 @@ test("map()", function() { }); test("contents()", function() { - expect(2); + expect(10); equals( $("#ap").contents().length, 9, "Check element contents" ); ok( $("#iframe").contents()[0], "Check existance of IFrame document" ); - // Disabled, randomly fails - //ok( $("#iframe").contents()[0].body, "Check existance of IFrame body" ); + var ibody = $("#loadediframe").contents()[0].body; + ok( ibody, "Check existance of IFrame body" ); + + equals( $("span", ibody).text(), "span text", "Find span in IFrame and check its text" ); + + $(ibody).append("
init text
"); + equals( $("div", ibody).length, 2, "Check the original div and the new div are in IFrame" ); + + equals( $("div:last", ibody).text(), "init text", "Add text to div in IFrame" ); + + $("div:last", ibody).text("div text"); + equals( $("div:last", ibody).text(), "div text", "Add text to div in IFrame" ); + + $("div:last", ibody).remove(); + equals( $("div", ibody).length, 1, "Delete the div and check only one div left in IFrame" ); + + equals( $("div", ibody).text(), "span text", "Make sure the correct div is still left after deletion in IFrame" ); + + $("", ibody).append("").appendTo(ibody); + $("table", ibody).remove(); + equals( $("div", ibody).length, 1, "Check for JS error on add and delete of a table in IFrame" ); });
cell