Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add jasmine test
  • Loading branch information
archmoj committed Aug 25, 2021
commit 111c3ee62d706c92d240320636d272e24baffaf9
34 changes: 34 additions & 0 deletions test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ var assertElemRightTo = customAssertions.assertElemRightTo;
var assertElemTopsAligned = customAssertions.assertElemTopsAligned;
var assertElemInside = customAssertions.assertElemInside;

var groupTitlesMock = require('@mocks/legendgroup-titles');

function touch(path, options) {
var len = path.length;
Lib.clearThrottle();
Expand Down Expand Up @@ -6078,6 +6080,38 @@ describe('hovermode: (x|y)unified', function() {
.then(done, done.fail);
});

it('should use hoverlabel.font for group titles as well as traces', function(done) {
function assertFont(fontFamily, fontSize, fontColor) {
var hover = getHoverLabel();
var traces = hover.selectAll('g.traces');

traces.each(function() {
var e = d3Select(this);
var text = e.select('text.legendtext');
var node = text.node();

var textStyle = window.getComputedStyle(node);
expect(textStyle.fontFamily.split(',')[0]).toBe(fontFamily, 'wrong font family');
expect(textStyle.fontSize).toBe(fontSize, 'wrong font size');
expect(textStyle.fill).toBe(fontColor, 'wrong font color');
});
}

var mockCopy = Lib.extendDeep({}, groupTitlesMock);

mockCopy.layout.hoverlabel = {
font: {size: 20, family: 'Mono', color: 'rgb(255, 127, 0)'}
};

Plotly.newPlot(gd, mockCopy)
.then(function(gd) {
_hover(gd, { xval: 0});

assertFont('Mono', '20px', 'rgb(255, 127, 0)');
})
.then(done, done.fail);
});

it('should work with hovertemplate', function(done) {
var mockCopy = Lib.extendDeep({}, mock);
mockCopy.data[0].hovertemplate = 'hovertemplate: %{y:0.2f}';
Expand Down