Fix for bug #962.
[jquery.git] / src / jquery / coreTest.js
index 6b73b0c..c20d406 100644 (file)
@@ -74,7 +74,7 @@ test("index(Object)", function() {
 });\r
 \r
 test("attr(String)", function() {\r
-       expect(12);\r
+       expect(15);\r
        ok( $('#text1').attr('value') == "Test", 'Check for value attribute' );\r
        ok( $('#text1').attr('type') == "text", 'Check for type attribute' );\r
        ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' );\r
@@ -87,6 +87,16 @@ test("attr(String)", function() {
        ok( $('#name').attr('name') == "name", 'Check for name attribute' );\r
        ok( $('#text1').attr('name') == "action", 'Check for name attribute' );\r
        ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );\r
+       \r
+       $('<a id="tAnchor5"></a>').attr('href', '#5').appendTo('#main'); // using innerHTML in IE causes href attribute to be serialized to the full path\r
+       ok( $('#tAnchor5').attr('href') == "#5", 'Check for non-absolute href (an anchor)' );\r
+       \r
+       stop();\r
+       $.get("data/dashboard.xml", function(xml) {\r
+               ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" );\r
+               ok( $("location", xml).attr("for") == "bar", "Check for attribute in XML document" );\r
+               start();\r
+       });\r
 });\r
 \r
 test("attr(String, Function)", function() {\r
@@ -203,7 +213,7 @@ test("wrap(String|Element)", function() {
 });\r
 \r
 test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
-       expect(9);\r
+       expect(11);\r
        var defaultText = 'Try them out:'\r
        var result = $('#first').append('<b>buga</b>');\r
        ok( result.text() == defaultText + 'buga', 'Check if text appending works' );\r
@@ -229,9 +239,18 @@ test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {
        ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );\r
 \r
        reset();\r
+       $("#sap").append( " text with spaces " );\r
+       ok( $("#sap")[0].innerHTML.match(/ text with spaces $/), "Check for appending text with spaces" );\r
+\r
+       reset();\r
        ok( $("#sap").append([]), "Check for appending an empty array." );\r
        ok( $("#sap").append(""), "Check for appending an empty string." );\r
        ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." );\r
+       \r
+       reset();\r
+       $("#sap").append(document.getElementById('form'));\r
+       ok( $("#sap>form").size() == 1, "Check for appending a form" );  // Bug #910\r
+       \r
 });\r
 \r
 test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
@@ -414,7 +433,7 @@ test("clone()", function() {
 });\r
 \r
 test("is(String)", function() {\r
-       expect(22);\r
+       expect(26);\r
        ok( $('#form').is('form'), 'Check for element: A form must be a form' );\r
        ok( !$('#form').is('div'), 'Check for element: A form is not a div' );\r
        ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' );\r
@@ -437,6 +456,12 @@ test("is(String)", function() {
        ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );\r
        ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );\r
        ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );\r
+       \r
+       // test is() with comma-seperated expressions\r
+       ok( $('#en').is('[@lang="en"],[@lang="de"]'), 'Check for lang attribute: Expecte en or de' );\r
+       ok( $('#en').is('[@lang="de"],[@lang="en"]'), 'Check for lang attribute: Expecte en or de' );\r
+       ok( $('#en').is('[@lang="en"] , [@lang="de"]'), 'Check for lang attribute: Expecte en or de' );\r
+       ok( $('#en').is('[@lang="de"] , [@lang="en"]'), 'Check for lang attribute: Expecte en or de' );\r
 });\r
 \r
 test("$.extend(Object, Object)", function() {\r
@@ -677,4 +702,4 @@ test("click() context", function() {
            //console.log( close[0]); // it's the <a> and not a <span> element\r
            return false;\r
        }).click();\r
-});
\ No newline at end of file
+});\r