X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fmanipulation.js;h=88e7d71076ca97936e0bab89fbd4ee270ba039f8;hb=0d5c3a68a092401089c9242bdafdb1b2534feb6a;hp=d8dbca96c7b7c5e9d9d4d017ca2dc47537bae8db;hpb=35951021545a3ae88018fc5ea3bebd1bc7d09c6a;p=jquery.git
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index d8dbca9..88e7d71 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -10,7 +10,7 @@ test("text()", function() {
});
var testWrap = function(val) {
- expect(10);
+ expect(15);
var defaultText = 'Try them out:'
var result = jQuery('#first').wrap(val( '
' )).text();
equals( defaultText, result, 'Check for wrapping of on-the-fly html' );
@@ -40,6 +40,17 @@ var testWrap = function(val) {
j = jQuery("").wrap(val( "" ));
equals( j[0].nodeName.toUpperCase(), "LABEL", "Element is a label" );
equals( j[0].parentNode.nodeName.toUpperCase(), "LI", "Element has been wrapped" );
+
+ // Wrap an element containing a text node
+ j = jQuery("").wrap("
test
");
+ equals( j[0].previousSibling.nodeType, 3, "Make sure the previous node is a text element" );
+ equals( j[0].parentNode.nodeName.toUpperCase(), "DIV", "And that we're in the div element." );
+
+ // Try to wrap an element with multiple elements (should fail)
+ j = jQuery("
").children().wrap("");
+ equals( j[0].parentNode.parentNode.childNodes.length, 1, "There should only be one element wrapping." );
+ equals( j.length, 1, "There should only be one element (no cloning)." );
+ equals( j[0].parentNode.nodeName.toUpperCase(), "P", "The span should be in the paragraph." );
}
test("wrap(String|Element)", function() {