Skip to content

Commit 16b01f0

Browse files
committed
add test of ternary+cartesian hover in compare mode
1 parent 93c5a88 commit 16b01f0

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

test/jasmine/tests/hover_label_test.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1375,6 +1375,8 @@ describe('hover on fill', function() {
13751375
var gd = createGraphDiv();
13761376

13771377
Plotly.plot(gd, mock.data, mock.layout).then(function() {
1378+
expect(gd._fullLayout.hovermode).toBe('closest');
1379+
13781380
// hover over a point when that's closest, even if you're over
13791381
// a fill, because by default we have hoveron='points+fills'
13801382
return assertLabelsCorrect([237, 150], [240.0, 144],
@@ -1402,7 +1404,35 @@ describe('hover on fill', function() {
14021404
}).then(function() {
14031405
// then make sure we can still select a *different* item afterward
14041406
return assertLabelsCorrect([237, 218], [266.75, 265], 'trace 1');
1405-
}).then(done);
1407+
})
1408+
.catch(fail)
1409+
.then(done);
1410+
});
1411+
1412+
it('should act like closest mode on ternary when cartesian is in compare mode', function(done) {
1413+
var mock = Lib.extendDeep({}, require('@mocks/ternary_fill.json'));
1414+
var gd = createGraphDiv();
1415+
1416+
mock.data.push({y: [7, 8, 9]});
1417+
mock.layout.xaxis = {domain: [0.8, 1], visible: false};
1418+
mock.layout.yaxis = {domain: [0.8, 1], visible: false};
1419+
1420+
Plotly.plot(gd, mock.data, mock.layout).then(function() {
1421+
expect(gd._fullLayout.hovermode).toBe('x');
1422+
1423+
// hover over a point when that's closest, even if you're over
1424+
// a fill, because by default we have hoveron='points+fills'
1425+
return assertLabelsCorrect([237, 150], [240.0, 144],
1426+
'trace 2Component A: 0.8Component B: 0.1Component C: 0.1');
1427+
}).then(function() {
1428+
// hovers over fills
1429+
return assertLabelsCorrect([237, 170], [247.7, 166], 'trace 2');
1430+
}).then(function() {
1431+
// hover on the cartesian trace in the corner
1432+
return assertLabelsCorrect([363, 122], [363, 122], 'trace 38');
1433+
})
1434+
.catch(fail)
1435+
.then(done);
14061436
});
14071437
});
14081438

0 commit comments

Comments
 (0)