aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/selector.js
diff options
context:
space:
mode:
authortimmywil <timmywillisn@gmail.com>2012-05-28 12:18:40 -0400
committertimmywil <timmywillisn@gmail.com>2012-05-28 12:41:58 -0400
commita4fc2edaab8c92bfebf90a10bd3f23dc7e03f993 (patch)
treedf4c172c54ddbc10918a1b6eb9900c0218a901cb /test/unit/selector.js
parentd0763a37c683feb3f3148a6dad877402421ab61d (diff)
downloadjquery-a4fc2edaab8c92bfebf90a10bd3f23dc7e03f993.tar.gz
jquery-a4fc2edaab8c92bfebf90a10bd3f23dc7e03f993.zip
Update Sizzle and add tests from the Sizzle suite that require jQuery for the selection to jquery/test/unit/selector.js
Diffstat (limited to 'test/unit/selector.js')
-rw-r--r--test/unit/selector.js58
1 files changed, 55 insertions, 3 deletions
diff --git a/test/unit/selector.js b/test/unit/selector.js
index a5758a1c7..18089c8c5 100644
--- a/test/unit/selector.js
+++ b/test/unit/selector.js
@@ -1,11 +1,63 @@
/**
- * This test page is for selector tests that address selector issues that have already been addressed in jQuery functions
- * and which only work because jQuery has hooked into Sizzle.
- * These tests may or may not fail in an independent Sizzle.
+ * This test page is for selector tests that require jQuery in order to do the selection
*/
module("selector - jQuery only", { teardown: moduleTeardown });
+test("element - jQuery only", function() {
+ expect( 5 );
+
+ deepEqual( jQuery("p", document.getElementsByTagName("div")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
+ deepEqual( jQuery("p", "div").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
+ deepEqual( jQuery("p", jQuery("div")).get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
+ deepEqual( jQuery("div").find("p").get(), q("firstp","ap","sndp","en","sap","first"), "Finding elements with a context." );
+
+ //#7533
+ equal( jQuery("<div id=\"A'B~C.D[E]\"><p>foo</p></div>").find("p").length, 1, "Find where context root is a node and has an ID with CSS3 meta characters" );
+});
+
+test("class - jQuery only", function() {
+ expect( 4 );
+
+ deepEqual( jQuery(".blog", document.getElementsByTagName("p")).get(), q("mark", "simon"), "Finding elements with a context." );
+ deepEqual( jQuery(".blog", "p").get(), q("mark", "simon"), "Finding elements with a context." );
+ deepEqual( jQuery(".blog", jQuery("p")).get(), q("mark", "simon"), "Finding elements with a context." );
+ deepEqual( jQuery("p").find(".blog").get(), q("mark", "simon"), "Finding elements with a context." );
+});
+
+test("pseudo - visibility", function() {
+ expect(9);
+
+ t( "Is Visible", "div:visible:not(#qunit-testrunner-toolbar):lt(2)", ["nothiddendiv", "nothiddendivchild"] );
+ t( "Is Not Hidden", "#qunit-fixture:hidden", [] );
+ t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] );
+
+ var $div = jQuery('<div/>').appendTo("body");
+ $div.css({ fontSize: 0, lineHeight: 0 });// IE also needs to set font-size and line-height to 0
+ $div.width(1).height(0);
+ t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
+ t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
+ $div.width(0).height(1);
+ t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
+ t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
+ $div.width(1).height(1);
+ t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
+ t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
+ $div.remove();
+});
+
+test("disconnected nodes", function() {
+ expect(4);
+ var $opt = jQuery('<option></option>').attr("value", "whipit").appendTo("#qunit-fixture").detach();
+ equal( $opt.val(), "whipit", "option value" );
+ equal( $opt.is(":selected"), false, "unselected option" );
+ $opt.attr("selected", true);
+ equal( $opt.is(":selected"), true, "selected option" );
+
+ var $div = jQuery( '<div/>' );
+ equal( $div.is("div"), true, "Make sure .is('nodeName') works on disconnect nodes." );
+});
+
testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQuery, window, document ) {
expect(34);