X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fjquery%2FcoreTest.js;h=d0fc9d25eb70a156706accbf0e5cb44deca8197c;hb=f28f199dc0a353135ef8b9afa2f3d25c6ffd2c75;hp=bb51acbea85c952034a9f9ea15d613f89d413210;hpb=53dc6afc310aa0e5df094304996ef605d4dbbd58;p=jquery.git
diff --git a/src/jquery/coreTest.js b/src/jquery/coreTest.js
index bb51acb..d0fc9d2 100644
--- a/src/jquery/coreTest.js
+++ b/src/jquery/coreTest.js
@@ -12,7 +12,7 @@ test("Basic requirements", function() {
});
test("$()", function() {
- expect(2);
+ expect(5);
var main = $("#main");
isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" );
@@ -29,6 +29,13 @@ test("$()", function() {
pass = false;
}
ok( pass, "$('<tag>') needs optional document parameter to ease cross-frame DOM wrangling, see #968" );*/
+
+ var code = $("");
+ equals( code.length, 1, "Correct number of elements generated for code" );
+ var img = $("");
+ equals( img.length, 1, "Correct number of elements generated for img" );
+ var div = $("
");
+ equals( div.length, 4, "Correct number of elements generated for div hr code b" );
});
test("isFunction", function() {
@@ -232,7 +239,7 @@ test("attr(Hash)", function() {
});
test("attr(String, Object)", function() {
- expect(8);
+ expect(12);
var div = $("div");
div.attr("foo", "bar");
var pass = true;
@@ -255,6 +262,28 @@ test("attr(String, Object)", function() {
ok( document.getElementById('text1').readOnly == false, 'Set readonly attribute' );
$("#name").attr('maxlength', '5');
ok( document.getElementById('name').maxLength == '5', 'Set maxlength attribute' );
+
+ reset();
+
+ var type = $("#check2").attr('type');
+ var thrown = false;
+ try {
+ $("#check2").attr('type','hidden');
+ } catch(e) {
+ thrown = true;
+ }
+ ok( thrown, "Exception thrown when trying to change type property" );
+ equals( type, $("#check2").attr('type'), "Verify that you can't change the type of an input element" );
+
+ var check = document.createElement("input");
+ var thrown = true;
+ try {
+ $(check).attr('type','checkbox');
+ } catch(e) {
+ thrown = false;
+ }
+ ok( thrown, "Exception thrown when trying to change type property" );
+ 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() {
@@ -820,6 +849,14 @@ test("not()", function() {
isSet( $("p").not($("#ap, #sndp, .result")).get(), q("firstp", "en", "sap", "first"), "not(jQuery)" );
});
+test("andSelf()", function() {
+ expect(4);
+ isSet( $("#en").siblings().andSelf().get(), q("sndp", "sap","en"), "Check for siblings and self" );
+ isSet( $("#foo").children().andSelf().get(), q("sndp", "en", "sap", "foo"), "Check for children and self" );
+ isSet( $("#en, #sndp").parent().andSelf().get(), q("foo","en","sndp"), "Check for parent and self" );
+ isSet( $("#groups").parents("p, div").andSelf().get(), q("ap", "main", "groups"), "Check for parents and self" );
+});
+
test("siblings([String])", function() {
expect(5);
isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );