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

Skip to content

Commit 13620f1

Browse files
committed
fixup test (calcdata isn't preserved in-between cases anymore)
1 parent bd4462f commit 13620f1

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

test/jasmine/tests/scattermapbox_test.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('scattermapbox hover', function() {
4040

4141
var hoverPoints = ScatterMapbox.hoverPoints;
4242

43-
var gd, pointData;
43+
var gd;
4444

4545
beforeAll(function(done) {
4646
jasmine.addMatchers(customMatchers);
@@ -57,30 +57,30 @@ describe('scattermapbox hover', function() {
5757
Plotly.plot(gd, data).then(done);
5858
});
5959

60-
beforeEach(function() {
60+
afterAll(function() {
61+
Plotly.purge(gd);
62+
destroyGraphDiv();
63+
});
64+
65+
function getPointData(gd) {
6166
var cd = gd.calcdata,
6267
mapbox = gd._fullLayout.mapbox._subplot;
6368

64-
pointData = {
69+
return {
6570
index: false,
6671
distance: 20,
6772
cd: cd[0],
6873
trace: cd[0][0].trace,
6974
xa: mapbox.xaxis,
7075
ya: mapbox.yaxis
7176
};
72-
});
73-
74-
afterAll(function() {
75-
Plotly.purge(gd);
76-
destroyGraphDiv();
77-
});
77+
}
7878

7979
it('should generate hover label info (base case)', function() {
8080
var xval = 11,
8181
yval = 11;
8282

83-
var out = hoverPoints(pointData, xval, yval)[0];
83+
var out = hoverPoints(getPointData(gd), xval, yval)[0];
8484

8585
expect(out.index).toEqual(0);
8686
expect([out.x0, out.x1, out.y0, out.y1]).toBeCloseToArray([
@@ -94,7 +94,7 @@ describe('scattermapbox hover', function() {
9494
var xval = 11 + 720,
9595
yval = 11;
9696

97-
var out = hoverPoints(pointData, xval, yval)[0];
97+
var out = hoverPoints(getPointData(gd), xval, yval)[0];
9898

9999
expect(out.index).toEqual(0);
100100
expect([out.x0, out.x1, out.y0, out.y1]).toBeCloseToArray([
@@ -108,7 +108,7 @@ describe('scattermapbox hover', function() {
108108
var xval = 11 - 1080,
109109
yval = 11;
110110

111-
var out = hoverPoints(pointData, xval, yval)[0];
111+
var out = hoverPoints(getPointData(gd), xval, yval)[0];
112112

113113
expect(out.index).toEqual(0);
114114
expect([out.x0, out.x1, out.y0, out.y1]).toBeCloseToArray([
@@ -123,7 +123,7 @@ describe('scattermapbox hover', function() {
123123
var xval = 11,
124124
yval = 11;
125125

126-
var out = hoverPoints(pointData, xval, yval)[0];
126+
var out = hoverPoints(getPointData(gd), xval, yval)[0];
127127

128128
expect(out.extraText).toEqual('lon: 10°');
129129
done();
@@ -135,7 +135,7 @@ describe('scattermapbox hover', function() {
135135
var xval = 11,
136136
yval = 11;
137137

138-
var out = hoverPoints(pointData, xval, yval)[0];
138+
var out = hoverPoints(getPointData(gd), xval, yval)[0];
139139

140140
expect(out.extraText).toEqual('lat: 10°');
141141
done();
@@ -147,7 +147,7 @@ describe('scattermapbox hover', function() {
147147
var xval = 11,
148148
yval = 11;
149149

150-
var out = hoverPoints(pointData, xval, yval)[0];
150+
var out = hoverPoints(getPointData(gd), xval, yval)[0];
151151

152152
expect(out.extraText).toEqual('A');
153153
done();

0 commit comments

Comments
 (0)