Moved all the expressions tests over into selector area, out of the main suite.
authorJohn Resig <jeresig@gmail.com>
Sun, 31 Dec 2006 18:09:05 +0000 (18:09 +0000)
committerJohn Resig <jeresig@gmail.com>
Sun, 31 Dec 2006 18:09:05 +0000 (18:09 +0000)
build/test/index.html
src/jquery/coreTest.js
src/selector/selectorTest.js [new file with mode: 0644]

index 22f7df1..8037c39 100644 (file)
@@ -5,6 +5,7 @@
        <script type="text/javascript" src="../dist/jquery.js"></script>
        <script type="text/javascript" src="data/testrunner.js"></script>
        <script type="text/javascript" src="../src/jquery/coreTest.js"></script>
+       <script type="text/javascript" src="../src/selector/selectorTest.js"></script>
        <script type="text/javascript" src="../src/event/eventTest.js"></script>
        <script type="text/javascript" src="../src/ajax/ajaxTest.js"></script>
        <script type="text/javascript" src="../src/fx/fxTest.js"></script>
index ada7195..287d709 100644 (file)
@@ -322,145 +322,6 @@ test("$.extend(Object, Object, Object, Object)", function() {
        isSet ( options2, options2Copy, "Check if not modified: options2 must not be modified" );\r
 });\r
 \r
