Skip to content

Commit 13007e0

Browse files
committed
add doScroll wrapper for dragbox tests
1 parent c60424b commit 13007e0

File tree

1 file changed

+19
-32
lines changed

1 file changed

+19
-32
lines changed

Diff for: test/jasmine/tests/cartesian_interact_test.js

+19-32
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,19 @@ describe('axis zoom/pan and main plot zoom', function() {
371371
};
372372
}
373373

374+
function doScroll(subplot, directions, deltaY, opts) {
375+
return function() {
376+
opts = opts || {};
377+
var edge = opts.edge || '';
378+
var dx = opts.dx || 0;
379+
var dy = opts.dy || 0;
380+
var dragger = getDragger(subplot, directions);
381+
var coords = getNodeCoords(dragger, edge);
382+
mouseEvent('scroll', coords.x + dx, coords.y + dy, {deltaY: deltaY, element: dragger});
383+
return delay(constants.REDRAWDELAY + 10)();
384+
};
385+
}
386+
374387
function checkRanges(newRanges, msg) {
375388
msg = msg || '';
376389
if(msg) msg = ' - ' + msg;
@@ -459,26 +472,11 @@ describe('axis zoom/pan and main plot zoom', function() {
459472
.then(doDblClick('x3y3', 'nsew'))
460473
.then(checkRanges({}, 'reset x3y3'))
461474
// scroll wheel
462-
.then(function() {
463-
var mainDrag = getDragger('xy', 'nsew');
464-
var mainDragCoords = getNodeCoords(mainDrag, 'se');
465-
mouseEvent('scroll', mainDragCoords.x, mainDragCoords.y, {deltaY: 20, element: mainDrag});
466-
})
467-
.then(delay(constants.REDRAWDELAY + 10))
475+
.then(doScroll('xy', 'nsew', 20, {edge: 'se'}))
468476
.then(checkRanges({xaxis: [-0.2103, 2], yaxis: [0, 2.2103]}, 'xy main scroll'))
469-
.then(function() {
470-
var ewDrag = getDragger('xy', 'ew');
471-
var ewDragCoords = getNodeCoords(ewDrag);
472-
mouseEvent('scroll', ewDragCoords.x - 50, ewDragCoords.y, {deltaY: -20, element: ewDrag});
473-
})
474-
.then(delay(constants.REDRAWDELAY + 10))
477+
.then(doScroll('xy', 'ew', -20, {dx: -50}))
475478
.then(checkRanges({xaxis: [-0.1578, 1.8422], yaxis: [0, 2.2103]}, 'x scroll'))
476-
.then(function() {
477-
var nsDrag = getDragger('xy', 'ns');
478-
var nsDragCoords = getNodeCoords(nsDrag);
479-
mouseEvent('scroll', nsDragCoords.x, nsDragCoords.y - 50, {deltaY: -20, element: nsDrag});
480-
})
481-
.then(delay(constants.REDRAWDELAY + 10))
479+
.then(doScroll('xy', 'ns', -20, {dy: -50}))
482480
.then(checkRanges({xaxis: [-0.1578, 1.8422], yaxis: [0.1578, 2.1578]}, 'y scroll'))
483481
.catch(failTest)
484482
.then(done);
@@ -512,20 +510,9 @@ describe('axis zoom/pan and main plot zoom', function() {
512510
.then(doDblClick('xy', 'nsew'))
513511
.then(checkRanges({}, 'dblclick xy #3'))
514512
// scroll wheel
515-
.then(function() {
516-
var mainDrag = getDragger('xy', 'nsew');
517-
var mainDragCoords = getNodeCoords(mainDrag, 'se');
518-
mouseEvent('scroll', mainDragCoords.x, mainDragCoords.y, {deltaY: 20, element: mainDrag});
519-
})
520-
.then(delay(constants.REDRAWDELAY + 10))
521-
.then(checkRanges({xaxis: [-0.2103, 2], yaxis: [0, 2.2103], xaxis2: [-0.1052, 2.1052], yaxis2: [-0.1052, 2.1052]},
522-
'scroll xy'))
523-
.then(function() {
524-
var ewDrag = getDragger('xy', 'ew');
525-
var ewDragCoords = getNodeCoords(ewDrag);
526-
mouseEvent('scroll', ewDragCoords.x - 50, ewDragCoords.y, {deltaY: -20, element: ewDrag});
527-
})
528-
.then(delay(constants.REDRAWDELAY + 10))
513+
.then(doScroll('xy', 'nsew', 20, {edge: 'se'}))
514+
.then(checkRanges({xaxis: [-0.2103, 2], yaxis: [0, 2.2103], xaxis2: [-0.1052, 2.1052], yaxis2: [-0.1052, 2.1052]}, 'scroll xy'))
515+
.then(doScroll('xy', 'ew', -20, {dx: -50}))
529516
.then(checkRanges({xaxis: [-0.1578, 1.8422], yaxis: [0.1052, 2.1052]}, 'scroll x'))
530517
.catch(failTest)
531518
.then(done);

0 commit comments

Comments
 (0)