X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fmanipulation.js;h=b9cb35dedd1680da037669dbaa2c75b983eedc7d;hb=69e6e53555f21f07b534f1169298f7b33011bb4b;hp=1b99b66701cb726ab6ded1577eb55e433c3d67a5;hpb=70b9aed422c34047299fe6e8934902fae61f2a3e;p=jquery.git diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 1b99b66..b9cb35d 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -116,6 +116,37 @@ test("wrapInner(String|Element)", function() { // testWrapInner(functionReturningObj) // }) +var testUnwrap = function() { + expect(9); + + jQuery("body").append(' '); + + var abcd = jQuery('#unwrap1 > span, #unwrap2 > span').get(), + abcdef = jQuery('#unwrap span').get(); + + equals( jQuery('#unwrap1 span, #unwrap2 span:first').unwrap().length, 3, 'make #unwrap1 and #unwrap2 go away' ); + same( jQuery('#unwrap > span').get(), abcd, 'all four spans should still exist' ); + + same( jQuery('#unwrap3 span').unwrap().get(), jQuery('#unwrap3 > span').get(), 'make all b in #unwrap3 go away' ); + + same( jQuery('#unwrap3 span').unwrap().get(), jQuery('#unwrap > span.unwrap3').get(), 'make #unwrap3 go away' ); + + same( jQuery('#unwrap').children().get(), abcdef, '#unwrap only contains 6 child spans' ); + + same( jQuery('#unwrap > span').unwrap().get(), jQuery('body > span.unwrap').get(), 'make the 6 spans become children of body' ); + + same( jQuery('body > span.unwrap').unwrap().get(), jQuery('body > span.unwrap').get(), 'can\'t unwrap children of body' ); + same( jQuery('body > span.unwrap').unwrap().get(), abcdef, 'can\'t unwrap children of body' ); + + same( jQuery('body > span.unwrap').get(), abcdef, 'body contains 6 .unwrap child spans' ); + + jQuery('body > span.unwrap').remove(); +} + +test("unwrap()", function() { + testUnwrap(); +}); + var testAppend = function(valueObj) { expect(21); var defaultText = 'Try them out:'