Skip to content

Commit 08d2e06

Browse files
committed
Add tests for hover label text
1 parent ffc8775 commit 08d2e06

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

test/jasmine/tests/hover_label_test.js

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var createGraphDiv = require('../assets/create_graph_div');
88
var destroyGraphDiv = require('../assets/destroy_graph_div');
99
var mouseEvent = require('../assets/mouse_event');
1010

11-
describe('hover info', function() {
11+
fdescribe('hover info', function() {
1212
'use strict';
1313

1414
var mock = require('@mocks/14.json'),
@@ -257,7 +257,7 @@ describe('hover info', function() {
257257
};
258258

259259
beforeEach(function() {
260-
this. gd = createGraphDiv();
260+
this.gd = createGraphDiv();
261261
});
262262

263263
it('should display the correct format when ticklabels true', function() {
@@ -281,4 +281,49 @@ describe('hover info', function() {
281281
expect(hovers.select('text')[0][0].textContent).toEqual('0.23');
282282
});
283283
});
284+
285+
describe('textmode', function() {
286+
287+
var data = [{
288+
x: [1,2,3,4],
289+
y: [2,3,4,5],
290+
mode: 'text',
291+
hoverinfo: 'text',
292+
text: ['test', null, 42, undefined]
293+
}],
294+
layout = {
295+
width: 600,
296+
height: 400
297+
};
298+
299+
beforeEach(function(done) {
300+
Plotly.plot(createGraphDiv(), data, layout).then(done);
301+
});
302+
303+
it('should show text labels', function() {
304+
mouseEvent('mousemove', 115, 310);
305+
var hovers = d3.selectAll('g.hovertext');
306+
expect(hovers.size()).toEqual(1);
307+
expect(hovers.select('text')[0][0].textContent).toEqual('test');
308+
});
309+
310+
it('should show number labels', function() {
311+
mouseEvent('mousemove', 370, 180);
312+
var hovers = d3.selectAll('g.hovertext');
313+
expect(hovers.size()).toEqual(1);
314+
expect(hovers.select('text')[0][0].textContent).toEqual('42');
315+
});
316+
317+
it('should not show null text labels', function() {
318+
mouseEvent('mousemove', 236, 246);
319+
var hovers = d3.selectAll('g.hovertext');
320+
expect(hovers.size()).toEqual(0);
321+
});
322+
323+
it('should not show undefined text labels', function() {
324+
mouseEvent('mousemove', 500, 115);
325+
var hovers = d3.selectAll('g.hovertext');
326+
expect(hovers.size()).toEqual(0);
327+
});
328+
});
284329
});

0 commit comments

Comments
 (0)