X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2FcoreTest.js;h=cda5908e0c52202eb49aa059c0b56c6b5db54daf;hb=05d401dd8439d8a2137d3fb69a70d671c0d3a69d;hp=ee4438194f3c57725a9e9e0eab12db909968b5d0;hpb=54035207fe91cb57f49bb8c0c9f7b4ada8d05346;p=jquery.git diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index ee44381..cda5908 100644 --- a/src/jquery/coreTest.js +++ b/src/jquery/coreTest.js @@ -118,29 +118,29 @@ test("isFunction", function() { test("length", function() { expect(1); - ok( $("div").length == 2, "Get Number of Elements Found" ); + ok( $("p").length == 6, "Get Number of Elements Found" ); }); test("size()", function() { expect(1); - ok( $("div").size() == 2, "Get Number of Elements Found" ); + ok( $("p").size() == 6, "Get Number of Elements Found" ); }); test("get()", function() { expect(1); - isSet( $("div").get(), q("main","foo"), "Get All Elements" ); + isSet( $("p").get(), q("firstp","ap","sndp","en","sap","first"), "Get All Elements" ); }); test("get(Number)", function() { expect(1); - ok( $("div").get(0) == document.getElementById("main"), "Get A Single Element" ); + ok( $("p").get(0) == document.getElementById("firstp"), "Get A Single Element" ); }); test("add(String|Element|Array)", function() { expect(7); 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" ); + ok( $([]).add($("#form")[0].elements).length >= 13, "Check elements from array" ); var x = $([]).add($("

xxx

")).add($("

xxx

")); ok( x[0].id == "x1", "Check on-the-fly element1" ); @@ -355,7 +355,7 @@ test("wrap(String|Element)", function() { }); test("append(String|Element|Array<Element>|jQuery)", function() { - expect(17); + expect(18); var defaultText = 'Try them out:' var result = $('#first').append('buga'); ok( result.text() == defaultText + 'buga', 'Check if text appending works' ); @@ -418,6 +418,10 @@ test("append(String|Element|Array<Element>|jQuery)", function() { ok( $('#table colgroup col').length, "Append col" ); reset(); + $('#table').append(''); + ok( $('#table caption').length, "Append caption" ); + + reset(); $('form:last') .append('') .append(''); @@ -718,11 +722,12 @@ test("not()", function() { }); test("siblings([String])", function() { - expect(4); + expect(5); isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" ); isSet( $("#sndp").siblings("[code]").get(), q("sap"), "Check for filtered siblings (has code child element)" ); isSet( $("#sndp").siblings("[a]").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" ); isSet( $("#foo").siblings("form, b").get(), q("form", "lengthtest", "floatTest"), "Check for multiple filters" ); + isSet( $("#en, #sndp").siblings().get(), q("sndp", "sap", "en"), "Check for unique results from siblings" ); }); test("children([String])", function() { @@ -732,26 +737,34 @@ test("children([String])", function() { isSet( $("#foo").children("#en, #sap").get(), q("en", "sap"), "Check for multiple filters" ); }); -test("parent[s]([String])", function() { - expect(8); +test("parent([String])", function() { + expect(5); ok( $("#groups").parent()[0].id == "ap", "Simple parent check" ); ok( $("#groups").parent("p")[0].id == "ap", "Filtered parent check" ); ok( $("#groups").parent("div").length == 0, "Filtered parent check, no match" ); ok( $("#groups").parent("div, p")[0].id == "ap", "Check for multiple filters" ); + isSet( $("#en, #sndp").parent().get(), q("foo"), "Check for unique results from parent" ); +}); +test("parents([String])", function() { + expect(5); ok( $("#groups").parents()[0].id == "ap", "Simple parents check" ); ok( $("#groups").parents("p")[0].id == "ap", "Filtered parents check" ); ok( $("#groups").parents("div")[0].id == "main", "Filtered parents check2" ); isSet( $("#groups").parents("p, div").get(), q("ap", "main"), "Check for multiple filters" ); + isSet( $("#en, #sndp").parents().get(), q("foo", "main", "dl", "body", "html"), "Check for unique results from parents" ); }); -test("next/prev([String])", function() { - expect(8); +test("next([String])", function() { + expect(4); ok( $("#ap").next()[0].id == "foo", "Simple next check" ); ok( $("#ap").next("div")[0].id == "foo", "Filtered next check" ); ok( $("#ap").next("p").length == 0, "Filtered next check, no match" ); ok( $("#ap").next("div, p")[0].id == "foo", "Multiple filters" ); +}); +test("prev([String])", function() { + expect(4); ok( $("#foo").prev()[0].id == "ap", "Simple prev check" ); ok( $("#foo").prev("p")[0].id == "ap", "Filtered prev check" ); ok( $("#foo").prev("div").length == 0, "Filtered prev check, no match" );