-test("expressions - element", function() {\r
-       expect(5);\r
-       ok( $("*").size() >= 30, "Select all" );\r
-       t( "Element Selector", "div", ["main","foo"] );\r
-       t( "Element Selector", "body", ["body"] );\r
-       t( "Element Selector", "html", ["html"] );\r
-       t( "Parent Element", "div div", ["foo"] );\r
-});\r
-\r
-test("expressions - id", function() {\r
-       expect(8);\r
-       t( "ID Selector", "#body", ["body"] );\r
-       t( "ID Selector w/ Element", "body#body", ["body"] );\r
-       t( "ID Selector w/ Element", "ul#first", [] );\r
-       \r
-       t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] );  // bug #267\r
-       t( "ID Selector, not an ancestor ID", "#form  #first", [] );\r
-       t( "ID Selector, not a child ID", "#form > #option1a", [] );\r
-       \r
-       t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"]  );\r
-       t( "All Children of ID with no children", "#firstUL/*", []  );\r
-});\r
-\r
-test("expressions - class", function() {\r
-       expect(4);\r
-       t( "Class Selector", ".blog", ["mark","simon"] );\r
-       t( "Class Selector", ".blog.link", ["simon"] );\r
-       t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );\r
-       t( "Parent Class Selector", "p .blog", ["mark","simon"] );\r
-});\r
-\r
-test("expressions - multiple", function() {\r
-       expect(4);\r
-       t( "Comma Support", "a.blog, div", ["mark","simon","main","foo"] );\r
-       t( "Comma Support", "a.blog , div", ["mark","simon","main","foo"] );\r
-       t( "Comma Support", "a.blog ,div", ["mark","simon","main","foo"] );\r
-       t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );\r
-});\r
-\r
-test("expressions - child and adjacent", function() {\r
-       expect(14);\r
-       t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );\r
-       t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );\r
-       t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );\r
-       t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );\r
-       t( "Child w/ Class", "p > a.blog", ["mark","simon"] );\r
-       t( "All Children", "code > *", ["anchor1","anchor2"] );\r
-       t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );\r
-       t( "Adjacent", "a + a", ["groups"] );\r
-       t( "Adjacent", "a +a", ["groups"] );\r
-       t( "Adjacent", "a+ a", ["groups"] );\r
-       t( "Adjacent", "a+a", ["groups"] );\r
-       t( "Adjacent", "p + p", ["ap","en","sap"] );\r
-       t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );\r
-       t( "First Child", "p:first-child", ["firstp","sndp"] );\r
-});\r
-\r
-test("expressions - attributes", function() {\r
-       expect(19);\r
-       t( "Attribute Exists", "a[@title]", ["google"] );\r
-       t( "Attribute Exists", "*[@title]", ["google"] );\r
-       t( "Attribute Exists", "[@title]", ["google"] );\r
-       \r
-       t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );\r
-       t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );\r
-       t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );\r
-       t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );\r
-       t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );\r
-       t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );\r
-       \r
-       t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );\r
-       t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );\r
-       t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );\r
-       \r
-       t("Select options via [@selected]", "#select1 option[@selected]", ["option1a"] );\r
-       t("Select options via [@selected]", "#select2 option[@selected]", ["option2d"] );\r
-       t("Select options via [@selected]", "#select3 option[@selected]", ["option3b", "option3c"] );\r
-       \r
-       t( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );\r
-       \r
-       t( ":not() Existing attribute", "select:not([@multiple])", ["select1", "select2"]);\r
-       t( ":not() Equals attribute", "select:not([@name=select1])", ["select2", "select3"]);\r
-       t( ":not() Equals quoted attribute", "select:not([@name='select1'])", ["select2", "select3"]);\r
-});\r
-\r
-test("expressions - pseudo (:) selctors", function() {\r
-       expect(30);\r
-       t( "First Child", "p:first-child", ["firstp","sndp"] );\r
-       t( "Last Child", "p:last-child", ["sap"] );\r
-       t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );\r
-       t( "Empty", "ul:empty", ["firstUL"] );\r
-       t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name"] );\r
-       t( "Disabled UI Element", "input:disabled", ["text2"] );\r
-       t( "Checked UI Element", "input:checked", ["radio2","check1"] );\r
-       t( "Selected Option Element", "option:selected", ["option1a","option2d","option3b","option3c"] );\r
-       t( "Text Contains", "a:contains('Google')", ["google","groups"] );\r
-       t( "Text Contains", "a:contains('Google Groups')", ["groups"] );\r
-       t( "Element Preceded By", "p ~ div", ["foo"] );\r
-       t( "Not", "a.blog:not(.link)", ["mark"] );\r
-       \r
-       t( "nth Element", "p:nth(1)", ["ap"] );\r
-       t( "First Element", "p:first", ["firstp"] );\r
-       t( "Last Element", "p:last", ["first"] );\r
-       t( "Even Elements", "p:even", ["firstp","sndp","sap"] );\r
-       t( "Odd Elements", "p:odd", ["ap","en","first"] );\r
-       t( "Position Equals", "p:eq(1)", ["ap"] );\r
-       t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );\r
-       t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );\r
-       t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );\r
-       t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );\r
-       t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );\r
-       \r
-       t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3"] );\r
-       t( "Form element :radio", ":radio", ["radio1", "radio2"] );\r
-       t( "Form element :checkbox", ":checkbox", ["check1", "check2"] );\r
-       t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name"] );\r
-       t( "Form element :radio:checked", ":radio:checked", ["radio2"] );\r
-       t( "Form element :checkbox:checked", ":checkbox:checked", ["check1"] );\r
-       t( "Form element :checkbox:checked, :radio:checked", ":checkbox:checked, :radio:checked", ["check1", "radio2"] );\r
-});\r
-\r
-test("expressions - basic xpath", function() {\r
-       expect(14);\r
-       ok( jQuery.find("//*").length >= 30, "All Elements (//*)" );\r
-       t( "All Div Elements", "//div", ["main","foo"] );\r
-       t( "Absolute Path", "/html/body", ["body"] );\r
-       t( "Absolute Path w/ *", "/* /body", ["body"] );\r
-       t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );\r
-       t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );\r
-       t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );\r
-       t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );\r
-       t( "Attribute Exists", "//a[@title]", ["google"] );\r
-       t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );\r
-       t( "Parent Axis", "//p/..", ["main","foo"] );\r
-       t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );\r
-       t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );\r
-       t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );\r
-});\r
-\r
 test("val()", function() {\r
        expect(2);\r
        ok( $("#text1").val() == "Test", "Check for value of input element" );\r
diff --git a/src/selector/selectorTest.js b/src/selector/selectorTest.js
new file mode 100644 (file)
index 0000000..6171614
--- /dev/null
@@ -0,0 +1,140 @@
+module("selector");\r
+\r
+test("expressions - element", function() {\r
+       expect(5);\r
+       ok( $("*").size() >= 30, "Select all" );\r
+       t( "Element Selector", "div", ["main","foo"] );\r
+       t( "Element Selector", "body", ["body"] );\r
+       t( "Element Selector", "html", ["html"] );\r
+       t( "Parent Element", "div div", ["foo"] );\r
+});\r
+\r
+test("expressions - id", function() {\r
+       expect(8);\r
+       t( "ID Selector", "#body", ["body"] );\r
+       t( "ID Selector w/ Element", "body#body", ["body"] );\r
+       t( "ID Selector w/ Element", "ul#first", [] );\r
+       \r
+       t( "ID Selector, child ID present", "#form > #radio1", ["radio1"] );  // bug #267\r
+       t( "ID Selector, not an ancestor ID", "#form  #first", [] );\r
+       t( "ID Selector, not a child ID", "#form > #option1a", [] );\r
+       \r
+       t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"]  );\r
+       t( "All Children of ID with no children", "#firstUL/*", []  );\r
+});\r
+\r
+test("expressions - class", function() {\r
+       expect(4);\r
+       t( "Class Selector", ".blog", ["mark","simon"] );\r
+       t( "Class Selector", ".blog.link", ["simon"] );\r
+       t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );\r
+       t( "Parent Class Selector", "p .blog", ["mark","simon"] );\r
+});\r
+\r
+test("expressions - multiple", function() {\r
+       expect(4);\r
+       t( "Comma Support", "a.blog, div", ["mark","simon","main","foo"] );\r
+       t( "Comma Support", "a.blog , div", ["mark","simon","main","foo"] );\r
+       t( "Comma Support", "a.blog ,div", ["mark","simon","main","foo"] );\r
+       t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );\r
+});\r
+\r
+test("expressions - child and adjacent", function() {\r
+       expect(14);\r
+       t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );\r
+       t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );\r
+       t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );\r
+       t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );\r
+       t( "Child w/ Class", "p > a.blog", ["mark","simon"] );\r
+       t( "All Children", "code > *", ["anchor1","anchor2"] );\r
+       t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );\r
+       t( "Adjacent", "a + a", ["groups"] );\r
+       t( "Adjacent", "a +a", ["groups"] );\r
+       t( "Adjacent", "a+ a", ["groups"] );\r
+       t( "Adjacent", "a+a", ["groups"] );\r
+       t( "Adjacent", "p + p", ["ap","en","sap"] );\r
+       t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );\r
+       t( "First Child", "p:first-child", ["firstp","sndp"] );\r
+});\r
+\r
+test("expressions - attributes", function() {\r
+       expect(19);\r
+       t( "Attribute Exists", "a[@title]", ["google"] );\r
+       t( "Attribute Exists", "*[@title]", ["google"] );\r
+       t( "Attribute Exists", "[@title]", ["google"] );\r
+       \r
+       t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );\r
+       t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );\r
+       t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );\r
+       t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );\r
+       t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );\r
+       t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );\r
+       \r
+       t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );\r
+       t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );\r
+       t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );\r
+       \r
+       t("Select options via [@selected]", "#select1 option[@selected]", ["option1a"] );\r
+       t("Select options via [@selected]", "#select2 option[@selected]", ["option2d"] );\r
+       t("Select options via [@selected]", "#select3 option[@selected]", ["option3b", "option3c"] );\r
+       \r
+       t( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );\r
+       \r
+       t( ":not() Existing attribute", "select:not([@multiple])", ["select1", "select2"]);\r
+       t( ":not() Equals attribute", "select:not([@name=select1])", ["select2", "select3"]);\r
+       t( ":not() Equals quoted attribute", "select:not([@name='select1'])", ["select2", "select3"]);\r
+});\r
+\r
+test("expressions - pseudo (:) selctors", function() {\r
+       expect(30);\r
+       t( "First Child", "p:first-child", ["firstp","sndp"] );\r
+       t( "Last Child", "p:last-child", ["sap"] );\r
+       t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );\r
+       t( "Empty", "ul:empty", ["firstUL"] );\r
+       t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name"] );\r
+       t( "Disabled UI Element", "input:disabled", ["text2"] );\r
+       t( "Checked UI Element", "input:checked", ["radio2","check1"] );\r
+       t( "Selected Option Element", "option:selected", ["option1a","option2d","option3b","option3c"] );\r
+       t( "Text Contains", "a:contains('Google')", ["google","groups"] );\r
+       t( "Text Contains", "a:contains('Google Groups')", ["groups"] );\r
+       t( "Element Preceded By", "p ~ div", ["foo"] );\r
+       t( "Not", "a.blog:not(.link)", ["mark"] );\r
+       \r
+       t( "nth Element", "p:nth(1)", ["ap"] );\r
+       t( "First Element", "p:first", ["firstp"] );\r
+       t( "Last Element", "p:last", ["first"] );\r
+       t( "Even Elements", "p:even", ["firstp","sndp","sap"] );\r
+       t( "Odd Elements", "p:odd", ["ap","en","first"] );\r
+       t( "Position Equals", "p:eq(1)", ["ap"] );\r
+       t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );\r
+       t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );\r
+       t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );\r
+       t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );\r
+       t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );\r
+       \r
+       t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3"] );\r
+       t( "Form element :radio", ":radio", ["radio1", "radio2"] );\r
+       t( "Form element :checkbox", ":checkbox", ["check1", "check2"] );\r
+       t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name"] );\r
+       t( "Form element :radio:checked", ":radio:checked", ["radio2"] );\r
+       t( "Form element :checkbox:checked", ":checkbox:checked", ["check1"] );\r
+       t( "Form element :checkbox:checked, :radio:checked", ":checkbox:checked, :radio:checked", ["check1", "radio2"] );\r
+});\r
+\r
+test("expressions - basic xpath", function() {\r
+       expect(14);\r
+       ok( jQuery.find("//*").length >= 30, "All Elements (//*)" );\r
+       t( "All Div Elements", "//div", ["main","foo"] );\r
+       t( "Absolute Path", "/html/body", ["body"] );\r
+       t( "Absolute Path w/ *", "/* /body", ["body"] );\r
+       t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );\r
+       t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );\r
+       t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );\r
+       t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );\r
+       t( "Attribute Exists", "//a[@title]", ["google"] );\r
+       t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );\r
+       t( "Parent Axis", "//p/..", ["main","foo"] );\r
+       t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );\r
+       t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );\r
+       t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );\r
+});
\ No newline at end of file