Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b98f0fe

Browse files
committed
package heatmap hover per mock
1 parent ec277a3 commit b98f0fe

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

test/jasmine/tests/heatmap_test.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -528,19 +528,10 @@ describe('heatmap hover', function() {
528528

529529
var gd;
530530

531-
beforeAll(function(done) {
531+
beforeAll(function() {
532532
jasmine.addMatchers(customMatchers);
533-
534-
gd = createGraphDiv();
535-
536-
var mock = require('@mocks/heatmap_multi-trace.json'),
537-
mockCopy = Lib.extendDeep({}, mock);
538-
539-
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(done);
540533
});
541534

542-
afterAll(destroyGraphDiv);
543-
544535
function _hover(gd, xval, yval) {
545536
var fullLayout = gd._fullLayout,
546537
calcData = gd.calcdata,
@@ -563,24 +554,39 @@ describe('heatmap hover', function() {
563554
return hoverData;
564555
}
565556

566-
function assertLabels(hoverPoint, xLabel, yLabel, zLabel) {
557+
function assertLabels(hoverPoint, xLabel, yLabel, zLabel, text) {
567558
expect(hoverPoint.xLabelVal).toEqual(xLabel, 'have correct x label');
568559
expect(hoverPoint.yLabelVal).toEqual(yLabel, 'have correct y label');
569560
expect(hoverPoint.zLabelVal).toEqual(zLabel, 'have correct z label');
561+
expect(hoverPoint.text).toEqual(text, 'have correct text label');
570562
}
571563

572-
it('should find closest point (case 1) and should', function() {
573-
var pt = _hover(gd, 0.5, 0.5)[0];
564+
describe('for `heatmap_multi-trace`', function() {
574565

575-
expect(pt.index).toEqual([1, 0], 'have correct index');
576-
assertLabels(pt, 1, 1, 4);
577-
});
566+
beforeAll(function(done) {
567+
gd = createGraphDiv();
578568

579-
it('should find closest point (case 2) and should', function() {
580-
var pt = _hover(gd, 1.5, 0.5)[0];
569+
var mock = require('@mocks/heatmap_multi-trace.json'),
570+
mockCopy = Lib.extendDeep({}, mock);
581571

582-
expect(pt.index).toEqual([0, 0], 'have correct index');
583-
assertLabels(pt, 2, 0.2, 6);
572+
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(done);
573+
});
574+
575+
afterAll(destroyGraphDiv);
576+
577+
it('should find closest point (case 1) and should', function() {
578+
var pt = _hover(gd, 0.5, 0.5)[0];
579+
580+
expect(pt.index).toEqual([1, 0], 'have correct index');
581+
assertLabels(pt, 1, 1, 4);
582+
});
583+
584+
it('should find closest point (case 2) and should', function() {
585+
var pt = _hover(gd, 1.5, 0.5)[0];
586+
587+
expect(pt.index).toEqual([0, 0], 'have correct index');
588+
assertLabels(pt, 2, 0.2, 6);
589+
});
584590
});
585591

586592
});

0 commit comments

Comments
 (0)