+\r
+test("$.each(Object,Function)", function() {\r
+ expect(8);\r
+ $.each( [0,1,2], function(i, n){\r
+ ok( i == n, "Check array iteration" );\r
+ });\r
+ \r
+ $.each( [5,6,7], function(i, n){\r
+ ok( i == n - 5, "Check array iteration" );\r
+ });\r
+ \r
+ $.each( { name: "name", lang: "lang" }, function(i, n){\r
+ ok( i == n, "Check object iteration" );\r
+ });\r
+});\r
+\r
+test("$.prop", function() {\r
+ expect(2);\r
+ var handle = function() { return this.id };\r
+ ok( $.prop($("#ap")[0], handle) == "ap", "Check with Function argument" );\r
+ ok( $.prop($("#ap")[0], "value") == "value", "Check with value argument" );\r
+});\r
+\r
+test("$.className", function() {\r
+ expect(6);\r
+ var x = $("<p>Hi</p>")[0];\r
+ var c = $.className;\r
+ c.add(x, "hi");\r
+ ok( x.className == "hi", "Check single added class" );\r
+ c.add(x, "foo bar");\r
+ ok( x.className == "hi foo bar", "Check more added classes" );\r
+ c.remove(x);\r
+ ok( x.className == "", "Remove all classes" );\r
+ c.add(x, "hi foo bar");\r
+ c.remove(x, "foo");\r
+ ok( x.className == "hi bar", "Check removal of one class" );\r
+ ok( c.has(x, "hi"), "Check has1" );\r
+ ok( c.has(x, "bar"), "Check has2" );\r
+});\r
+\r
+test("remove()", function() {\r
+ $("#ap").children().remove();\r
+ ok( $("#ap").text().length > 10, "Check text is not removed" );\r
+ ok( $("#ap").children().length == 0, "Check remove" );\r
+ \r
+ reset();\r
+ $("#ap").children().remove("a");\r
+ ok( $("#ap").text().length > 10, "Check text is not removed" );\r
+ ok( $("#ap").children().length == 1, "Check filtered remove" );\r
+});\r
+\r
+test("empty()", function() {\r
+ ok( $("#ap").children().empty().text().length == 0, "Check text is removed" );\r
+ ok( $("#ap").children().length == 4, "Check elements are not removed" );\r
+});\r
+\r
+test("eq(), gt(), lt(), contains()", function() {\r
+ ok( $("#ap a").eq(1)[0].id == "groups", "eq()" );\r
+ isSet( $("#ap a").gt(0).get(), q("groups", "anchor1", "mark"), "gt()" );\r
+ isSet( $("#ap a").lt(3).get(), q("google", "groups", "anchor1"), "lt()" );\r
+ isSet( $("#foo a").contains("log").get(), q("anchor2", "simon"), "contains()" );\r
+});\r
+\r
+test("click() context", function() {\r
+ $('<li><a href="#">Change location</a></li>').prependTo('#firstUL').find('a').bind('click', function() {\r
+ var close = $('spanx', this); // same with $(this).find('span');\r
+ ok( close.length == 0, "Element does not exist, length must be zero" );\r
+ ok( !close[0], "Element does not exist, direct access to element must return undefined" );\r
+ //console.log( close[0]); // it's the <a> and not a <span> element\r
+ return false;\r
+ }).click();\r
+});
\ No newline at end of file