X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fmanipulation.js;h=00984168ca385de088031b221f029fc9128687fa;hb=b0306cc3a662edf9675cd16081ff0e81b2a0f587;hp=465686fdfd7b3d06fcd9556ab862a2844591b337;hpb=173c1477ae6efc4c2eeb7131ba0646c4e1323975;p=jquery.git diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 465686f..0098416 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:' @@ -340,7 +371,7 @@ var testBefore = function(val) { jQuery('#yahoo').before(val( jQuery("#first, #mark") )); equals( expected, jQuery('#en').text(), "Insert jQuery before" ); - var set = jQuery("
").before(val("test")); + var set = jQuery("
").before("test"); equals( set[0].nodeName.toLowerCase(), "span", "Insert the element before the disconnected node." ); equals( set.length, 2, "Insert the element before the disconnected node." ); } @@ -396,7 +427,7 @@ var testAfter = function(val) { jQuery('#yahoo').after(val( jQuery("#first, #mark") )); equals( expected, jQuery('#en').text(), "Insert jQuery after" ); - var set = jQuery("
").after(val("test")); + var set = jQuery("
").after("test"); equals( set[1].nodeName.toLowerCase(), "span", "Insert the element after the disconnected node." ); equals( set.length, 2, "Insert the element after the disconnected node." ); }; @@ -571,7 +602,7 @@ test("val()", function() { equals( jQuery('#select2').val(), '3', 'Call val() on a single="single" select' ); - isSet( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' ); + same( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' ); equals( jQuery('#option3c').val(), '2', 'Call val() on a option element with value' ); @@ -626,7 +657,7 @@ var testHtml = function(valueObj) { } ok( pass, "Set HTML" ); - window.debug = false; + delete window.debug; reset(); // using contents will get comments regular, text, and comment nodes