Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d0887b8

Browse files
committed
add test for hover label after resize
1 parent acc9630 commit d0887b8

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

test/jasmine/tests/hover_label_test.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var d3 = require('d3');
22

33
var Plotly = require('@lib/index');
44
var Fx = require('@src/plots/cartesian/graph_interact');
5+
var constants = require('@src/plots/cartesian/constants');
56
var Lib = require('@src/lib');
67

78
var createGraphDiv = require('../assets/create_graph_div');
@@ -605,3 +606,49 @@ describe('hover info on overlaid subplots', function() {
605606
}).then(done);
606607
});
607608
});
609+
610+
describe('hover after resizing', function() {
611+
'use strict';
612+
613+
afterEach(destroyGraphDiv);
614+
615+
function assertLabelCount(pos, cnt, msg) {
616+
return new Promise(function(resolve) {
617+
mouseEvent('mousemove', pos[0], pos[1]);
618+
619+
setTimeout(function() {
620+
var hoverText = d3.selectAll('g.hovertext');
621+
expect(hoverText.size()).toEqual(cnt, msg);
622+
623+
resolve();
624+
}, constants.HOVERMINTIME);
625+
});
626+
}
627+
628+
it('should work', function(done) {
629+
var data = [{ y: [2, 1, 2] }],
630+
layout = { width: 600, height: 500 },
631+
gd = createGraphDiv();
632+
633+
var pos0 = [311, 409],
634+
pos1 = [407, 128];
635+
636+
Plotly.plot(gd, data, layout).then(function() {
637+
return assertLabelCount(pos0, 1, 'before resize, showing pt label');
638+
}).then(function() {
639+
return assertLabelCount(pos1, 0, 'before resize, not showing blank spot');
640+
}).then(function() {
641+
return Plotly.relayout(gd, 'width', 500);
642+
}).then(function() {
643+
return assertLabelCount(pos0, 0, 'after resize, not showing blank spot');
644+
}).then(function() {
645+
return assertLabelCount(pos1, 1, 'after resize, showing pt label');
646+
}).then(function() {
647+
return Plotly.relayout(gd, 'width', 600);
648+
}).then(function() {
649+
return assertLabelCount(pos0, 1, 'back to initial, showing pt label');
650+
}).then(function() {
651+
return assertLabelCount(pos1, 0, 'back to initial, not showing blank spot');
652+
}).then(done);
653+
});
654+
});

0 commit comments

Comments
 (0)