Fixed not(jQuery) (need. more. tests.)
[jquery.git] / src / jquery / coreTest.js
index ccd84f7..a9c3e26 100644 (file)
@@ -11,6 +11,11 @@ test("Basic requirements", function() {
        ok( $, "$()" );\r
 });\r
 \r
+test("$()", function() {\r
+       var main = $("#main");\r
+       isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );\r
+});\r
+\r
 test("length", function() {\r
        ok( $("div").length == 2, "Get Number of Elements Found" );\r
 });\r
@@ -29,7 +34,7 @@ test("get(Number)", function() {
 \r
 test("add(String|Element|Array)", function() {\r
        isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );\r
-       \r
+       isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" );\r
        ok( $([]).add($("#form")[0].elements).length > 13, "Check elements from array" );\r
        \r
        var x = $([]).add($("<p id='x1'>xxx</p>")).add($("<p id='x2'>xxx</p>"));\r
@@ -82,8 +87,9 @@ test("attr(String)", function() {
 });\r
 \r
 test("attr(String, Function)", function() {\r
-       expect(1);\r
+       expect(2);\r
        ok( $('#text1').attr('value', function() { return this.id })[0].value == "text1", "Set value from id" );\r
+       ok( $('#text1').attr('title', function(i) { return i }).attr('title') == "0", "Set value with an index");\r
 });\r
 \r
 test("attr(Hash)", function() {\r
@@ -192,7 +198,7 @@ test("wrap(String|Element)", function() {
 });\r
 \r
 test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
-       expect(5);\r
+       expect(9);\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
@@ -212,6 +218,15 @@ test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {
        expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";\r
        $('#sap').append($("#first, #yahoo"));\r
        ok( expected == $('#sap').text(), "Check for appending of jQuery object" );\r
+\r
+       reset();\r
+       $("#sap").append( 5 );\r
+       ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" );\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
 \r
 test("appendTo(String|Element|Array&lt;Element&gt;|jQuery)", function() {\r
@@ -479,10 +494,11 @@ test("filter()", function() {
        isSet( $("p").filter(function() { return !$("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );\r
 });\r
 \r
-test("not(String)", function() {\r
-       expect(2);\r
+test("not()", function() {\r
+       expect(3);\r
        ok( $("#main > p#ap > a").not("#google").length == 2, "not('selector')" );\r
        isSet( $("p").not("#ap, #sndp, .result").get(), q("firstp", "en", "sap", "first"), "not('selector, selector')" );\r
+       isSet( $("p").not($("#ap, #sndp, .result")).get(), q("firstp", "en", "sap", "first"), "not(jQuery)" );\r
 });\r
 \r
 \r