X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;f=src%2Fjquery%2FcoreTest.js;h=312bc3ce15b6aa8e8bf668c7d85e363f2334262e;hb=e06b7447c2e8887549338b3b5f4fa9ed65fe9dcd;hp=602da848c87756757eaf8468d38576a49d91af73;hpb=69ef5fac9e84623c1260cf4d548c1034ac7e45a8;p=jquery.git
diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js
index 602da84..312bc3c 100644
--- a/src/jquery/coreTest.js
+++ b/src/jquery/coreTest.js
@@ -12,7 +12,7 @@ test("Basic requirements", function() {
});
test("$()", function() {
- expect(3);
+ expect(2);
var main = $("#main");
isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
@@ -116,31 +116,43 @@ test("isFunction", function() {
});
});
+test("$('html')", function() {
+ expect(2);
+
+ reset();
+ ok( $("")[0], "Creating a script" );
+
+ reset();
+ ok( $("")[0], "Creating a link" );
+
+ reset();
+});
+
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" );
@@ -194,17 +206,15 @@ test("attr(String)", function() {
ok( $('#tAnchor5').attr('href') == "#5", 'Check for non-absolute href (an anchor)' );
});
-if ( location.protocol != "file:" ) {
- 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) 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);
@@ -247,21 +257,19 @@ test("attr(String, Object)", function() {
ok( document.getElementById('name').maxLength == '5', 'Set maxlength attribute' );
});
-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("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);
@@ -327,7 +335,7 @@ test("text()", function() {
});
test("wrap(String|Element)", function() {
- expect(7);
+ expect(6);
var defaultText = 'Try them out:'
var result = $('#first').wrap('
').text();
ok( defaultText == result, 'Check for wrapping of on-the-fly html' );
@@ -340,22 +348,22 @@ test("wrap(String|Element)", function() {
ok( result.text() == defaultText, 'Check for element wrapping' );
reset();
- stop();
+ //stop();
$('#check1').click(function() {
var checkbox = this;
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
$(checkbox).wrap( '' );
ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
// use a fade in to check state after this event handler has finished
- setTimeout(function() {
+ /*setTimeout(function() {
ok( !checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" );
start();
- }, 100);
+ }, 100);*/
}).click();
});
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 +426,10 @@ test("append(String|Element|Array<Element>|jQuery)", function() {
ok( $('#table colgroup col').length, "Append col" );
reset();
+ $('#table').append('