X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fmanipulation.js;h=465686fdfd7b3d06fcd9556ab862a2844591b337;hb=8356871a5522ad59cac80af2ca4695079059b97e;hp=0327f93b2379adc26c73c53d4e9d7dfee214e2da;hpb=7c04a64016c1f295dfdf4e731f693f8400a987bc;p=jquery.git diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 0327f93..465686f 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1,19 +1,24 @@ +module("manipulation"); + +var bareObj = function(value) { return value; }; +var functionReturningObj = function(value) { return (function() { return value; }); }; + test("text()", function() { expect(1); var expected = "This link has class=\"blog\": Simon Willison's Weblog"; equals( jQuery('#sap').text(), expected, 'Check for merged text of more then one element.' ); }); -test("wrap(String|Element)", function() { - expect(10); +var testWrap = function(val) { + expect(15); var defaultText = 'Try them out:' - var result = jQuery('#first').wrap('
').text(); + var result = jQuery('#first').wrap(val( '
' )).text(); equals( defaultText, result, 'Check for wrapping of on-the-fly html' ); ok( jQuery('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' ); reset(); var defaultText = 'Try them out:' - var result = jQuery('#first').wrap(document.getElementById('empty')).parent(); + var result = jQuery('#first').wrap(val( document.getElementById('empty') )).parent(); ok( result.is('ol'), 'Check for element wrapping' ); equals( result.text(), defaultText, 'Check for element wrapping' ); @@ -21,27 +26,47 @@ test("wrap(String|Element)", function() { jQuery('#check1').click(function() { var checkbox = this; ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" ); - jQuery(checkbox).wrap( '' ); + jQuery(checkbox).wrap(val( '' )); ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" ); }).click(); // using contents will get comments regular, text, and comment nodes var j = jQuery("#nonnodes").contents(); - j.wrap(""); + j.wrap(val( "" )); equals( jQuery("#nonnodes > i").length, 3, "Check node,textnode,comment wraps ok" ); equals( jQuery("#nonnodes > i").text(), j.text() + j[1].nodeValue, "Check node,textnode,comment wraps doesn't hurt text" ); // Try wrapping a disconnected node - j = jQuery("