event-hover-tests.js revision 8c0728da50e402de1837852ea5482ccd74c230f7
3f3aa287185afb5d48d7ef0717054a154c372dc9Adam MooreYUI.add('event-hover-tests', function(Y) {
3f3aa287185afb5d48d7ef0717054a154c372dc9Adam Moore
3f3aa287185afb5d48d7ef0717054a154c372dc9Adam Moorefunction setUp() {
3f3aa287185afb5d48d7ef0717054a154c372dc9Adam Moore var testbed = Y.one('#testbed'),
3f3aa287185afb5d48d7ef0717054a154c372dc9Adam Moore body;
3f3aa287185afb5d48d7ef0717054a154c372dc9Adam Moore
d408aa66c7199d6b6a133c20c2116414dc70fa0aAdam Moore if (!testbed) {
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith body = Y.one('body');
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith testbed = body.create('<div id="testbed"></div>');
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith body.prepend(testbed);
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith }
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith testbed.setContent(
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith '<ul id="items">' +
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith '<li id="item1">' +
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith '<div id="div1"><p id="p1"># <em id="em1">1</em></p></div>' +
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith '</li>' +
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith '<li id="item2">' +
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith '<div id="div2"><p id="p2"># <em id="em2">2</em></p></div>' +
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith '</li>' +
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith '<li id="item3">' +
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith '<div id="div3"><p id="p3"># <em id="em3">3</em></p></div>' +
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith '</li>' +
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith '</ul>');
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith}
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smithfunction tearDown() {
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith var testbed = Y.one('#testbed');
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith if (testbed) {
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith testbed.remove().destroy(true);
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith }
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith}
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smithfunction mouse(target, out) {
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith var eventname = (out) ? 'mouseout' : 'mouseover',
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith testbed = Y.one('#testbed'),
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith testbedReached = false,
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith ancestors = Y.one(target).ancestors(function(node) {
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith if (node === testbed) {
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith testbedReached = true;
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith }
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith return !testbedReached;
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith }, true),
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith i, len;
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith if (out) {
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith for (i = ancestors.size() - 1; i >= 1; --i) {
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith Y.Event.simulate(
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith ancestors._nodes[i],
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith eventname,
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith { relatedTarget: ancestors._nodes[i - 1] });
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith }
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith } else {
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith for (i = 1, len = ancestors.size(); i < len; ++i) {
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith Y.Event.simulate(
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith ancestors._nodes[i],
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith eventname,
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith { relatedTarget: ancestors._nodes[i - 1] });
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith }
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith }
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith}
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smithvar suite = new Y.Test.Suite("event-hover"),
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith areSame = Y.Assert.areSame;
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smithsuite.add(new Y.Test.Case({
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith name: 'subscribe',
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith setUp: setUp,
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith tearDown: tearDown,
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith "test node.on('hover', over, out)": function () {
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith var overCount = 0,
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith outCount = 0,
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith target = Y.one('#em1'),
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith overType, outType, overPhase, outPhase, overEType, outEType,
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith overTarget, outTarget, overCurrentTarget, outCurrentTarget,
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith overRelTarget, outRelTarget,
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith overThisObj, outThisObj;
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith function over(e) {
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith overCount++;
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith overType = e.type;
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith overPhase = e.phase;
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith overEType = e._event.type;
2f788db79418bb9fff1a97f29f12dad42f4909efLuke Smith overThisObj = this;
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overTarget = e.target;
eea24ae7b751e818f5a88c631ddfa3799e963cd4Adam Moore overCurrentTarget = e.currentTarget;
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith }
43c15c82a8f3e7361f944d6daa02f1885c88ebf0Adam Moore
030b855bbf1937a46e1e2b88025d61e72a205469Luke Smith function out(e) {
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith outCount++;
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith outType = e.type;
edac37f62b5675c375833896993369855211cbfdTodd Kloots outPhase = e.phase;
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith outEType = e._event.type;
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith outThisObj = this;
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith outTarget = e.target;
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith outCurrentTarget = e.currentTarget;
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith }
eea24ae7b751e818f5a88c631ddfa3799e963cd4Adam Moore
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith target.on('hover', over, out);
eea24ae7b751e818f5a88c631ddfa3799e963cd4Adam Moore
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith mouse('#em1');
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith Y.Assert.areSame(1, overCount);
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith Y.Assert.areSame('hover', overType);
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith Y.Assert.areSame('over', overPhase);
d408aa66c7199d6b6a133c20c2116414dc70fa0aAdam Moore Y.Assert.areSame('mouseover', overEType);
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith Y.Assert.areSame(target, overThisObj);
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith Y.Assert.areSame(target, overTarget);
7a925457f765fe5ea2507b4629476fa3e100e4eeTodd Kloots Y.Assert.areSame(target, overCurrentTarget);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith Y.Assert.areSame(0, outCount);
63d012ee193ba8c768b2a2aade99081422759213Luke Smith Y.Assert.isUndefined(outType);
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith Y.Assert.isUndefined(outPhase);
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith Y.Assert.isUndefined(outEType);
7a925457f765fe5ea2507b4629476fa3e100e4eeTodd Kloots Y.Assert.isUndefined(outThisObj);
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith Y.Assert.isUndefined(outTarget);
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith Y.Assert.isUndefined(outCurrentTarget);
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith mouse("#em1", true);
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith Y.Assert.areSame(1, overCount);
73cf5b20418beae941f34ec39a8d87035ae01711Luke Smith Y.Assert.areSame('hover', overType);
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith Y.Assert.areSame('over', overPhase);
7a925457f765fe5ea2507b4629476fa3e100e4eeTodd Kloots Y.Assert.areSame('mouseover', overEType);
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith Y.Assert.areSame(target, overThisObj);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame(target, overTarget);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame(target, overCurrentTarget);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame(1, outCount);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame('hover', outType);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame('out', outPhase);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame('mouseout', outEType);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame(target, outThisObj);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame(target, outTarget);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame(target, outCurrentTarget);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith },
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith "test container.on('hover', over, out)": function () {
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith var overCount = 0,
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith outCount = 0,
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith target = Y.one('#item1'),
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overType, outType, overPhase, outPhase, overEType, outEType,
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overTarget, outTarget, overCurrentTarget, outCurrentTarget,
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overRelTarget, outRelTarget,
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overThisObj, outThisObj;
426d8b6487a18aa68071eecf43ed7bc4f58f36d4Luke Smith
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith function over(e) {
7a925457f765fe5ea2507b4629476fa3e100e4eeTodd Kloots overCount++;
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overType = e.type;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith overPhase = e.phase;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith overEType = e._event.type;
851a447adf0cc52bb286ca6e8d71c3f6e088030dLuke Smith overThisObj = this;
7a925457f765fe5ea2507b4629476fa3e100e4eeTodd Kloots overTarget = e.target;
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overCurrentTarget = e.currentTarget;
14017741ef334485c65013d129608513161db7c2Luke Smith }
14017741ef334485c65013d129608513161db7c2Luke Smith
7a925457f765fe5ea2507b4629476fa3e100e4eeTodd Kloots function out(e) {
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith outCount++;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith outType = e.type;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith outPhase = e.phase;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith outEType = e._event.type;
7a925457f765fe5ea2507b4629476fa3e100e4eeTodd Kloots outThisObj = this;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith outTarget = e.target;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith outCurrentTarget = e.currentTarget;
851a447adf0cc52bb286ca6e8d71c3f6e088030dLuke Smith }
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith
eea24ae7b751e818f5a88c631ddfa3799e963cd4Adam Moore target.on('hover', over, out);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith
7a925457f765fe5ea2507b4629476fa3e100e4eeTodd Kloots mouse('#em1');
0c4bb3413c8172f27fcebdf7242f5798d026064bLuke Smith
0c4bb3413c8172f27fcebdf7242f5798d026064bLuke Smith Y.Assert.areSame(1, overCount);
14017741ef334485c65013d129608513161db7c2Luke Smith Y.Assert.areSame('hover', overType);
d408aa66c7199d6b6a133c20c2116414dc70fa0aAdam Moore Y.Assert.areSame('over', overPhase);
7a925457f765fe5ea2507b4629476fa3e100e4eeTodd Kloots Y.Assert.areSame('mouseover', overEType);
14017741ef334485c65013d129608513161db7c2Luke Smith Y.Assert.areSame(target, overThisObj);
14017741ef334485c65013d129608513161db7c2Luke Smith Y.Assert.areSame(target, overTarget);
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith Y.Assert.areSame(target, overCurrentTarget);
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots
680f13616a493c7bf3a794982e07d10abd9763b3Luke Smith Y.Assert.areSame(0, outCount);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.isUndefined(outType);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.isUndefined(outPhase);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.isUndefined(outEType);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.isUndefined(outThisObj);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.isUndefined(outTarget);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.isUndefined(outCurrentTarget);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith mouse("#em1", true);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame(1, overCount);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame('hover', overType);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame('over', overPhase);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame('mouseover', overEType);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame(target, overThisObj);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame(target, overTarget);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame(target, overCurrentTarget);
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith Y.Assert.areSame(1, outCount);
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith Y.Assert.areSame('hover', outType);
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith Y.Assert.areSame('out', outPhase);
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith Y.Assert.areSame('mouseout', outEType);
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith Y.Assert.areSame(target, outThisObj);
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith Y.Assert.areSame(target, outTarget);
a5f89af11a2a0cd671fb5d37a001dfc929eba3b1Todd Kloots Y.Assert.areSame(target, outCurrentTarget);
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith },
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith "test Y.on('hover', over, out, '#foo')": function () {
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith var overCount = 0,
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith outCount = 0,
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith target = Y.one('#item1'),
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith overType, outType, overPhase, outPhase, overEType, outEType,
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith overTarget, outTarget, overCurrentTarget, outCurrentTarget,
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith overRelTarget, outRelTarget,
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith overThisObj, outThisObj;
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith function over(e) {
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith overCount++;
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith overType = e.type;
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith overPhase = e.phase;
10d8bafc5c24f3a4285cf6060a1935ba5cfc4b85Luke Smith overEType = e._event.type;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith overThisObj = this;
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith overTarget = e.target;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith overCurrentTarget = e.currentTarget;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith }
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith function out(e) {
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith outCount++;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith outType = e.type;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith outPhase = e.phase;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith outEType = e._event.type;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith outThisObj = this;
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith outTarget = e.target;
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith outCurrentTarget = e.currentTarget;
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith }
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith Y.on('hover', over, out, '#item1');
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith mouse('#em1');
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith Y.Assert.areSame(1, overCount);
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith Y.Assert.areSame('hover', overType);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.areSame('over', overPhase);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.areSame('mouseover', overEType);
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith Y.Assert.areSame(target, overThisObj);
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith Y.Assert.areSame(target, overTarget);
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith Y.Assert.areSame(target, overCurrentTarget);
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith Y.Assert.areSame(0, outCount);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.isUndefined(outType);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.isUndefined(outPhase);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.isUndefined(outEType);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.isUndefined(outThisObj);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.isUndefined(outTarget);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.isUndefined(outCurrentTarget);
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith mouse("#em1", true);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.areSame(1, overCount);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.areSame('hover', overType);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.areSame('over', overPhase);
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith Y.Assert.areSame('mouseover', overEType);
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith Y.Assert.areSame(target, overThisObj);
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith Y.Assert.areSame(target, overTarget);
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith Y.Assert.areSame(target, overCurrentTarget);
3e72e854188ef0c1927857102f15b449dc598fafLuke Smith
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.areSame(1, outCount);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.areSame('hover', outType);
14017741ef334485c65013d129608513161db7c2Luke Smith Y.Assert.areSame('out', outPhase);
669975fc1822c49f2f84c92ac2b7809df46b1093Luke Smith Y.Assert.areSame('mouseout', outEType);
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith Y.Assert.areSame(target, outThisObj);
14017741ef334485c65013d129608513161db7c2Luke Smith Y.Assert.areSame(target, outTarget);
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith Y.Assert.areSame(target, outCurrentTarget);
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith },
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith "test nodelist.on('hover', over, out)": function () {
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith var overCount = 0,
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith outCount = 0,
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith item1 = Y.one('#item1'),
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith item2 = Y.one('#item2'),
fb83a09fe023a741781ee955f4e9538d3cbe21a2Luke Smith item3 = Y.one('#item3'),
aadc0b0e666b9b335884a2437510798ae8949343Adam Moore overType = [],
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots overPhase = [],
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots overEType = [],
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overTarget = [],
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overCurrentTarget = [],
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overRelTarget = [],
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots overThisObj = [],
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots outType = [],
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots outPhase = [],
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots outEType = [],
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith outTarget = [],
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith outCurrentTarget = [],
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith outRelTarget = [],
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith outThisObj = [];
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith function over(e) {
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overCount++;
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overType.push(e.type);
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith overPhase.push(e.phase);
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots overEType.push(e._event.type);
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots overThisObj.push(this);
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots overTarget.push(e.target);
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots overCurrentTarget.push(e.currentTarget);
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots }
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith function out(e) {
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith outCount++;
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots outType.push(e.type);
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots outPhase.push(e.phase);
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots outEType.push(e._event.type);
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots outThisObj.push(this);
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots outTarget.push(e.target);
67d8986c26b16b1d9ea6e5b62e753c55af9a4f52Todd Kloots outCurrentTarget.push(e.currentTarget);
7b4d1363155303b5bfb852e5639b851bbd4dc255Luke Smith }
Y.all('#items li').on('hover', over, out);
mouse('#em1'); mouse("#em1", true);
Y.Assert.areSame(1, overCount);
Y.ArrayAssert.itemsAreSame(['hover'], overType);
Y.ArrayAssert.itemsAreSame(['over'], overPhase);
Y.ArrayAssert.itemsAreSame(['mouseover'], overEType);
Y.ArrayAssert.itemsAreSame([item1], overThisObj);
Y.ArrayAssert.itemsAreSame([item1], overTarget);
Y.ArrayAssert.itemsAreSame([item1], overCurrentTarget);
Y.Assert.areSame(1, outCount);
Y.ArrayAssert.itemsAreSame(['hover'], outType);
Y.ArrayAssert.itemsAreSame(['out'], outPhase);
Y.ArrayAssert.itemsAreSame(['mouseout'], outEType);
Y.ArrayAssert.itemsAreSame([item1], outThisObj);
Y.ArrayAssert.itemsAreSame([item1], outTarget);
Y.ArrayAssert.itemsAreSame([item1], outCurrentTarget);
mouse("#em2"); mouse("#em2", true);
mouse("#em3"); mouse("#em3", true);
Y.Assert.areSame(3, overCount);
Y.ArrayAssert.itemsAreSame(['hover','hover','hover'], overType);
Y.ArrayAssert.itemsAreSame(['over','over','over'], overPhase);
Y.ArrayAssert.itemsAreSame(['mouseover','mouseover','mouseover'], overEType);
Y.ArrayAssert.itemsAreSame([item1, item2, item3], overThisObj);
Y.ArrayAssert.itemsAreSame([item1, item2, item3], overTarget);
Y.ArrayAssert.itemsAreSame([item1, item2, item3], overCurrentTarget);
Y.Assert.areSame(3, outCount);
Y.ArrayAssert.itemsAreSame(['hover','hover','hover'], outType);
Y.ArrayAssert.itemsAreSame(['out','out','out'], outPhase);
Y.ArrayAssert.itemsAreSame(['mouseout','mouseout','mouseout'], outEType);
Y.ArrayAssert.itemsAreSame([item1, item2, item3], outThisObj);
Y.ArrayAssert.itemsAreSame([item1, item2, item3], outTarget);
Y.ArrayAssert.itemsAreSame([item1, item2, item3], outCurrentTarget);
},
"test node.delegate('hover', over, out, filter)": function () {
var overCount = 0,
outCount = 0,
items = Y.one('#items'),
item1 = Y.one('#item1'),
item2 = Y.one('#item2'),
item3 = Y.one('#item3'),
overType = [],
overPhase = [],
overEType = [],
overTarget = [],
overCurrentTarget = [],
overRelTarget = [],
overThisObj = [],
outType = [],
outPhase = [],
outEType = [],
outTarget = [],
outCurrentTarget = [],
outRelTarget = [],
outThisObj = [],
overContainer = [],
outContainer = [];
function over(e) {
overCount++;
overType.push(e.type);
overPhase.push(e.phase);
overEType.push(e._event.type);
overThisObj.push(this);
overTarget.push(e.target);
overCurrentTarget.push(e.currentTarget);
overContainer.push(e.container);
}
function out(e) {
outCount++;
outType.push(e.type);
outPhase.push(e.phase);
outEType.push(e._event.type);
outThisObj.push(this);
outTarget.push(e.target);
outCurrentTarget.push(e.currentTarget);
outContainer.push(e.container);
}
items.delegate('hover', over, out, 'li');
mouse('#em1'); mouse("#em1", true);
Y.Assert.areSame(1, overCount);
Y.ArrayAssert.itemsAreSame(['hover'], overType);
Y.ArrayAssert.itemsAreSame(['over'], overPhase);
Y.ArrayAssert.itemsAreSame(['mouseover'], overEType);
Y.ArrayAssert.itemsAreSame([item1], overThisObj);
Y.ArrayAssert.itemsAreSame([item1], overTarget);
Y.ArrayAssert.itemsAreSame([item1], overCurrentTarget);
Y.ArrayAssert.itemsAreSame([items], overContainer);
Y.Assert.areSame(1, outCount);
Y.ArrayAssert.itemsAreSame(['hover'], outType);
Y.ArrayAssert.itemsAreSame(['out'], outPhase);
Y.ArrayAssert.itemsAreSame(['mouseout'], outEType);
Y.ArrayAssert.itemsAreSame([item1], outThisObj);
Y.ArrayAssert.itemsAreSame([item1], outTarget);
Y.ArrayAssert.itemsAreSame([item1], outCurrentTarget);
Y.ArrayAssert.itemsAreSame([items], overContainer);
mouse("#em2"); mouse("#em2", true);
mouse("#em3"); mouse("#em3", true);
Y.Assert.areSame(3, overCount);
Y.ArrayAssert.itemsAreSame(['hover','hover','hover'], overType);
Y.ArrayAssert.itemsAreSame(['over','over','over'], overPhase);
Y.ArrayAssert.itemsAreSame(['mouseover','mouseover','mouseover'], overEType);
Y.ArrayAssert.itemsAreSame([item1, item2, item3], overThisObj);
Y.ArrayAssert.itemsAreSame([item1, item2, item3], overTarget);
Y.ArrayAssert.itemsAreSame([item1, item2, item3], overCurrentTarget);
Y.ArrayAssert.itemsAreSame([items, items, items], overContainer);
Y.Assert.areSame(3, outCount);
Y.ArrayAssert.itemsAreSame(['hover','hover','hover'], outType);
Y.ArrayAssert.itemsAreSame(['out','out','out'], outPhase);
Y.ArrayAssert.itemsAreSame(['mouseout','mouseout','mouseout'], outEType);
Y.ArrayAssert.itemsAreSame([item1, item2, item3], outThisObj);
Y.ArrayAssert.itemsAreSame([item1, item2, item3], outTarget);
Y.ArrayAssert.itemsAreSame([item1, item2, item3], outCurrentTarget);
Y.ArrayAssert.itemsAreSame([items, items, items], outContainer);
},
"test node.on('hover', over, out, thisObj)": function () {
var overCount = 0,
outCount = 0,
target = Y.one('#item1'),
obj = { foo: 'foo' },
overType, outType, overPhase, outPhase, overEType, outEType,
overTarget, outTarget, overCurrentTarget, outCurrentTarget,
overRelTarget, outRelTarget,
overThisObj, outThisObj, overFoo, outFoo;
function over(e) {
overCount++;
overType = e.type;
overPhase = e.phase;
overEType = e._event.type;
overThisObj = this;
overTarget = e.target;
overCurrentTarget = e.currentTarget;
overFoo = this.foo
}
function out(e) {
outCount++;
outType = e.type;
outPhase = e.phase;
outEType = e._event.type;
outThisObj = this;
outTarget = e.target;
outCurrentTarget = e.currentTarget;
outFoo = this.foo
}
target.on('hover', over, out, obj);
mouse('#em1'); mouse("#em1", true);
Y.Assert.areSame(1, overCount);
Y.Assert.areSame('hover', overType);
Y.Assert.areSame('over', overPhase);
Y.Assert.areSame('mouseover', overEType);
Y.Assert.areSame(obj, overThisObj);
Y.Assert.areSame(target, overTarget);
Y.Assert.areSame(target, overCurrentTarget);
Y.Assert.areSame('foo', overFoo);
Y.Assert.areSame(1, outCount);
Y.Assert.areSame('hover', outType);
Y.Assert.areSame('out', outPhase);
Y.Assert.areSame('mouseout', outEType);
Y.Assert.areSame(obj, outThisObj);
Y.Assert.areSame(target, outTarget);
Y.Assert.areSame(target, outCurrentTarget);
Y.Assert.areSame('foo', outFoo);
},
"test Y.on('hover', over, out, '#foo', thisObj)": function () {
var overCount = 0,
outCount = 0,
target = Y.one('#item1'),
obj = { foo: 'foo' },
overType, outType, overPhase, outPhase, overEType, outEType,
overTarget, outTarget, overCurrentTarget, outCurrentTarget,
overRelTarget, outRelTarget,
overThisObj, outThisObj, overFoo, outFoo;
function over(e) {
overCount++;
overType = e.type;
overPhase = e.phase;
overEType = e._event.type;
overThisObj = this;
overTarget = e.target;
overCurrentTarget = e.currentTarget;
overFoo = this.foo
}
function out(e) {
outCount++;
outType = e.type;
outPhase = e.phase;
outEType = e._event.type;
outThisObj = this;
outTarget = e.target;
outCurrentTarget = e.currentTarget;
outFoo = this.foo
}
Y.on('hover', over, out, '#item1', obj);
mouse('#em1'); mouse("#em1", true);
Y.Assert.areSame(1, overCount);
Y.Assert.areSame('hover', overType);
Y.Assert.areSame('over', overPhase);
Y.Assert.areSame('mouseover', overEType);
Y.Assert.areSame(obj, overThisObj);
Y.Assert.areSame(target, overTarget);
Y.Assert.areSame(target, overCurrentTarget);
Y.Assert.areSame('foo', overFoo);
Y.Assert.areSame(1, outCount);
Y.Assert.areSame('hover', outType);
Y.Assert.areSame('out', outPhase);
Y.Assert.areSame('mouseout', outEType);
Y.Assert.areSame(obj, outThisObj);
Y.Assert.areSame(target, outTarget);
Y.Assert.areSame(target, outCurrentTarget);
Y.Assert.areSame('foo', outFoo);
},
"test nodelist.on('hover', over, out, thisObj)": function () {
},
"test node.on('hover', over, out, thisObj, arg)": function () {
},
"test Y.on('hover', over, out, '#foo', thisObj, arg)": function () {
},
"test nodelist.on('hover', over, out, thisObj), arg": function () {
},
"test node.on('hover', over, out, null, arg)": function () {
},
"test Y.on('hover', over, out, '#foo', null, arg)": function () {
},
"test nodelist.on('hover', over, out, null), arg": function () {
}
}));
suite.add(new Y.Test.Case({
name: 'detach',
setUp: setUp,
tearDown: tearDown,
"test node.on('hover', over, out); node.detach('hover');": function () {
},
"test node.on('hover', over, out); node.detach('hover', over);": function () {
},
"test node.on('cat|hover', over, out); node.detach('cat|hover');": function () {
},
"test node.on('cat|hover', over, out); node.detach('cat|*');": function () {
},
"test node.on('hover', over, out); handle.detach();": function () {
}
}));
suite.add(new Y.Test.Case({
name: 'delegate',
setUp: setUp,
tearDown: tearDown
}));
Y.Test.Runner.add(suite);
}, '@VERSION@' ,{requires:['event-hover', 'test', 'event-simulate']});