X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=5f2f81af859d1fe874c27926810c2acabff0a69b;hb=be4a8c32ac77c3b1cdf1b598943b23bdb3119467;hp=f40f3b02ec8c58ddd302bdd891048091b49f6127;hpb=d938c6bbd6b220f122c50f5f828b8f0cd818c168;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index f40f3b0..5f2f81a 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" ); @@ -342,8 +367,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(); }); }); @@ -538,7 +563,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; } @@ -1175,9 +1200,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