UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

170 lines (123 loc) 5.46 kB
StartTest(function(t) { t.testExtJS(function (t) { t.beforeEach(function (t) { t.setCursorPosition(0,0); }); t.it('moving mouse to coordinate / element should work', function (t) { document.body.innerHTML = '<div style="width:50px;height:50px;background:#ccc;"></div>' t.chain( { moveMouseTo : [ 100, 0 ] }, function (next) { t.isDeeply(t.currentPosition, [ 100, 0 ], 'moveMouseTo Input: Array - Cursor moved to correct place'); next(); }, { moveMouseTo : 'div' }, function (next) { t.isDeeply(t.currentPosition, [25, 25], 'moveMouseTo Input: Element - Cursor moved to correct place'); var assert = function(event) { t.is(event.buttons, 1, 'buttons property set correctly'); document.body.removeEventListener('mousemove', assert); }; // Assure that mouse move operations include the 'buttons' property t.mouseDown(t.currentPosition, null, null, function () { // IE and Safari does not support "event.buttons" property if (!Ext.isIE && !Ext.isSafari) document.body.addEventListener('mousemove', assert); next(); }); }, { moveMouseTo : [ 10, 10 ] }, { mouseUp : [] } ); }); t.xit('should support passing options object to moveMouseTo method', function (t) { document.body.innerHTML = '<div id="div" style="width:50px;height:50px;background:#ccc;"></div>' var parent = Ext.get('div') parent.on({ mousemove : function (e) { t.ok(e.shiftKey, 'mousemove event has options') }, single : true }); parent.on({ mouseover : function (e) { t.ok(e.shiftKey, 'mouseover event has options') }, single : true }); t.chain( { moveMouseTo : [ 5, 5 ], options : { shiftKey : true }}, function (next) { t.isDeeply(t.currentPosition, [ 5, 5 ], 'moveMouseTo Input: Array - Cursor moved to correct place'); next(); } ); }); t.xit('should support passing options object to moveMouseBy method', function (t) { document.body.innerHTML = '<div id="div2" style="width:50px;height:50px;background:#ccc;"></div>' var parent = Ext.get('div2'); parent.on({ mousemove : function (e) { t.ok(e.shiftKey, 'mousemove event has options') }, single : true }); parent.on({ mouseover : function (e) { t.ok(e.shiftKey, 'mouseover event has options') }, single : true }); t.chain( { moveMouseTo : [ 5, 5 ], options : { shiftKey : true }}, function (next) { t.isDeeply(t.currentPosition, [ 5, 5 ], 'moveMouseTo Input: Array - Cursor moved to correct place'); next(); } ); }); t.xit('should support passing options object to moveCursor method', function (t) { document.body.innerHTML = '<div id="div3" style="width:50px;height:50px;background:#ccc;"></div>' var parent = Ext.get('div3') parent.on({ mousemove : function (e) { t.ok(e.shiftKey, 'mousemove event has options') }, single : true }); parent.on({ mouseover : function (e) { t.ok(e.shiftKey, 'mouseover event has options') }, single : true }); t.chain( { action : 'moveCursor', by : [ 5, 5 ], options : { shiftKey : true }}, function (next) { t.isDeeply(t.currentPosition, [ 5, 5 ], 'moveMouseTo Input: Array - Cursor moved to correct place'); } ); }); t.xit('should support passing options object to moveCursor method', function (t) { document.body.innerHTML = '<div id="div4" style="width:50px;height:50px;background:#ccc;"></div>' var parent = Ext.get('div4') parent.on({ mousemove : function (e) { t.ok(e.shiftKey, 'mousemove event has options') }, single : true }); parent.on({ mouseover : function (e) { t.ok(e.shiftKey, 'mouseover event has options') }, single : true }); t.chain( { action : 'moveCursor', by : [ 5, 5 ], options : { shiftKey : true }}, function (next) { t.isDeeply(t.currentPosition, [ 5, 5 ], 'moveMouseTo Input: Array - Cursor moved to correct place'); } ); }); }); });