Skip to content

Commit 111c3ee

Browse files
committed
add jasmine test
1 parent d95d1f1 commit 111c3ee

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
@@ -26,6 +26,8 @@ var assertElemRightTo = customAssertions.assertElemRightTo;
2626
var assertElemTopsAligned = customAssertions.assertElemTopsAligned;
2727
var assertElemInside = customAssertions.assertElemInside;
2828

29+
var groupTitlesMock = require('@mocks/legendgroup-titles');
30+
2931
function touch(path, options) {
3032
var len = path.length;
3133
Lib.clearThrottle();
@@ -6078,6 +6080,38 @@ describe('hovermode: (x|y)unified', function() {
60786080
.then(done, done.fail);
60796081
});
60806082

6083+
it('should use hoverlabel.font for group titles as well as traces', function(done) {
6084+
function assertFont(fontFamily, fontSize, fontColor) {
6085+
var hover = getHoverLabel();
6086+
var traces = hover.selectAll('g.traces');
6087+
6088+
traces.each(function() {
6089+
var e = d3Select(this);
6090+
var text = e.select('text.legendtext');
6091+
var node = text.node();
6092+
6093+
var textStyle = window.getComputedStyle(node);
6094+
expect(textStyle.fontFamily.split(',')[0]).toBe(fontFamily, 'wrong font family');
6095+
expect(textStyle.fontSize).toBe(fontSize, 'wrong font size');
6096+
expect(textStyle.fill).toBe(fontColor, 'wrong font color');
6097+
});
6098+
}
6099+
6100+
var mockCopy = Lib.extendDeep({}, groupTitlesMock);
6101+
6102+
mockCopy.layout.hoverlabel = {
6103+
font: {size: 20, family: 'Mono', color: 'rgb(255, 127, 0)'}
6104+
};
6105+
6106+
Plotly.newPlot(gd, mockCopy)
6107+
.then(function(gd) {
6108+
_hover(gd, { xval: 0});
6109+
6110+
assertFont('Mono', '20px', 'rgb(255, 127, 0)');
6111+
})
6112+
.then(done, done.fail);
6113+
});
6114+
60816115
it('should work with hovertemplate', function(done) {
60826116
var mockCopy = Lib.extendDeep({}, mock);
60836117
mockCopy.data[0].hovertemplate = 'hovertemplate: %{y:0.2f}';

0 commit comments

Comments
 (0)