X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fmanipulation.js;h=c942bfd38083747fc6ce74300eec8e112d2f5fe9;hb=520f1a26845252dd6d7fd5f3b5bb7779ba91eb2c;hp=1755ae4750fd5ad8790ba1f85b086456bd4c9bd1;hpb=4130319e97b1c591d394b73961b6772559cd0549;p=jquery.git diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 1755ae4..c942bfd 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1,21 +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' ); @@ -23,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("