// ======================================================================== // CoreQuery Tests // ======================================================================== // This file tests additions to CoreQuery. These should function even if you use // jQuery module("CoreQuery.within() && within()"); test("should return if passed RAW element that is child", function() { var cq = SC.$('
\
\
\
\
\
') ; var child = cq.find('.child1'); equals(cq.within(child.get(0)), YES, "cq.within(DOMElement) = YES") ; var notChild = SC.$('
') ; equals(cq.within(notChild.get(0)), NO, "cq.hadChild(DOMElement) = NO"); child = notChild = cq = null ; }) ; test("should return if passed CQ with element that is child", function() { var cq = SC.$('
\
\
\
\
\
') ; var child = cq.find('.child1'); equals(cq.within(child), YES, "cq.within(DOMElement) = YES") ; var notChild = SC.$('
') ; equals(cq.within(notChild), NO, "cq.hadChild(DOMElement) = NO"); child = notChild = cq = null ; }) ; test("should work if matched set has multiple element", function() { var cq = SC.$('
\
\
\
\
\
\
\
\
\
').find('.root') ; equals(cq.length, 3, "should have three element in matched set"); var child = cq.find('.child1'); equals(cq.within(child), YES, "cq.within(DOMElement) = YES") ; var notChild = SC.$('
') ; equals(cq.within(notChild), NO, "cq.hadChild(DOMElement) = NO"); child = notChild = cq = null ; }) ; test("should return YES if matching self", function() { var cq = SC.$('
'); equals(cq.within(cq), YES, "should not match"); });