X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2FcoreTest.js;h=28ba00702907155cb97f00aa21bd01542e401ce7;hb=27c08b65446568b700606e837a85630d3634f25f;hp=ccd84f72b770cb0ed8a98a261ccb5b5673433a4a;hpb=f2ff0db0320cfab0d856ff68d012cb843c97b600;p=jquery.git diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index ccd84f7..28ba007 100644 --- a/src/jquery/coreTest.js +++ b/src/jquery/coreTest.js @@ -11,6 +11,11 @@ test("Basic requirements", function() { ok( $, "$()" ); }); +test("$()", function() { + var main = $("#main"); + isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" ); +}); + test("length", function() { ok( $("div").length == 2, "Get Number of Elements Found" ); }); @@ -29,7 +34,7 @@ test("get(Number)", function() { test("add(String|Element|Array)", function() { isSet( $("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" ); - + isSet( $("#sndp").add( $("#en")[0] ).add( $("#sap") ).get(), q("sndp", "en", "sap"), "Check elements from document" ); ok( $([]).add($("#form")[0].elements).length > 13, "Check elements from array" ); var x = $([]).add($("

xxx

")).add($("

xxx

")); @@ -82,8 +87,9 @@ test("attr(String)", function() { }); test("attr(String, Function)", function() { - expect(1); + expect(2); ok( $('#text1').attr('value', function() { return this.id })[0].value == "text1", "Set value from id" ); + ok( $('#text1').attr('title', function(i) { return i }).attr('title') == "0", "Set value with an index"); }); test("attr(Hash)", function() { @@ -192,7 +198,7 @@ test("wrap(String|Element)", function() { }); test("append(String|Element|Array<Element>|jQuery)", function() { - expect(5); + expect(9); var defaultText = 'Try them out:' var result = $('#first').append('buga'); ok( result.text() == defaultText + 'buga', 'Check if text appending works' ); @@ -212,6 +218,15 @@ test("append(String|Element|Array<Element>|jQuery)", function() { expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo"; $('#sap').append($("#first, #yahoo")); ok( expected == $('#sap').text(), "Check for appending of jQuery object" ); + + reset(); + $("#sap").append( 5 ); + ok( $("#sap")[0].innerHTML.match( /5$/ ), "Check for appending a number" ); + + reset(); + ok( $("#sap").append([]), "Check for appending an empty array." ); + ok( $("#sap").append(""), "Check for appending an empty string." ); + ok( $("#sap").append(document.getElementsByTagName("foo")), "Check for appending an empty nodelist." ); }); test("appendTo(String|Element|Array<Element>|jQuery)", function() {