Implemented #753
[jquery.git] / src / jquery / coreTest.js
index 43033a7..436dcc5 100644 (file)
@@ -67,6 +67,15 @@ test("attr(String)", function() {
        ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );\r
 });\r
 \r
+test("attr(String, Function|String)", function() {\r
+       ok( $('#text1').attr('value', function() { return this.id })[0].value == "text1", "Set value from id" );\r
+       ok( $('#text2').attr('value', "${this.id}")[0].value == "text2", "Set value from id" );\r
+       reset();\r
+       $('#text1, #text2').attr({value: "${this.id + 'foobar'}"});\r
+       ok( $('#text1')[0].value == "text1foobar", "Set value from id" );\r
+       ok( $('#text2')[0].value == "text2foobar", "Set value from id" );\r
+});\r
+\r
 test("attr(Hash)", function() {\r
        expect(1);\r
        var pass = true;\r
@@ -87,7 +96,7 @@ test("attr(String, Object)", function() {
        ok( pass, "Set Attribute" );\r
        \r
        $("#name").attr('name', 'something');\r
-       ok( $("#name").name() == 'something', 'Set name attribute' );\r
+       ok( $("#name").attr('name') == 'something', 'Set name attribute' );\r
        $("#check2").attr('checked', true);\r
        ok( document.getElementById('check2').checked == true, 'Set checked attribute' );\r
        $("#check2").attr('checked', false);\r
@@ -368,27 +377,6 @@ test("html(String)", function() {
        ok( pass, "Set HTML" );\r
 });\r
 \r
-test("id()", function() {\r
-       expect(3);\r
-       ok( $(document.getElementById('main')).id() == "main", "Check for id" );\r
-       ok( $("#foo").id() == "foo", "Check for id" );\r
-       ok( !$("head").id(), "Check for id" );\r
-});\r
-\r
-test("title()", function() {\r
-       expect(2);\r
-       ok( $(document.getElementById('google')).title() == "Google!", "Check for title" );\r
-       ok( !$("#yahoo").title(), "Check for title" );\r
-});\r
-\r
-test("name()", function() {\r
-       expect(3);\r
-       ok( $(document.getElementById('text1')).name() == "action", "Check for name" );\r
-       ok( $("#hidden1").name() == "hidden", "Check for name" );\r
-       ok( !$("#area1").name(), "Check for name" );\r
-});\r
-\r
-\r
 test("siblings([String])", function() {\r
        expect(3);\r
        isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );\r