aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2014-02-27 03:01:07 +0400
committerOleg Gaidarenko <markelog@gmail.com>2014-04-15 17:46:25 +0400
commit10d92e3dced034191dbd44db6a37aae8749d1da0 (patch)
tree5695805d47beb3293842c96b72927cc27f54cd5a
parent6e4f75fea780646e1a1769f496179e797ae00ce4 (diff)
downloadjquery-10d92e3dced034191dbd44db6a37aae8749d1da0.tar.gz
jquery-10d92e3dced034191dbd44db6a37aae8749d1da0.zip
Tests: Copy Sizzle.contains tests
-rw-r--r--test/unit/selector.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/unit/selector.js b/test/unit/selector.js
index 4c544dca7..df0282e08 100644
--- a/test/unit/selector.js
+++ b/test/unit/selector.js
@@ -220,6 +220,32 @@ testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQue
t( "Improperly named form elements do not interfere with form selections (#9570)", "form[name='formName']", ["form1"] );
});
+test( "jQuery.contains", function() {
+ expect( 16 );
+
+ var container = document.getElementById("nonnodes"),
+ element = container.firstChild,
+ text = element.nextSibling,
+ nonContained = container.nextSibling,
+ detached = document.createElement("a");
+ ok( element && element.nodeType === 1, "preliminary: found element" );
+ ok( text && text.nodeType === 3, "preliminary: found text" );
+ ok( nonContained, "preliminary: found non-descendant" );
+ ok( jQuery.contains(container, element), "child" );
+ ok( jQuery.contains(container.parentNode, element), "grandchild" );
+ ok( jQuery.contains(container, text), "text child" );
+ ok( jQuery.contains(container.parentNode, text), "text grandchild" );
+ ok( !jQuery.contains(container, container), "self" );
+ ok( !jQuery.contains(element, container), "parent" );
+ ok( !jQuery.contains(container, nonContained), "non-descendant" );
+ ok( !jQuery.contains(container, document), "document" );
+ ok( !jQuery.contains(container, document.documentElement), "documentElement (negative)" );
+ ok( !jQuery.contains(container, null), "Passing null does not throw an error" );
+ ok( jQuery.contains(document, document.documentElement), "documentElement (positive)" );
+ ok( jQuery.contains(document, element), "document container (positive)" );
+ ok( !jQuery.contains(document, detached), "document container (negative)" );
+});
+
testIframe("selector/sizzle_cache", "Sizzle cache collides with multiple Sizzles on a page", function( jQuery, window, document ) {
var $cached = window["$cached"];