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

Skip to content

Commit cdeb3fe

Browse files
committed
Add test for hover label format
1 parent c71973b commit cdeb3fe

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

test/jasmine/tests/hover_label_test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ var Lib = require('@src/lib');
66

77
var createGraphDiv = require('../assets/create_graph_div');
88
var destroyGraphDiv = require('../assets/destroy_graph_div');
9+
var mouseEvent = require('../assets/mouse_event');
910

1011
describe('hover info', function() {
1112
'use strict';
@@ -242,4 +243,42 @@ describe('hover info', function() {
242243
expect(d3.selectAll('g.hovertext').select('text').selectAll('tspan').size()).toEqual(2);
243244
});
244245
});
246+
247+
describe('hoverformat', function() {
248+
249+
var data = [{
250+
x: [1, 2, 3],
251+
y: [0.12345, 0.23456, 0.34567]
252+
}],
253+
layout = {
254+
yaxis: { showticklabels: true, hoverformat: ',.2r' },
255+
width: 600,
256+
height: 400
257+
};
258+
259+
beforeEach(function() {
260+
this. gd = createGraphDiv();
261+
});
262+
263+
it('should display the correct format when ticklabels true', function() {
264+
Plotly.plot(this.gd, data, layout);
265+
mouseEvent('mousemove', 310, 220);
266+
267+
var hovers = d3.selectAll('g.hovertext');
268+
269+
expect(hovers.size()).toEqual(1);
270+
expect(hovers.select('text')[0][0].textContent).toEqual('0.23');
271+
});
272+
273+
it('should display the correct format when ticklabels false', function() {
274+
layout.yaxis.showticklabels = false;
275+
Plotly.plot(this.gd, data, layout);
276+
mouseEvent('mousemove', 310, 220);
277+
278+
var hovers = d3.selectAll('g.hovertext');
279+
280+
expect(hovers.size()).toEqual(1);
281+
expect(hovers.select('text')[0][0].textContent).toEqual('0.23');
282+
});
283+
});
245284
});

0 commit comments

Comments
 (0)