X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2FcoreTest.js;h=7be53f738338d7af3f66338ee6033627445c280f;hb=aa424984f7c37956f568512aa94bc16787e4c651;hp=169380bd0e91b35f50f2d27d1d60de14e14c193e;hpb=4451a83407b396a3e52b83667fe51a10bfb31289;p=jquery.git diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js index 169380b..7be53f7 100644 --- a/src/jquery/coreTest.js +++ b/src/jquery/coreTest.js @@ -68,8 +68,8 @@ test("attr(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" ); }); test("attr(Hash)", function() { @@ -103,19 +103,21 @@ test("attr(String, Object)", function() { ok( document.getElementById('text1').readOnly == false, 'Set readonly attribute' ); }); -test("attr(String, Object)x", function() { - expect(2); - stop(); - $.get('data/dashboard.xml', function(xml) { - var titles = []; - $('tab', xml).each(function() { - titles.push($(this).attr('title')); - }); - ok( titles[0] == 'Location', 'attr() in XML context: Check first title' ); - ok( titles[1] == 'Users', 'attr() in XML context: Check second title' ); - start(); +if ( location.protocol != "file:" ) { + test("attr(String, Object)x", function() { + expect(2); + stop(); + $.get('data/dashboard.xml', function(xml) { + var titles = []; + $('tab', xml).each(function() { + titles.push($(this).attr('title')); + }); + ok( titles[0] == 'Location', 'attr() in XML context: Check first title' ); + ok( titles[1] == 'Users', 'attr() in XML context: Check second title' ); + start(); + }); }); -}); +} test("css(String|Hash)", function() { expect(8); @@ -427,7 +429,20 @@ test("removeClass(String) - add three classes and remove again", function() { ok( pass, "Remove multiple classes" ); }); +test("toggleClass(String)", function() { + 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)", function() { + expect(1); + ok( $("#foo").text("
Hello cruel world!
")[0].innerHTML == "<div><b>Hello</b> cruel world!</div>", "Check escaped text" ); +});