X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=test%2Funit%2Fmanipulation.js;h=9242dddb5f7ebcb5e886d75e1088397cf92ce633;hb=66975de2d249643779e2b3daad0457f7f5f92508;hp=0327f93b2379adc26c73c53d4e9d7dfee214e2da;hpb=7c04a64016c1f295dfdf4e731f693f8400a987bc;p=jquery.git diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 0327f93..9242ddd 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1,19 +1,27 @@ +module("manipulation"); + +var bareObj = function(value) { return value; }; +var functionReturningObj = function(value) { return (function() { return value; }); }; + test("text()", function() { - expect(1); + expect(2); 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.' ); + + // Check serialization of text values + equals( jQuery(document.createTextNode("foo")).text(), "foo", "Text node was retreived from .text()." ); }); -test("wrap(String|Element)", function() { - expect(10); +var testWrap = function(val) { + expect(18); 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 +29,61 @@ 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" ); + equals( jQuery("#nonnodes > i").text(), j.text(), "Check node,textnode,comment wraps doesn't hurt text" ); // Try wrapping a disconnected node - j = jQuery("