Skip to content

Commit 92a7c90

Browse files
committed
#313 test cases
1 parent a6fb1da commit 92a7c90

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
@@ -96,6 +96,70 @@ describe('Test click interactions:', function() {
9696
});
9797
});
9898

99+
describe('click events with hoverinfo set to none', function() {
100+
var futureData;
101+
102+
beforeEach(function(done) {
103+
gd = createGraphDiv();
104+
105+
var mockCopy = Lib.extendDeep({}, mock);
106+
mockCopy.data[0].hoverinfo = 'none';
107+
Plotly.plot(gd, mockCopy.data, mockCopy.layout)
108+
.then(done);
109+
110+
gd.on('plotly_click', function(data) {
111+
futureData = data;
112+
});
113+
});
114+
115+
it('should contain the correct fields despite hoverinfo: "none"', function() {
116+
click(pointPos[0], pointPos[1]);
117+
expect(futureData.points.length).toEqual(1);
118+
119+
var pt = futureData.points[0];
120+
expect(Object.keys(pt)).toEqual([
121+
'data', 'fullData', 'curveNumber', 'pointNumber',
122+
'x', 'y', 'xaxis', 'yaxis'
123+
]);
124+
expect(pt.curveNumber).toEqual(0);
125+
expect(pt.pointNumber).toEqual(11);
126+
expect(pt.x).toEqual(0.125);
127+
expect(pt.y).toEqual(2.125);
128+
});
129+
});
130+
131+
describe('click events with hoverinfo set to none', function() {
132+
var futureData;
133+
134+
beforeEach(function(done) {
135+
gd = createGraphDiv();
136+
137+
var mockCopy = Lib.extendDeep({}, mock);
138+
mockCopy.data[0].hoverinfo = 'none';
139+
Plotly.plot(gd, mockCopy.data, mockCopy.layout)
140+
.then(done);
141+
142+
gd.on('plotly_hover', function(data) {
143+
futureData = data;
144+
});
145+
});
146+
147+
it('should contain the correct fields despite hoverinfo: "none"', function() {
148+
click(pointPos[0], pointPos[1]);
149+
expect(futureData.points.length).toEqual(1);
150+
151+
var pt = futureData.points[0];
152+
expect(Object.keys(pt)).toEqual([
153+
'data', 'fullData', 'curveNumber', 'pointNumber',
154+
'x', 'y', 'xaxis', 'yaxis'
155+
]);
156+
expect(pt.curveNumber).toEqual(0);
157+
expect(pt.pointNumber).toEqual(11);
158+
expect(pt.x).toEqual(0.125);
159+
expect(pt.y).toEqual(2.125);
160+
});
161+
});
162+
99163
describe('double click events', function() {
100164
var futureData;
101165

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)