UNPKG

siesta-lite

Version:

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

67 lines (48 loc) 1.75 kB
StartTest({ viewportHeight : 500, viewportWidth : 800 }, function (t) { document.body.style.height = ''; t.beforeEach(function () { document.body.innerHTML = '<div style="position:relative; width: 10px; height:1500px; border-style:solid; border-width:1px;">scroller</div>' + '<div id="clicker" style="position:absolute; left: 100px; top: 600px; height:200px; background:red;">clicker</div>' document.body.scrollTop = 500 }) t.it('`getElementAtCursor`', function (t) { t.chain( { moveMouseTo : '#clicker' }, function (next) { t.is(t.getElementAtCursor(), t.query('#clicker')[ 0 ]) next() } ) }) t.it('`Move mouse to`', function (t) { t.firesOnce('#clicker', 'click') t.chain( { click : [ 110, 700 ] } ) }) t.it('`Move mouse to - need to scroll target point into view`', function (t) { document.body.scrollTop = 0 t.firesOnce('#clicker', 'click') t.chain( { click : [ 110, 700 ] } ) }) t.it('`Drag from coordinates`', function (t) { t.firesOnce('#clicker', 'mousedown') t.firesOnce(document.body, 'mouseup') t.chain( { drag : [ 110, 700 ], by : [ 50, 50 ] } ) }) t.it('`Drag from el to other el`', function (t) { t.firesOnce('#clicker', 'mousedown') t.firesOnce(document.body, 'mouseup') t.chain( { drag : '#clicker', to : document.body, toOffset : [ 160, 750 ] } ) }) });