X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=eee1740d6361d99c959eccbe1d3db98169772cb1;hb=971840f343dae04fdc6ff51ecb03ec8b3aaee067;hp=dce86d828e2b18554a67beeca3e3714bf7c6c13b;hpb=606b863edaff29035960e4d813b45d63b8d92876;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index dce86d8..eee1740 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -123,11 +123,18 @@ test("isFunction", function() { }); }); +var foo = false; + test("$('html')", function() { - expect(2); + expect(4); reset(); - ok( $("")[0], "Creating a script" ); + foo = false; + var s = $("")[0]; + ok( s, "Creating a script" ); + ok( !foo, "Make sure the script wasn't executed prematurely" ); + $("body").append(s); + ok( foo, "Executing a scripts contents in the right context" ); reset(); ok( $("")[0], "Creating a link" ); @@ -213,15 +220,17 @@ test("attr(String)", function() { ok( $('#tAnchor5').attr('href') == "#5", 'Check for non-absolute href (an anchor)' ); }); -test("attr(String) in XML Files", function() { - expect(2); - stop(); - $.get("data/dashboard.xml", function(xml) { - ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" ); - ok( $("location", xml).attr("for") == "bar", "Check for attribute in XML document" ); - start(); - }); -}); +if ( !isLocal ) { + test("attr(String) in XML Files", function() { + expect(2); + stop(); + $.get("data/dashboard.xml", function(xml) { + ok( $("locations", xml).attr("class") == "foo", "Check class attribute in XML document" ); + ok( $("location", xml).attr("for") == "bar", "Check for attribute in XML document" ); + start(); + }); + }); +} test("attr(String, Function)", function() { expect(2); @@ -286,19 +295,21 @@ test("attr(String, Object)", function() { equals( "checkbox", $(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" ); }); -test("attr(String, Object) - Loaded via XML document", 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 ( !isLocal ) { + test("attr(String, Object) - Loaded via XML document", 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(19); @@ -813,11 +824,14 @@ test("val()", function() { }); test("val(String)", function() { - expect(2); + expect(3); document.getElementById('text1').value = "bla"; ok( $("#text1").val() == "bla", "Check for modified value of input element" ); $("#text1").val('test'); ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" ); + + $("#select1").val("3"); + ok( $("#select1").val() == "3", "Check for modified (via val(String)) value of select element" ); }); test("html(String)", function() { @@ -1034,11 +1048,13 @@ test("empty()", function() { }); test("slice()", function() { - expect(4); + expect(5); isSet( $("#ap a").slice(1,2), q("groups"), "slice(1,2)" ); isSet( $("#ap a").slice(1), q("groups", "anchor1", "mark"), "slice(1)" ); isSet( $("#ap a").slice(0,3), q("google", "groups", "anchor1"), "slice(0,3)" ); isSet( $("#ap a").slice(-1), q("mark"), "slice(-1)" ); + + isSet( $("#ap a").eq(1), q("groups"), "eq(1)" ); }); test("map()", function() {