Added support for .text() on text nodes. Fixes #5525.
[jquery.git] / test / unit / manipulation.js
index b9cb35d..4997634 100644 (file)
@@ -4,9 +4,12 @@ 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()." );
 });
 
 var testWrap = function(val) {
@@ -602,7 +605,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' );
 
@@ -643,7 +646,7 @@ test("val(Function)", function() {
 })
 
 var testHtml = function(valueObj) {
-       expect(17);
+       expect(20);
 
        window.debug = true;
 
@@ -676,6 +679,12 @@ var testHtml = function(valueObj) {
        equals( $div.html(valueObj( 5 )).html(), '5', 'Setting a number as html' );
        equals( $div.html(valueObj( 0 )).html(), '0', 'Setting a zero as html' );
 
+       var $div2 = jQuery('<div/>'), insert = "&lt;div&gt;hello1&lt;/div&gt;";
+       equals( $div2.html(insert).html(), insert, "Verify escaped insertion." );
+       equals( $div2.html("x" + insert).html(), "x" + insert, "Verify escaped insertion." );
+       equals( $div2.html(" " + insert).html(), " " + insert, "Verify escaped insertion." );
+
+
        reset();
 
        jQuery("#main").html(valueObj('<script type="something/else">ok( false, "Non-script evaluated." );</script><script type="text/javascript">ok( true, "text/javascript is evaluated." );</script><script>ok( true, "No type is evaluated." );</script><div><script type="text/javascript">ok( true, "Inner text/javascript is evaluated." );</script><script>ok( true, "Inner No type is evaluated." );</script><script type="something/else">ok( false, "Non-script evaluated." );</script></div>'));