Skip to content

Commit 0881bd6

Browse files
committed
plotly#313 test cases
1 parent 3d6c46b commit 0881bd6

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

test/jasmine/tests/click_test.js

+64
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,70 @@ describe('click interactions', function() {
7070
});
7171
});
7272

73+
describe('click events with hoverinfo set to none', function() {
74+
var futureData;
75+
76+
beforeEach(function(done) {
77+
gd = createGraphDiv();
78+
79+
var mockCopy = Lib.extendDeep({}, mock);
80+
mockCopy.data[0].hoverinfo = 'none';
81+
Plotly.plot(gd, mockCopy.data, mockCopy.layout)
82+
.then(done);
83+
84+
gd.on('plotly_click', function(data) {
85+
futureData = data;
86+
});
87+
});
88+
89+
it('should contain the correct fields despite hoverinfo: "none"', function() {
90+
click(pointPos[0], pointPos[1]);
91+
expect(futureData.points.length).toEqual(1);
92+
93+
var pt = futureData.points[0];
94+
expect(Object.keys(pt)).toEqual([
95+
'data', 'fullData', 'curveNumber', 'pointNumber',
96+
'x', 'y', 'xaxis', 'yaxis'
97+
]);
98+
expect(pt.curveNumber).toEqual(0);
99+
expect(pt.pointNumber).toEqual(11);
100+
expect(pt.x).toEqual(0.125);
101+
expect(pt.y).toEqual(2.125);
102+
});
103+
});
104+
105+
describe('click events with hoverinfo set to none', function() {
106+
var futureData;
107+
108+
beforeEach(function(done) {
109+
gd = createGraphDiv();
110+
111+
var mockCopy = Lib.extendDeep({}, mock);
112+
mockCopy.data[0].hoverinfo = 'none';
113+
Plotly.plot(gd, mockCopy.data, mockCopy.layout)
114+
.then(done);
115+
116+
gd.on('plotly_hover', function(data) {
117+
futureData = data;
118+
});
119+
});
120+
121+
it('should contain the correct fields despite hoverinfo: "none"', function() {
122+
click(pointPos[0], pointPos[1]);
123+
expect(futureData.points.length).toEqual(1);
124+
125+
var pt = futureData.points[0];
126+
expect(Object.keys(pt)).toEqual([
127+
'data', 'fullData', 'curveNumber', 'pointNumber',
128+
'x', 'y', 'xaxis', 'yaxis'
129+
]);
130+
expect(pt.curveNumber).toEqual(0);
131+
expect(pt.pointNumber).toEqual(11);
132+
expect(pt.x).toEqual(0.125);
133+
expect(pt.y).toEqual(2.125);
134+
});
135+
});
136+
73137
describe('double click events', function() {
74138
var futureData;
75139

test/jasmine/tests/hover_label_test.js

+25
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,31 @@ describe('hover info', function() {
244244
});
245245
});
246246

247+
describe('hover info none', function() {
248+
var mockCopy = Lib.extendDeep({}, mock);
249+
250+
mockCopy.data[0].hoverinfo = 'none';
251+
252+
beforeEach(function(done) {
253+
Plotly.plot(createGraphDiv(), mockCopy.data, mockCopy.layout).then(done);
254+
});
255+
256+
it('does not render if hover is set to none', function() {
257+
var gd = document.getElementById('graph');
258+
Fx.hover('graph', evt, 'xy');
259+
260+
var hoverTrace = gd._hoverdata[0];
261+
262+
expect(hoverTrace.curveNumber).toEqual(0);
263+
expect(hoverTrace.pointNumber).toEqual(17);
264+
expect(hoverTrace.x).toEqual(0.388);
265+
expect(hoverTrace.y).toEqual(1);
266+
267+
expect(d3.selectAll('g.axistext').size()).toEqual(0);
268+
expect(d3.selectAll('g.hovertext').size()).toEqual(0);
269+
});
270+
});
271+
247272
describe('hoverformat', function() {
248273

249274
var data = [{

0 commit comments

Comments
 (0)