Sha256: 38df312e2a8d6a3149ffbeca67c72fe5e1ec8d47a0a367eb71a9e4cc8a3a2e87
Contents?: true
Size: 1.88 KB
Versions: 5
Compression:
Stored size: 1.88 KB
Contents
// ======================================================================== // CoreQuery Tests // ======================================================================== module("CoreQuery.setClass()"); test("setClass(existing, NO) should remove the class", function() { var cq = SC.$('<div class="existing"></div>') ; equals(cq.hasClass('existing'), YES, "cq has existing"); cq.setClass("existing", NO) ; equals(cq.hasClass('existing'), NO, 'cq should not have existing'); }); test("setClass(existing, YES) should do nothing", function() { var cq = SC.$('<div class="existing"></div>') ; equals(cq.hasClass('existing'), YES, "cq has existing"); cq.setClass("existing", YES) ; equals(cq.hasClass('existing'), YES, 'cq should have existing'); }); test("setClass(new, YES) should add the class", function() { var cq = SC.$('<div class="existing"></div>') ; equals(cq.hasClass('new'), NO, "cq does not have new"); cq.setClass("new", YES) ; equals(cq.hasClass('new'), YES, 'cq should have new'); }); test("setClass(new, NO) should do nothing", function() { var cq = SC.$('<div class="existing"></div>') ; equals(cq.hasClass('new'), NO, "cq does not have new"); cq.setClass("new", NO) ; equals(cq.hasClass('new'), NO, "cq does not have new"); }); test("setClass(mixed, YES) should work across multiple", function() { var cq = SC.$('<div class="root">\ <div class="match"></div>\ <div class="match"></div>\ </div>').find('.match'); equals(cq.length, 2, 'should have two items'); var allHaveMixed = YES; cq.each(function(el){ if (!SC.$(el).hasClass('mixed')) allHaveMixed = NO; }); equals(allHaveMixed, NO, "should not all have mixed class"); cq.setClass("mixed", YES); allHaveMixed = YES; cq.each(function(el){ if (!SC.$(el).hasClass('mixed')) allHaveMixed = NO; }); equals(cq.hasClass("mixed"), YES, "now all should have mixed class") ; }) ;
Version data entries
5 entries across 5 versions & 2 rubygems