Skip to content

Commit b0dbec3

Browse files
committed
pie: test issue plotly#902
* Test that 'plotly_hover' is triggered when `hoverinfo` is set to `"none"`.
1 parent a95e1c0 commit b0dbec3

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

test/jasmine/tests/hover_pie_test.js

+54
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,60 @@ function getClientPosition(selector, index) {
2323
describe('pie hovering', function() {
2424
var mock = require('@mocks/pie_simple.json');
2525

26+
describe('with hoverinfo set to none', function() {
27+
var mockCopy = Lib.extendDeep({}, mock),
28+
gd;
29+
30+
mockCopy.data[0].hoverinfo = 'none';
31+
32+
beforeEach(function(done) {
33+
gd = createGraphDiv();
34+
35+
Plotly.plot(gd, mockCopy.data, mockCopy.layout)
36+
.then(done);
37+
});
38+
39+
afterEach(destroyGraphDiv);
40+
41+
it('should fire hover event when moving from one slice to another', function(done) {
42+
var count = 0,
43+
hoverData = [];
44+
45+
gd.on('plotly_hover', function(data) {
46+
count++;
47+
hoverData.push(data);
48+
});
49+
50+
mouseEvent('mouseover', 173, 133);
51+
setTimeout(function() {
52+
mouseEvent('mouseover', 233, 193);
53+
expect(count).toEqual(2);
54+
expect(hoverData[0]).not.toEqual(hoverData[1]);
55+
done();
56+
}, 100);
57+
});
58+
59+
it('should fire unhover event when the mouse moves off the graph', function(done) {
60+
var count = 0,
61+
unhoverData = [];
62+
63+
gd.on('plotly_unhover', function(data) {
64+
count++;
65+
unhoverData.push(data);
66+
});
67+
68+
mouseEvent('mouseover', 173, 133);
69+
mouseEvent('mouseout', 173, 133);
70+
setTimeout(function() {
71+
mouseEvent('mouseover', 233, 193);
72+
mouseEvent('mouseout', 233, 193);
73+
expect(count).toEqual(2);
74+
expect(unhoverData[0]).not.toEqual(unhoverData[1]);
75+
done();
76+
}, 100);
77+
});
78+
});
79+
2680
describe('event data', function() {
2781
var mockCopy = Lib.extendDeep({}, mock),
2882
width = mockCopy.layout.width,

0 commit comments

Comments
 (0)