Skip to content

Commit f46e4af

Browse files
committed
Revert "remove tests related to unhandled bugs in the previous d3-geo functions"
This reverts commit a7735e6.
1 parent 1b4fd15 commit f46e4af

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed

test/jasmine/tests/geo_test.js

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,46 @@ describe('Test geo interactions', function() {
13531353
.then(done, done.fail);
13541354
});
13551355

1356+
it('should clear hover label when cursor slips off subplot', function(done) {
1357+
var gd = createGraphDiv();
1358+
var fig = Lib.extendDeep({}, require('@mocks/geo_orthographic.json'));
1359+
1360+
function _assert(msg, hoverLabelCnt) {
1361+
expect(d3SelectAll('g.hovertext').size())
1362+
.toBe(hoverLabelCnt, msg);
1363+
}
1364+
1365+
var px = 390;
1366+
var py = 290;
1367+
var cnt = 0;
1368+
1369+
Plotly.newPlot(gd, fig).then(function() {
1370+
gd.on('plotly_unhover', function() { cnt++; });
1371+
1372+
mouseEvent('mousemove', px, py);
1373+
_assert('base state', 1);
1374+
1375+
return new Promise(function(resolve) {
1376+
var interval = setInterval(function() {
1377+
px += 2;
1378+
mouseEvent('mousemove', px, py);
1379+
1380+
if(px < 402) {
1381+
_assert('- px ' + px, 1);
1382+
expect(cnt).toBe(0, 'no plotly_unhover event so far');
1383+
} else {
1384+
_assert('- px ' + px, 0);
1385+
expect(cnt).toBe(1, 'plotly_unhover event count');
1386+
1387+
clearInterval(interval);
1388+
resolve();
1389+
}
1390+
}, 100);
1391+
});
1392+
})
1393+
.then(done, done.fail);
1394+
});
1395+
13561396
it('should not confuse positions on either side of the globe', function(done) {
13571397
var gd = createGraphDiv();
13581398
var fig = Lib.extendDeep({}, require('@mocks/geo_orthographic.json'));
@@ -1381,6 +1421,66 @@ describe('Test geo interactions', function() {
13811421
.then(done, done.fail);
13821422
});
13831423

1424+
it('should plot to scope defaults when user setting lead to NaN map bounds', function(done) {
1425+
var gd = createGraphDiv();
1426+
1427+
spyOn(Lib, 'warn');
1428+
1429+
Plotly.newPlot(gd, [{
1430+
type: 'scattergeo',
1431+
lon: [0],
1432+
lat: [0]
1433+
}], {
1434+
geo: {
1435+
projection: {
1436+
type: 'kavrayskiy7',
1437+
rotation: {
1438+
lat: 38.794799,
1439+
lon: -81.622334,
1440+
}
1441+
},
1442+
center: {
1443+
lat: -81
1444+
},
1445+
lataxis: {
1446+
range: [38.794799, 45.122292]
1447+
},
1448+
lonaxis: {
1449+
range: [-82.904731, -81.622334]
1450+
}
1451+
},
1452+
width: 700,
1453+
heigth: 500
1454+
})
1455+
.then(function() {
1456+
var geoLayout = gd._fullLayout.geo;
1457+
var geo = geoLayout._subplot;
1458+
1459+
expect(geoLayout.projection.rotation).toEqual({
1460+
lon: 0, lat: 0, roll: 0,
1461+
});
1462+
expect(geoLayout.center).toEqual({
1463+
lon: 0, lat: 0
1464+
});
1465+
expect(geoLayout.lonaxis.range).toEqual([-180, 180]);
1466+
expect(geoLayout.lataxis.range).toEqual([-90, 90]);
1467+
1468+
expect(geo.viewInitial).toEqual({
1469+
'fitbounds': false,
1470+
'projection.rotation.lon': 0,
1471+
'center.lon': 0,
1472+
'center.lat': 0,
1473+
'projection.scale': 1
1474+
});
1475+
1476+
expect(Lib.warn).toHaveBeenCalledTimes(1);
1477+
expect(Lib.warn).toHaveBeenCalledWith(
1478+
'Invalid geo settings, relayout\'ing to default view.'
1479+
);
1480+
})
1481+
.then(done, done.fail);
1482+
});
1483+
13841484
it('should get hover right for choropleths involving landmasses that cross antimeridian', function(done) {
13851485
var gd = createGraphDiv();
13861486

0 commit comments

Comments
 (0)