X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=bc1def38928c2509a109e9d1a218245db0f19e7f;hb=d44e9451f789db40e7cb370717258c00dff10edd;hp=f3a3aa3dba9610c5a93865c44b06802c4325215a;hpb=76e3a901530609d3c4a695ccb8a48251445c6861;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index f3a3aa3..bc1def3 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -173,7 +173,19 @@ test("$('html', context)", function() { var $div = $("
"); var $span = $("", $div); - equals($span.length, 1, "Verify a span created with a div context works"); + 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() { @@ -196,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" ); @@ -209,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() { @@ -355,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(); }); }); @@ -551,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; } @@ -1188,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