Skip to content

Commit 12fc1f7

Browse files
committed
Added test to make sure gl3d unhover event data is correct
1 parent cc9b695 commit 12fc1f7

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

test/jasmine/tests/gl3d_hover_click_test.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,77 @@ describe('Test gl3d trace click/hover:', function() {
550550
.then(done, done.fail);
551551
});
552552

553+
fit('@gl should emit correct event data on unhover', function(done) {
554+
var _mock = Lib.extendDeep({}, mock2);
555+
var x = 655;
556+
var y = 221;
557+
558+
function _hover() {
559+
mouseEvent('mouseover', x, y);
560+
}
561+
562+
function _unhover() {
563+
return new Promise(function(resolve) {
564+
var x0 = x;
565+
var y0 = y;
566+
var initialElement = document.elementFromPoint(x0, y0);
567+
var canceler = setInterval(function() {
568+
x0 -= 2;
569+
y0 -= 2;
570+
mouseEvent('mouseover', x0, y0);
571+
572+
var nowElement = document.elementFromPoint(x0, y0);
573+
if(nowElement !== initialElement) {
574+
mouseEvent('mouseout', x0, y0, {element: initialElement});
575+
}
576+
}, 10);
577+
578+
gd.on('plotly_unhover', function(eventData) {
579+
clearInterval(canceler);
580+
resolve(eventData);
581+
});
582+
583+
setTimeout(function() {
584+
clearInterval(canceler);
585+
resolve(null);
586+
}, 350);
587+
});
588+
}
589+
590+
Plotly.newPlot(gd, _mock)
591+
.then(delay(20))
592+
.then(function() {
593+
gd.on('plotly_hover', function(eventData) {
594+
ptData = eventData.points[0];
595+
});
596+
gd.on('plotly_unhover', function(eventData) {
597+
ptData = eventData.points[0];
598+
});
599+
})
600+
.then(delay(20))
601+
.then(_hover)
602+
.then(delay(20))
603+
.then(function() {
604+
assertEventData(100.75, -102.63, -102.63, 0, 0, {
605+
'marker.symbol': 'circle',
606+
'marker.size': 10,
607+
'marker.color': 'blue',
608+
'marker.line.color': 'black'
609+
});
610+
})
611+
.then(_unhover)
612+
.then(delay(20))
613+
.then(function() {
614+
assertEventData(100.75, -102.63, -102.63, 0, 0, {
615+
'marker.symbol': 'circle',
616+
'marker.size': 10,
617+
'marker.color': 'blue',
618+
'marker.line.color': 'black'
619+
});
620+
})
621+
.then(done, done.fail);
622+
});
623+
553624
it('@gl should display correct face colors', function(done) {
554625
var fig = mesh3dcoloringMock;
555626

0 commit comments

Comments
 (0)