3 test("Basic requirements", function() {
5 ok( Array.prototype.push, "Array.push()" );
6 ok( Function.prototype.apply, "Function.apply()" );
7 ok( document.getElementById, "getElementById" );
8 ok( document.getElementsByTagName, "getElementsByTagName" );
9 ok( RegExp, "RegExp" );
10 ok( jQuery, "jQuery" );
14 test("length", function() {
15 ok( $("div").length == 2, "Get Number of Elements Found" );
18 test("size()", function() {
19 ok( $("div").size() == 2, "Get Number of Elements Found" );
22 test("get()", function() {
23 isSet( $("div").get(), q("main","foo"), "Get All Elements" );
26 test("get(Number)", function() {
27 ok( $("div").get(0) == document.getElementById("main"), "Get A Single Element" );
30 test("each(Function)", function() {
33 div.each(function(){this.foo = 'zoo';});
35 for ( var i = 0; i < div.size(); i++ ) {
36 if ( div.get(i).foo != "zoo" ) pass = false;
38 ok( pass, "Execute a function, Relative" );
41 test("index(Object)", function() {
43 ok( $([window, document]).index(window) == 0, "Check for index of elements" );
44 ok( $([window, document]).index(document) == 1, "Check for index of elements" );
45 var inputElements = $('#radio1,#radio2,#check1,#check2');
46 ok( inputElements.index(document.getElementById('radio1')) == 0, "Check for index of elements" );
47 ok( inputElements.index(document.getElementById('radio2')) == 1, "Check for index of elements" );
48 ok( inputElements.index(document.getElementById('check1')) == 2, "Check for index of elements" );
49 ok( inputElements.index(document.getElementById('check2')) == 3, "Check for index of elements" );
50 ok( inputElements.index(window) == -1, "Check for not found index" );
51 ok( inputElements.index(document) == -1, "Check for not found index" );
54 test("attr(String)", function() {
56 ok( $('#text1').attr('value') == "Test", 'Check for value attribute' );
57 ok( $('#text1').attr('type') == "text", 'Check for type attribute' );
58 ok( $('#radio1').attr('type') == "radio", 'Check for type attribute' );
59 ok( $('#check1').attr('type') == "checkbox", 'Check for type attribute' );
60 ok( $('#simon1').attr('rel') == "bookmark", 'Check for rel attribute' );
61 ok( $('#google').attr('title') == "Google!", 'Check for title attribute' );
62 ok( $('#mark').attr('hreflang') == "en", 'Check for hreflang attribute' );
63 ok( $('#en').attr('lang') == "en", 'Check for lang attribute' );
64 ok( $('#simon').attr('class') == "blog link", 'Check for class attribute' );
65 ok( $('#name').attr('name') == "name", 'Check for name attribute' );
66 ok( $('#text1').attr('name') == "action", 'Check for name attribute' );
67 ok( $('#form').attr('action').indexOf("formaction") >= 0, 'Check for action attribute' );
70 test("attr(Hash)", function() {
73 $("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){
74 if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false;
76 ok( pass, "Set Multiple Attributes" );
79 test("attr(String, Object)", function() {
82 div.attr("foo", "bar");
84 for ( var i = 0; i < div.size(); i++ ) {
85 if ( div.get(i).getAttribute('foo') != "bar" ) pass = false;
87 ok( pass, "Set Attribute" );
89 $("#name").attr('name', 'something');
90 ok( $("#name").name() == 'something', 'Set name attribute' );
91 $("#check2").attr('checked', true);
92 ok( document.getElementById('check2').checked == true, 'Set checked attribute' );
93 $("#check2").attr('checked', false);
94 ok( document.getElementById('check2').checked == false, 'Set checked attribute' );
95 $("#text1").attr('readonly', true);
96 ok( document.getElementById('text1').readOnly == true, 'Set readonly attribute' );
97 $("#text1").attr('readonly', false);
98 ok( document.getElementById('text1').readOnly == false, 'Set readonly attribute' );
101 test("attr(String, Object)x", function() {
104 $.get('data/dashboard.xml', function(xml) {
106 $('tab', xml).each(function() {
107 titles.push($(this).attr('title'));
109 ok( titles[0] == 'Location', 'attr() in XML context: Check first title' );
110 ok( titles[1] == 'Users', 'attr() in XML context: Check second title' );
115 test("css(String|Hash)", function() {
118 ok( $('#main').css("display") == 'none', 'Check for css property "display"');
120 ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
121 $('#foo').css({display: 'none'});
122 ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
123 $('#foo').css({display: 'block'});
124 ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
126 $('#floatTest').css({styleFloat: 'right'});
127 ok( $('#floatTest').css('styleFloat') == 'right', 'Modified CSS float using "styleFloat": Assert float is right');
128 $('#floatTest').css({cssFloat: 'left'});
129 ok( $('#floatTest').css('cssFloat') == 'left', 'Modified CSS float using "cssFloat": Assert float is left');
130 $('#floatTest').css({'float': 'right'});
131 ok( $('#floatTest').css('float') == 'right', 'Modified CSS float using "float": Assert float is right');
132 $('#floatTest').css({'font-size': '30px'});
133 ok( $('#floatTest').css('font-size') == '30px', 'Modified CSS font-size: Assert font-size is 30px');
136 test("css(String, Object)", function() {
138 ok( $('#foo').is(':visible'), 'Modifying CSS display: Assert element is visible');
139 $('#foo').css('display', 'none');
140 ok( !$('#foo').is(':visible'), 'Modified CSS display: Assert element is hidden');
141 $('#foo').css('display', 'block');
142 ok( $('#foo').is(':visible'), 'Modified CSS display: Assert element is visible');
144 $('#floatTest').css('styleFloat', 'left');
145 ok( $('#floatTest').css('styleFloat') == 'left', 'Modified CSS float using "styleFloat": Assert float is left');
146 $('#floatTest').css('cssFloat', 'right');
147 ok( $('#floatTest').css('cssFloat') == 'right', 'Modified CSS float using "cssFloat": Assert float is right');
148 $('#floatTest').css('float', 'left');
149 ok( $('#floatTest').css('float') == 'left', 'Modified CSS float using "float": Assert float is left');
150 $('#floatTest').css('font-size', '20px');
151 ok( $('#floatTest').css('font-size') == '20px', 'Modified CSS font-size: Assert font-size is 20px');
154 test("text()", function() {
155 var expected = "This link has class=\"blog\": Simon Willison's Weblog";
156 ok( $('#sap').text() == expected, 'Check for merged text of more then one element.' );
159 test("wrap(String|Element)", function() {
161 var defaultText = 'Try them out:'
162 var result = $('#first').wrap('<div class="red"><span></span></div>').text();
163 ok( defaultText == result, 'Check for wrapping of on-the-fly html' );
164 ok( $('#first').parent().parent().is('.red'), 'Check if wrapper has class "red"' );
167 var defaultText = 'Try them out:'
168 var result = $('#first').wrap(document.getElementById('empty')).parent();
169 ok( result.is('ol'), 'Check for element wrapping' );
170 ok( result.text() == defaultText, 'Check for element wrapping' );
173 test("append(String|Element|Array<Element>)", function() {
175 var defaultText = 'Try them out:'
176 var result = $('#first').append('<b>buga</b>');
177 ok( result.text() == defaultText + 'buga', 'Check if text appending works' );
178 ok( $('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
181 expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
182 $('#sap').append(document.getElementById('first'));
183 ok( expected == $('#sap').text(), "Check for appending of element" );
186 expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:Yahoo";
187 $('#sap').append([document.getElementById('first'), document.getElementById('yahoo')]);
188 ok( expected == $('#sap').text(), "Check for appending of array of elements" );
191 test("prepend(String|Element|Array<Element>)", function() {
193 var defaultText = 'Try them out:'
194 var result = $('#first').prepend('<b>buga</b>');
195 ok( result.text() == 'buga' + defaultText, 'Check if text prepending works' );
196 ok( $('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
199 expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
200 $('#sap').prepend(document.getElementById('first'));
201 ok( expected == $('#sap').text(), "Check for prepending of element" );
204 expected = "Try them out:YahooThis link has class=\"blog\": Simon Willison's Weblog";
205 $('#sap').prepend([document.getElementById('first'), document.getElementById('yahoo')]);
206 ok( expected == $('#sap').text(), "Check for prepending of array of elements" );
209 test("before(String|Element|Array<Element>)", function() {
211 var expected = 'This is a normal link: bugaYahoo';
212 $('#yahoo').before('<b>buga</b>');
213 ok( expected == $('#en').text(), 'Insert String before' );
216 expected = "This is a normal link: Try them out:Yahoo";
217 $('#yahoo').before(document.getElementById('first'));
218 ok( expected == $('#en').text(), "Insert element before" );
221 expected = "This is a normal link: Try them out:diveintomarkYahoo";
222 $('#yahoo').before([document.getElementById('first'), document.getElementById('mark')]);
223 ok( expected == $('#en').text(), "Insert array of elements before" );
226 test("after(String|Element|Array<Element>)", function() {
228 var expected = 'This is a normal link: Yahoobuga';
229 $('#yahoo').after('<b>buga</b>');
230 ok( expected == $('#en').text(), 'Insert String after' );
233 expected = "This is a normal link: YahooTry them out:";
234 $('#yahoo').after(document.getElementById('first'));
235 ok( expected == $('#en').text(), "Insert element after" );
238 expected = "This is a normal link: YahooTry them out:diveintomark";
239 $('#yahoo').after([document.getElementById('first'), document.getElementById('mark')]);
240 ok( expected == $('#en').text(), "Insert array of elements after" );
243 test("end()", function() {
245 ok( 'Yahoo' == $('#yahoo').parent().end().text(), 'Check for end' );
246 ok( $('#yahoo').end(), 'Check for end with nothing to end' );
249 test("find(String)", function() {
250 ok( 'Yahoo' == $('#foo').find('.blogTest').text(), 'Check for find' );
253 test("clone()", function() {
255 ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' );
256 var clone = $('#yahoo').clone();
257 ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' );
258 ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' );
261 test("filter()", function() {
262 isSet( $("input").filter(":checked").get(), q("radio2", "check1"), "filter(String)" );
263 isSet( $("p").filter(["#ap", "#sndp"]).get(), q("ap", "sndp"), "filter(Array<String>)" );
266 test("filter(String) - execute callback in fitting context", function() {
268 $("input").filter(":checked",function(i){
269 ok( this == q("radio2", "check1")[i], "Filter elements, context" );
273 test("filter(String) - execute callback in not-fitting context", function() {
275 $("#main > p#ap > a").filter("#foobar",function(){},function(i){
276 ok( this == q("google","groups", "mark")[i], "Filter elements, else context" );
280 test("not(String)", function() {
281 ok($("#main > p#ap > a").not("#google").length == 2, "not('selector')")
282 isSet( $("p").not("#ap, #sndp").get(), q("firstp", "en", "sap", "first", "result"), "not('selector, selector')" );
285 test("is(String)", function() {
287 ok( $('#form').is('form'), 'Check for element: A form must be a form' );
288 ok( !$('#form').is('div'), 'Check for element: A form is not a div' );
289 ok( $('#mark').is('.blog'), 'Check for class: Expected class "blog"' );
290 ok( !$('#mark').is('.link'), 'Check for class: Did not expect class "link"' );
291 ok( $('#simon').is('.blog.link'), 'Check for multiple classes: Expected classes "blog" and "link"' );
292 ok( !$('#simon').is('.blogTest'), 'Check for multiple classes: Expected classes "blog" and "link", but not "blogTest"' );
293 ok( $('#en').is('[@lang="en"]'), 'Check for attribute: Expected attribute lang to be "en"' );
294 ok( !$('#en').is('[@lang="de"]'), 'Check for attribute: Expected attribute lang to be "en", not "de"' );
295 ok( $('#text1').is('[@type="text"]'), 'Check for attribute: Expected attribute type to be "text"' );
296 ok( !$('#text1').is('[@type="radio"]'), 'Check for attribute: Expected attribute type to be "text", not "radio"' );
297 ok( $('#text2').is(':disabled'), 'Check for pseudoclass: Expected to be disabled' );
298 ok( !$('#text1').is(':disabled'), 'Check for pseudoclass: Expected not disabled' );
299 ok( $('#radio2').is(':checked'), 'Check for pseudoclass: Expected to be checked' );
300 ok( !$('#radio1').is(':checked'), 'Check for pseudoclass: Expected not checked' );
301 ok( $('#foo').is('[p]'), 'Check for child: Expected a child "p" element' );
302 ok( !$('#foo').is('[ul]'), 'Check for child: Did not expect "ul" element' );
303 ok( $('#foo').is('[p][a][code]'), 'Check for childs: Expected "p", "a" and "code" child elements' );
304 ok( !$('#foo').is('[p][a][code][ol]'), 'Check for childs: Expected "p", "a" and "code" child elements, but no "ol"' );
305 ok( !$('#foo').is(0), 'Expected false for an invalid expression - 0' );
306 ok( !$('#foo').is(null), 'Expected false for an invalid expression - null' );
307 ok( !$('#foo').is(''), 'Expected false for an invalid expression - ""' );
308 ok( !$('#foo').is(undefined), 'Expected false for an invalid expression - undefined' );
311 test("$.extend(Object, Object)", function() {
313 var settings = { xnumber1: 5, xnumber2: 7, xstring1: "peter", xstring2: "pan" },
314 options = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
315 optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
316 merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" };
317 jQuery.extend(settings, options);
318 isSet( settings, merged, "Check if extended: settings must be extended" );
319 isSet ( options, optionsCopy, "Check if not modified: options must not be modified" );
322 test("expressions - element", function() {
324 ok( $("*").size() >= 30, "Select all" );
325 t( "Element Selector", "div", ["main","foo"] );
326 t( "Element Selector", "body", ["body"] );
327 t( "Element Selector", "html", ["html"] );
328 t( "Parent Element", "div div", ["foo"] );
331 test("expressions - id", function() {
333 t( "ID Selector", "#body", ["body"] );
334 t( "ID Selector w/ Element", "body#body", ["body"] );
335 t( "ID Selector w/ Element", "ul#first", [] );
337 t( "All Children of ID", "#foo/*", ["sndp", "en", "sap"] );
338 t( "All Children of ID with no children", "#firstUL/*", [] );
341 test("expressions - class", function() {
343 t( "Class Selector", ".blog", ["mark","simon"] );
344 t( "Class Selector", ".blog.link", ["simon"] );
345 t( "Class Selector w/ Element", "a.blog", ["mark","simon"] );
346 t( "Parent Class Selector", "p .blog", ["mark","simon"] );
349 test("expressions - multiple", function() {
351 t( "Comma Support", "a.blog, div", ["mark","simon","main","foo"] );
352 t( "Comma Support", "a.blog , div", ["mark","simon","main","foo"] );
353 t( "Comma Support", "a.blog ,div", ["mark","simon","main","foo"] );
354 t( "Comma Support", "a.blog,div", ["mark","simon","main","foo"] );
357 test("expressions - child and adjacent", function() {
359 t( "Child", "p > a", ["simon1","google","groups","mark","yahoo","simon"] );
360 t( "Child", "p> a", ["simon1","google","groups","mark","yahoo","simon"] );
361 t( "Child", "p >a", ["simon1","google","groups","mark","yahoo","simon"] );
362 t( "Child", "p>a", ["simon1","google","groups","mark","yahoo","simon"] );
363 t( "Child w/ Class", "p > a.blog", ["mark","simon"] );
364 t( "All Children", "code > *", ["anchor1","anchor2"] );
365 t( "All Grandchildren", "p > * > *", ["anchor1","anchor2"] );
366 t( "Adjacent", "a + a", ["groups"] );
367 t( "Adjacent", "a +a", ["groups"] );
368 t( "Adjacent", "a+ a", ["groups"] );
369 t( "Adjacent", "a+a", ["groups"] );
370 t( "Adjacent", "p + p", ["ap","en","sap"] );
371 t( "Comma, Child, and Adjacent", "a + a, code > a", ["groups","anchor1","anchor2"] );
372 t( "First Child", "p:first-child", ["firstp","sndp"] );
375 test("expressions - attributes", function() {
377 t( "Attribute Exists", "a[@title]", ["google"] );
378 t( "Attribute Exists", "*[@title]", ["google"] );
379 t( "Attribute Exists", "[@title]", ["google"] );
381 t( "Attribute Equals", "a[@rel='bookmark']", ["simon1"] );
382 t( "Attribute Equals", 'a[@rel="bookmark"]', ["simon1"] );
383 t( "Attribute Equals", "a[@rel=bookmark]", ["simon1"] );
384 t( "Multiple Attribute Equals", "input[@type='hidden'],input[@type='radio']", ["hidden1","radio1","radio2"] );
385 t( "Multiple Attribute Equals", "input[@type=\"hidden\"],input[@type='radio']", ["hidden1","radio1","radio2"] );
386 t( "Multiple Attribute Equals", "input[@type=hidden],input[@type=radio]", ["hidden1","radio1","radio2"] );
388 t( "Attribute Begins With", "a[@href ^= 'http://www']", ["google","yahoo"] );
389 t( "Attribute Ends With", "a[@href $= 'org/']", ["mark"] );
390 t( "Attribute Contains", "a[@href *= 'google']", ["google","groups"] );
392 t( "Grouped Form Elements", "input[@name='foo[bar]']", ["hidden2"] );
394 t( ":not() Existing attribute", "select:not([@multiple])", ["select1", "select2"]);
395 t( ":not() Equals attribute", "select:not([@name=select1])", ["select2", "select3"]);
396 t( ":not() Equals quoted attribute", "select:not([@name='select1'])", ["select2", "select3"]);
399 test("expressions - pseudo (:) selctors", function() {
401 t( "First Child", "p:first-child", ["firstp","sndp"] );
402 t( "Last Child", "p:last-child", ["sap"] );
403 t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
404 t( "Empty", "ul:empty", ["firstUL"] );
405 t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name"] );
406 t( "Disabled UI Element", "input:disabled", ["text2"] );
407 t( "Checked UI Element", "input:checked", ["radio2","check1"] );
408 t( "Selected Option Element", "option:selected", ["option1a","option2d","option3b","option3c"] );
409 t( "Text Contains", "a:contains('Google')", ["google","groups"] );
410 t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
411 t( "Element Preceded By", "p ~ div", ["foo"] );
412 t( "Not", "a.blog:not(.link)", ["mark"] );
414 t( "nth Element", "p:nth(1)", ["ap"] );
415 t( "First Element", "p:first", ["firstp"] );
416 t( "Last Element", "p:last", ["first"] );
417 t( "Even Elements", "p:even", ["firstp","sndp","sap"] );
418 t( "Odd Elements", "p:odd", ["ap","en","first"] );
419 t( "Position Equals", "p:eq(1)", ["ap"] );
420 t( "Position Greater Than", "p:gt(0)", ["ap","sndp","en","sap","first"] );
421 t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] );
422 t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] );
423 t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name"] );
424 t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] );
426 t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3"] );
427 t( "Form element :radio", ":radio", ["radio1", "radio2"] );
428 t( "Form element :checkbox", ":checkbox", ["check1", "check2"] );
429 t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name"] );
430 t( "Form element :radio:checked", ":radio:checked", ["radio2"] );
431 t( "Form element :checkbox:checked", ":checkbox:checked", ["check1"] );
432 t( "Form element :checkbox:checked, :radio:checked", ":checkbox:checked, :radio:checked", ["check1", "radio2"] );
435 test("expressions - basic xpath", function() {
437 ok( jQuery.find("//*").length >= 30, "All Elements (//*)" );
438 t( "All Div Elements", "//div", ["main","foo"] );
439 t( "Absolute Path", "/html/body", ["body"] );
440 t( "Absolute Path w/ *", "/* /body", ["body"] );
441 t( "Long Absolute Path", "/html/body/dl/div/div/p", ["sndp","en","sap"] );
442 t( "Absolute and Relative Paths", "/html//div", ["main","foo"] );
443 t( "All Children, Explicit", "//code/*", ["anchor1","anchor2"] );
444 t( "All Children, Implicit", "//code/", ["anchor1","anchor2"] );
445 t( "Attribute Exists", "//a[@title]", ["google"] );
446 t( "Attribute Equals", "//a[@rel='bookmark']", ["simon1"] );
447 t( "Parent Axis", "//p/..", ["main","foo"] );
448 t( "Sibling Axis", "//p/../", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );
449 t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","sndp","en","sap"] );
450 t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] );
453 test("val()", function() {
455 ok( $("#text1").val() == "Test", "Check for value of input element" );
456 ok( !$("#text1").val() == "", "Check for value of input element" );
459 test("val(String)", function() {
461 document.getElementById('text1').value = "bla";
462 ok( $("#text1").val() == "bla", "Check for modified value of input element" );
463 $("#text1").val('test');
464 ok ( document.getElementById('text1').value == "test", "Check for modified (via val(String)) value of input element" );
467 test("html(String)", function() {
470 div.html("<b>test</b>");
472 for ( var i = 0; i < div.size(); i++ ) {
473 if ( div.get(i).childNodes.length == 0 ) pass = false;
475 ok( pass, "Set HTML" );
478 test("id()", function() {
480 ok( $(document.getElementById('main')).id() == "main", "Check for id" );
481 ok( $("#foo").id() == "foo", "Check for id" );
482 ok( !$("head").id(), "Check for id" );
485 test("title()", function() {
487 ok( $(document.getElementById('google')).title() == "Google!", "Check for title" );
488 ok( !$("#yahoo").title(), "Check for title" );
491 test("name()", function() {
493 ok( $(document.getElementById('text1')).name() == "action", "Check for name" );
494 ok( $("#hidden1").name() == "hidden", "Check for name" );
495 ok( !$("#area1").name(), "Check for name" );
499 test("siblings([String])", function() {
501 isSet( $("#en").siblings().get(), q("sndp", "sap"), "Check for siblings" );
502 isSet( $("#sndp").siblings("[code]").get(), q("sap"), "Check for filtered siblings (has code child element)" );
503 isSet( $("#sndp").siblings("[a]").get(), q("en", "sap"), "Check for filtered siblings (has anchor child element)" );
506 test("children([String])", function() {
508 isSet( $("#foo").children().get(), q("sndp", "en", "sap"), "Check for children" );
509 isSet( $("#foo").children("[code]").get(), q("sndp", "sap"), "Check for filtered children" );
513 test("show()", function() {
515 var pass = true, div = $("div");
516 div.show().each(function(){
517 if ( this.style.display == "none" ) pass = false;
522 test("addClass(String)", function() {
524 div.addClass("test");
526 for ( var i = 0; i < div.size(); i++ ) {
527 if ( div.get(i).className.indexOf("test") == -1 ) pass = false;
529 ok( pass, "Add Class" );
532 test("removeClass(String) - simple", function() {
534 var div = $("div").addClass("test").removeClass("test"),
536 for ( var i = 0; i < div.size(); i++ ) {
537 if ( div.get(i).className.indexOf("test") != -1 ) pass = false;
539 ok( pass, "Remove Class" );
542 test("removeClass(String) - add three classes and remove again", function() {
544 var div = $("div").addClass("test").addClass("foo").addClass("bar");
545 div.removeClass("test").removeClass("bar").removeClass("foo");
547 for ( var i = 0; i < div.size(); i++ ) {
548 if ( div.get(i).className.match(/test|bar|foo/) ) pass = false;
550 ok( pass, "Remove multiple classes" );