X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fjquery%2FcoreTest.js;h=58616dba116e44eb5a2770f8e1adc8a8409c3f3b;hb=ea283bd13130303271077a6ee8b14b7c79bd0ce4;hp=4b29c8f86ea71a546102407ab2eb9a7e6f437d94;hpb=12e63353391f1a556a73fe92bcd8e5f0ac277726;p=jquery.git diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index 4b29c8f..58616db 100644 --- a/src/jquery/coreTest.js +++ b/src/jquery/coreTest.js @@ -67,13 +67,9 @@ test("attr(String)", function() { ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' ); }); -test("attr(String, Function|String)", function() { +test("attr(String, Function)", function() { + expect(1); ok( $('#text1').attr('value', function() { return this.id })[0].value == "text1", "Set value from id" ); - ok( $('#text2').attr('value', "${this.id}")[0].value == "text2", "Set value from id" ); - reset(); - $('#text1, #text2').attr({value: "${this.id + 'foobar'}"}); - ok( $('#text1')[0].value == "text1foobar", "Set value from id" ); - ok( $('#text2')[0].value == "text2foobar", "Set value from id" ); }); test("attr(Hash)", function() { @@ -392,6 +388,15 @@ test("children([String])", function() { isSet( $("#foo").children("[code]").get(), q("sndp", "sap"), "Check for filtered children" ); }); +test("parent[s]([String])", function() { + 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").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" ); +}); test("show()", function() { expect(1); @@ -433,11 +438,21 @@ test("removeClass(String) - add three classes and remove again", function() { ok( pass, "Remove multiple classes" ); }); +test("toggleClass(String)", function() { + expect(3); + var e = $("#firstp"); + ok( !e.is(".test"), "Assert class not present" ); + e.toggleClass("test"); + ok( e.is(".test"), "Assert class present" ); + e.toggleClass("test"); + ok( !e.is(".test"), "Assert class not present" ); +}); + test("removeAttr(String", function() { ok( $('#mark').removeAttr("class")[0].className == "", "remove class" ); }); -test("text(String, Boolean)", function() { +test("text(String)", function() { + expect(1); ok( $("#foo").text("
Hello cruel world!
")[0].innerHTML == "<div><b>Hello</b> cruel world!</div>", "Check escaped text" ); - ok( $("#foo").text("
Hello cruel world!
", true)[0].innerHTML == "Hello cruel world!", "Check stripped text" ); -}); \ No newline at end of file +});