Skip to content

Commit 7bff254

Browse files
committed
add hovertemplate tests for scatterternary and scattermapbox
1 parent 1bdb8ae commit 7bff254

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

test/jasmine/tests/scattermapbox_test.js

+21
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var destroyGraphDiv = require('../assets/destroy_graph_div');
1010
var failTest = require('../assets/fail_test');
1111
var supplyAllDefaults = require('../assets/supply_defaults');
1212

13+
var assertHoverLabelContent = require('../assets/custom_assertions').assertHoverLabelContent;
1314
var mouseEvent = require('../assets/mouse_event');
1415
var click = require('../assets/click');
1516
var HOVERMINTIME = require('@src/components/fx').constants.HOVERMINTIME;
@@ -601,6 +602,15 @@ describe('@noCI scattermapbox hover', function() {
601602
};
602603
}
603604

605+
function checkHoverLabel(pos, content) {
606+
mouseEvent('mousemove', pos[0], pos[1]);
607+
608+
assertHoverLabelContent({
609+
nums: content[0],
610+
name: content[1]
611+
});
612+
}
613+
604614
it('should generate hover label info (base case)', function() {
605615
var xval = 11;
606616
var yval = 11;
@@ -788,6 +798,17 @@ describe('@noCI scattermapbox hover', function() {
788798
done();
789799
});
790800
});
801+
802+
it('should always display hoverlabel when hovertemplate is defined', function(done) {
803+
Plotly.restyle(gd, {
804+
name: '',
805+
hovertemplate: 'tpl2<extra></extra>'
806+
})
807+
.then(function() {
808+
checkHoverLabel([190, 215], ['tpl2', '']);
809+
done();
810+
});
811+
});
791812
});
792813

793814
describe('@noCI Test plotly events on a scattermapbox plot:', function() {

test/jasmine/tests/scatterternary_test.js

+31-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ var failTest = require('../assets/fail_test');
99
var customAssertions = require('../assets/custom_assertions');
1010
var supplyAllDefaults = require('../assets/supply_defaults');
1111

12+
var mouseEvent = require('../assets/mouse_event');
13+
var assertHoverLabelContent = customAssertions.assertHoverLabelContent;
14+
1215
var assertClip = customAssertions.assertClip;
1316
var assertNodeDisplay = customAssertions.assertNodeDisplay;
1417

@@ -334,17 +337,24 @@ describe('scatterternary hover', function() {
334337

335338
var gd;
336339

340+
function check(pos, content) {
341+
mouseEvent('mousemove', pos[0], pos[1]);
342+
343+
assertHoverLabelContent({
344+
nums: content[0],
345+
name: content[1]
346+
});
347+
}
348+
337349
beforeAll(function(done) {
338350
gd = createGraphDiv();
339-
340351
var data = [{
341352
type: 'scatterternary',
342353
a: [0.1, 0.2, 0.3],
343354
b: [0.3, 0.2, 0.1],
344355
c: [0.1, 0.4, 0.5],
345356
text: ['A', 'B', 'C']
346357
}];
347-
348358
Plotly.plot(gd, data).then(done);
349359
});
350360

@@ -418,6 +428,25 @@ describe('scatterternary hover', function() {
418428
.then(done);
419429
});
420430

431+
it('should always display hoverlabel when hovertemplate is defined', function(done) {
432+
var fig = Lib.extendDeep({}, require('@mocks/ternary_simple.json'));
433+
434+
Plotly.newPlot(gd, fig)
435+
.then(function() {
436+
return Plotly.restyle(gd, {
437+
hovertemplate: '%{a}, %{b}, %{c}',
438+
name: '',
439+
text: null,
440+
hovertext: null
441+
});
442+
})
443+
.then(function() {
444+
check([380, 210], ['0.5, 0.25, 0.25']);
445+
})
446+
.catch(failTest)
447+
.then(done);
448+
});
449+
421450
});
422451

423452
describe('Test scatterternary *cliponaxis*', function() {

0 commit comments

Comments
 (0)