X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=test%2Funit%2Fcore.js;h=f5fc895a4e3e7bbf5ea0ef29002b80946a6a763a;hb=14b88f6019cd467c35a2c9e845740a61c153525e;hp=818e0f7d55dec03bd42c2e35ab277ac87d967d73;hpb=3dabd7ec301770a2a6bb8457c96d630d42376719;p=jquery.git diff --git a/test/unit/core.js b/test/unit/core.js index 818e0f7..f5fc895 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); @@ -767,7 +778,7 @@ test("is(String)", function() { }); test("$.extend(Object, Object)", function() { - expect(10); + expect(11); var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" }, options = { xnumber2: 1, xstring2: "x", xxx: "newstring" }, @@ -775,9 +786,9 @@ test("$.extend(Object, Object)", function() { merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" }, deep1 = { foo: { bar: true } }, deep1copy = { foo: { bar: true } }, - deep2 = { foo: { baz: true } }, - deep2copy = { foo: { baz: true } }, - deepmerged = { foo: { bar: true, baz: true } }; + deep2 = { foo: { baz: true }, foo2: document }, + deep2copy = { foo: { baz: true }, foo2: document }, + deepmerged = { foo: { bar: true, baz: true }, foo2: document }; jQuery.extend(settings, options); isObj( settings, merged, "Check if extended: settings must be extended" ); @@ -790,6 +801,7 @@ test("$.extend(Object, Object)", function() { jQuery.extend(true, deep1, deep2); isObj( deep1.foo, deepmerged.foo, "Check if foo: settings must be extended" ); isObj( deep2.foo, deep2copy.foo, "Check if not deep2: options must not be modified" ); + equals( deep1.foo2, document, "Make sure that a deep clone was not attempted on the document" ); var defaults = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" }, defaultsCopy = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" }, @@ -813,15 +825,20 @@ 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" ); }); +var scriptorder = 0; + test("html(String)", function() { - expect(3); + expect(9); var div = $("div"); div.html("test"); var pass = true; @@ -836,6 +853,8 @@ test("html(String)", function() { $("#main").html('foo
'); + $("#main").html("