Skip to content

Commit 775b9fc

Browse files
committed
add a jasmine test for hoverlabel.grouptitlefont
1 parent f3095bf commit 775b9fc

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/jasmine/tests/hover_label_test.js

+34
Original file line numberDiff line numberDiff line change
@@ -6144,6 +6144,40 @@ describe('hovermode: (x|y)unified', function() {
61446144
.then(done, done.fail);
61456145
});
61466146

6147+
it('should use hoverlabel.grouptitlefont for group titles', function(done) {
6148+
function assertFont(fontFamily, fontSize, fontColor) {
6149+
var hover = getHoverLabel();
6150+
var traces = hover.selectAll('g.traces');
6151+
6152+
traces.each(function() {
6153+
var e = d3Select(this);
6154+
var text = e.select('text.legendtext');
6155+
var node = text.node();
6156+
var label = node.innerHTML;
6157+
if(label.indexOf('group') !== -1) {
6158+
var textStyle = window.getComputedStyle(node);
6159+
expect(textStyle.fontFamily.split(',')[0]).toBe(fontFamily, 'wrong font family');
6160+
expect(textStyle.fontSize).toBe(fontSize, 'wrong font size');
6161+
expect(textStyle.fill).toBe(fontColor, 'wrong font color');
6162+
}
6163+
});
6164+
}
6165+
6166+
var mockCopy = Lib.extendDeep({}, groupTitlesMock);
6167+
6168+
mockCopy.layout.hoverlabel = {
6169+
grouptitlefont: {size: 20, family: 'Mono', color: 'rgb(255, 127, 0)'}
6170+
};
6171+
6172+
Plotly.newPlot(gd, mockCopy)
6173+
.then(function(gd) {
6174+
_hover(gd, { xval: 0});
6175+
6176+
assertFont('Mono', '20px', 'rgb(255, 127, 0)');
6177+
})
6178+
.then(done, done.fail);
6179+
});
6180+
61476181
it('should work with hovertemplate', function(done) {
61486182
var mockCopy = Lib.extendDeep({}, mock);
61496183
mockCopy.data[0].hovertemplate = 'hovertemplate: %{y:0.2f}';

0 commit comments

Comments
 (0)