});\r
\r
test("attr(String, Function)", function() {\r
+ expect(1);\r
ok( $('#text1').attr('value', function() { return this.id })[0].value == "text1", "Set value from id" );\r
- ok( $('#text2').attr('value', "${this.id}")[0].value == "text2", "Set value from id" );\r
});\r
\r
test("attr(Hash)", function() {\r
ok( document.getElementById('text1').readOnly == false, 'Set readonly attribute' );\r
});\r
\r
-test("attr(String, Object)x", function() {\r
- expect(2);\r
- stop();\r
- $.get('data/dashboard.xml', function(xml) { \r
- var titles = [];\r
- $('tab', xml).each(function() {\r
- titles.push($(this).attr('title'));\r
- });\r
- ok( titles[0] == 'Location', 'attr() in XML context: Check first title' );\r
- ok( titles[1] == 'Users', 'attr() in XML context: Check second title' );\r
- start();\r
+if ( location.protocol != "file:" ) {\r
+ test("attr(String, Object)x", function() {\r
+ expect(2);\r
+ stop();\r
+ $.get('data/dashboard.xml', function(xml) { \r
+ var titles = [];\r
+ $('tab', xml).each(function() {\r
+ titles.push($(this).attr('title'));\r
+ });\r
+ ok( titles[0] == 'Location', 'attr() in XML context: Check first title' );\r
+ ok( titles[1] == 'Users', 'attr() in XML context: Check second title' );\r
+ start();\r
+ });\r
});\r
-});\r
+}\r
\r
test("css(String|Hash)", function() {\r
expect(8);\r
ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' );\r
});\r
\r
-test("filter()", function() {\r
- isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );\r
- isSet( $("p").filter(["#ap", "#sndp"]).get(), q("ap", "sndp"), "filter(Array<String>)" );\r
- isSet( $("p").filter(function() { return !$("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );\r
-});\r
-\r
-test("not(String)", function() {\r
- ok($("#main > p#ap > a").not("#google").length == 2, "not('selector')")\r
- // TODO: Comma-based selector\r
- //isSet( $("p").not("#ap, #sndp").get(), q("firstp", "en", "sap", "first", "result"), "not('selector, selector')" );\r
-});\r
-\r
test("is(String)", function() {\r
expect(22);\r
ok( $('#form').is('form'), 'Check for element: A form must be a form' );\r
ok( pass, "Set HTML" );\r
});\r
\r
+test("filter()", function() {\r
+ expect(5);\r
+ isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );\r
+ isSet( $("p").filter(["#ap", "#sndp"]).get(), q("ap", "sndp"), "filter(Array<String>)" );\r
+ isSet( $("p").filter("#ap, #sndp").get(), q("ap", "sndp"), "filter('String, String')" );\r
+ isSet( $("p").filter("#ap,#sndp").get(), q("ap", "sndp"), "filter('String,String')" );\r
+ isSet( $("p").filter(function() { return !$("a", this).length }).get(), q("sndp", "first"), "filter(Function)" );\r
+});\r
+\r
+test("not(String)", function() {\r
+ expect(2);\r
+ ok( $("#main > p#ap > a").not("#google").length == 2, "not('selector')" );\r
+ isSet( $("p").not("#ap, #sndp").get(), q("firstp", "en", "sap", "first", "result"), "not('selector, selector')" );\r
+});\r
+\r
+\r
test("siblings([String])", function() {\r
- expect(3);\r
+ expect(4);\r
isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );\r
isSet( $("#sndp").siblings("[code]").get(), q("sap"), "Check for filtered siblings (has code child element)" ); \r
isSet( $("#sndp").siblings("[a]").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );\r
+ isSet( $("#foo").siblings("form, b").get(), q("form", "floatTest"), "Check for multiple filters" );\r
});\r
\r
test("children([String])", function() {\r
- expect(2);\r
+ expect(3);\r
isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" );\r
isSet( $("#foo").children("[code]").get(), q("sndp", "sap"), "Check for filtered children" );\r
+ isSet( $("#foo").children("#en, #sap").get(), q("en", "sap"), "Check for multiple filters" );\r
+});\r
+\r
+test("parent[s]([String])", function() {\r
+ expect(8);\r
+ ok( $("#groups").parent()[0].id == "ap", "Simple parent check" );\r
+ ok( $("#groups").parent("p")[0].id == "ap", "Filtered parent check" );\r
+ ok( $("#groups").parent("div").length == 0, "Filtered parent check, no match" );\r
+ ok( $("#groups").parent("div, p")[0].id == "ap", "Check for multiple filters" );\r
+ \r
+ ok( $("#groups").parents()[0].id == "ap", "Simple parents check" );\r
+ ok( $("#groups").parents("p")[0].id == "ap", "Filtered parents check" );\r
+ ok( $("#groups").parents("div")[0].id == "main", "Filtered parents check2" );\r
+ isSet( $("#groups").parents("p, div").get(), q("ap", "main"), "Check for multiple filters" );\r
});\r
\r
+test("next/prev([String])", function() {\r
+ expect(8);\r
+ ok( $("#ap").next()[0].id == "foo", "Simple next check" );\r
+ ok( $("#ap").next("div")[0].id == "foo", "Filtered next check" );\r
+ ok( $("#ap").next("p").length == 0, "Filtered next check, no match" );\r
+ ok( $("#ap").next("div, p")[0].id == "foo", "Multiple filters" );\r
+ \r
+ ok( $("#foo").prev()[0].id == "ap", "Simple prev check" );\r
+ ok( $("#foo").prev("p")[0].id == "ap", "Filtered prev check" );\r
+ ok( $("#foo").prev("div").length == 0, "Filtered prev check, no match" );\r
+ ok( $("#foo").prev("p, div")[0].id == "ap", "Multiple filters" );\r
+});\r
\r
test("show()", function() {\r
expect(1);\r
ok( pass, "Remove multiple classes" );\r
});\r
\r
+test("toggleClass(String)", function() {\r
+ expect(3);\r
+ var e = $("#firstp");\r
+ ok( !e.is(".test"), "Assert class not present" );\r
+ e.toggleClass("test");\r
+ ok( e.is(".test"), "Assert class present" ); \r
+ e.toggleClass("test");\r
+ ok( !e.is(".test"), "Assert class not present" );\r
+});\r
+\r
test("removeAttr(String", function() {\r
ok( $('#mark').removeAttr("class")[0].className == "", "remove class" );\r
});\r
\r
+test("text(String)", function() {\r
+ expect(1);\r
+ ok( $("#foo").text("<div><b>Hello</b> cruel world!</div>")[0].innerHTML == "<div><b>Hello</b> cruel world!</div>", "Check escaped text" );\r
+});\r