Skip to content

Commit 506fa5e

Browse files
committed
Add test
1 parent 1400e7c commit 506fa5e

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

test/jasmine/tests/hover_label_test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,31 @@ describe('Fx.hover:', function () {
7676
})
7777
.then(done, done.fail);
7878
});
79+
80+
it('populates xval/yval from calcdata when called with a pointNumber selection', (done) => {
81+
// regression: array-mode dispatcher used to leave xval/yval undefined when
82+
// the selection carried pointNumber, which crashed scattermap (NaN lonShift)
83+
const data = [{ x: [10, 20, 30], y: [1, 2, 3] }];
84+
85+
Plotly.newPlot(gd, data)
86+
.then(() => {
87+
const traceModule = gd._fullData[0]._module;
88+
let capturedArgs;
89+
const originalHoverPoints = traceModule.hoverPoints;
90+
spyOn(traceModule, 'hoverPoints').and.callFake((...args) => {
91+
capturedArgs = args;
92+
return originalHoverPoints(...args);
93+
});
94+
95+
Plotly.Fx.hover(gd, [{ curveNumber: 0, pointNumber: 1 }]);
96+
97+
expect(traceModule.hoverPoints).toHaveBeenCalled();
98+
// signature: hoverPoints(pointData, xval, yval, hovermode, opts)
99+
expect(capturedArgs[1]).toBe(20, 'xval should match cd[1].x');
100+
expect(capturedArgs[2]).toBe(2, 'yval should match cd[1].y');
101+
})
102+
.then(done, done.fail);
103+
});
79104
});
80105

81106
describe('hover info', function () {

0 commit comments

Comments
 (0)