From: Oleg Gaidarenko Date: Tue, 22 Dec 2015 18:54:09 +0000 (+0300) Subject: Wrap: correct tests length X-Git-Tag: 1.12.0~25 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f21d43a1146256379d7f5b7cb537ed59aeebdeb4;p=jquery.git Wrap: correct tests length --- diff --git a/test/unit/wrap.js b/test/unit/wrap.js index 2348f2d47..431b7af03 100644 --- a/test/unit/wrap.js +++ b/test/unit/wrap.js @@ -332,46 +332,90 @@ QUnit.test( "wrapInner(Function) returns Element", function( assert ) { var num, val = manipulationFunctionReturningObj, - div = jQuery("
"); + div = jQuery( "
" ); - num = jQuery("#first").children().length; - jQuery("#first").wrapInner( val(document.getElementById("empty")) ); - equal( jQuery("#first").children().length, 1, "Only one child" ); - ok( jQuery("#first").children().is("#empty"), "Verify Right Element" ); - equal( jQuery("#first").children().children().length, num, "Verify Elements Intact" ); + num = jQuery( "#first" ).children().length; + jQuery( "#first" ).wrapInner( val( document.getElementById( "empty" ) ) ); + equal( jQuery( "#first" ).children().length, 1, "Only one child" ); + ok( jQuery( "#first" ).children().is( "#empty" ), "Verify Right Element" ); + equal( jQuery( "#first" ).children().children().length, num, "Verify Elements Intact" ); - div.wrapInner( val("") ); + div.wrapInner( val( "" ) ); equal( div.children().length, 1, "The contents were wrapped." ); equal( div.children()[ 0 ].nodeName.toLowerCase(), "span", "A span was inserted." ); -}); +} ); test( "unwrap()", function() { expect( 9 ); - jQuery("body").append(" "); + jQuery( "body" ).append( + " " + ); - var abcd = jQuery("#unwrap1 > span, #unwrap2 > span").get(), - abcdef = jQuery("#unwrap span").get(); + var abcd = jQuery( "#unwrap1 > span, #unwrap2 > span" ).get(), + abcdef = jQuery( "#unwrap span" ).get(); - equal( jQuery("#unwrap1 span").add("#unwrap2 span:first-child").unwrap().length, 3, "make #unwrap1 and #unwrap2 go away" ); - deepEqual( jQuery("#unwrap > span").get(), abcd, "all four spans should still exist" ); + equal( + jQuery( "#unwrap1 span" ).add( "#unwrap2 span:first-child" ).unwrap().length, + 3, + "make #unwrap1 and #unwrap2 go away" + ); - deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap3 > span").get(), "make all b in #unwrap3 go away" ); + deepEqual( + jQuery( "#unwrap > span" ).get(), + abcd, + "all four spans should still exist" + ); - deepEqual( jQuery("#unwrap3 span").unwrap().get(), jQuery("#unwrap > span.unwrap3").get(), "make #unwrap3 go away" ); + deepEqual( + jQuery( "#unwrap3 span" ).unwrap().get(), + jQuery( "#unwrap3 > span" ).get(), + "make all b in #unwrap3 go away" + ); - deepEqual( jQuery("#unwrap").children().get(), abcdef, "#unwrap only contains 6 child spans" ); + deepEqual( + jQuery( "#unwrap3 span" ).unwrap().get(), + jQuery( "#unwrap > span.unwrap3" ).get(), + "make #unwrap3 go away" + ); - deepEqual( jQuery("#unwrap > span").unwrap().get(), jQuery("body > span.unwrap").get(), "make the 6 spans become children of body" ); + deepEqual( + jQuery( "#unwrap" ).children().get(), + abcdef, + "#unwrap only contains 6 child spans" + ); - deepEqual( jQuery("body > span.unwrap").unwrap().get(), jQuery("body > span.unwrap").get(), "can't unwrap children of body" ); - deepEqual( jQuery("body > span.unwrap").unwrap().get(), abcdef, "can't unwrap children of body" ); + deepEqual( + jQuery( "#unwrap > span" ).unwrap().get(), + jQuery( "body > span.unwrap" ).get(), + "make the 6 spans become children of body" + ); + + deepEqual( + jQuery( "body > span.unwrap" ).unwrap().get(), + jQuery( "body > span.unwrap" ).get(), + "can't unwrap children of body" + ); - deepEqual( jQuery("body > span.unwrap").get(), abcdef, "body contains 6 .unwrap child spans" ); + deepEqual( + jQuery( "body > span.unwrap" ).unwrap().get(), + abcdef, + "can't unwrap children of body" + ); - jQuery("body > span.unwrap").remove(); -}); + deepEqual( + jQuery( "body > span.unwrap" ).get(), + abcdef, + "body contains 6 .unwrap child spans" + ); + + jQuery( "body > span.unwrap" ).remove(); +} ); QUnit.test( "jQuery() & wrap[Inner/All]() handle unknown elems (#10667)", function( assert ) {