Skip to content

Commit 93055f0

Browse files
committed
Update tests
1 parent c2b23ea commit 93055f0

5 files changed

Lines changed: 39 additions & 48 deletions

File tree

test/jasmine/tests/choropleth_test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,10 @@ describe('Test choropleth hover:', function() {
177177
fontFamily: 'Arial'
178178
};
179179

180+
// Tests here were written for `fitbounds: false`, so set that explicitly
181+
fig.layout ||= {};
182+
fig.layout.geo = Lib.extendDeep({}, fig.layout.geo, { fitbounds: false });
183+
180184
return Plotly.newPlot(gd, fig)
181185
.then(function() {
182186
if(hasCssTransform) {

test/jasmine/tests/geo_test.js

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -607,9 +607,9 @@ describe('Test Geo layout defaults', function () {
607607
};
608608
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
609609
_assert({
610-
'projection.scale': 1,
611-
'center.lon': 15,
612-
'center.lat': 57.5,
610+
'projection.scale': null,
611+
'center.lon': null,
612+
'center.lat': null,
613613
'projection.rotation.lon': 15,
614614
'projection.rotation.lat': 0,
615615
'lonaxis.range': [-30, 60],
@@ -2514,7 +2514,7 @@ describe('Test geo zoom/pan/drag interactions:', function () {
25142514

25152515
newPlot(fig)
25162516
.then(function () {
2517-
_assert('base', [[180, 0], [180, 0], 1.1249], [[-180, -0], [350, 260], [0, 0], 114.59], undefined);
2517+
_assert('base', [[null, 0], [null, null], null], [[-180, -0], [350, 260], [0, 0], 114.59], undefined);
25182518
return drag({
25192519
path: [
25202520
[350, 250],
@@ -2528,7 +2528,13 @@ describe('Test geo zoom/pan/drag interactions:', function () {
25282528
'after east-west drag',
25292529
[[149.4, 0], [149.4, 0], 1.1249],
25302530
[[-149.4, 0], [350, 260], [0, 0], 114.59],
2531-
['geo.projection.rotation.lon', 'geo.center.lon', 'geo.fitbounds']
2531+
[
2532+
'geo.projection.rotation.lon',
2533+
'geo.center.lon',
2534+
'geo.center.lat',
2535+
'geo.projection.scale',
2536+
'geo.fitbounds'
2537+
]
25322538
);
25332539
return scroll([200, 250], [-200, -200]);
25342540
})
@@ -2558,7 +2564,7 @@ describe('Test geo zoom/pan/drag interactions:', function () {
25582564
.then(function () {
25592565
_assert(
25602566
'after double click',
2561-
[[180, 0], [180, 0], 1.1249],
2567+
[[null, 0], [null, null], null],
25622568
[[-180, -0], [350, 260], [0, 0], 114.59],
25632569
'dblclick'
25642570
);
@@ -2615,12 +2621,7 @@ describe('Test geo zoom/pan/drag interactions:', function () {
26152621
'after east-west drag',
26162622
[[-103.7, 49.3], 1],
26172623
[[103.7, -49.3], 160],
2618-
[
2619-
'geo.projection.rotation.lon',
2620-
'geo.projection.rotation.lat',
2621-
'geo.center.lon',
2622-
'geo.center.lat'
2623-
]
2624+
['geo.projection.rotation.lon', 'geo.projection.rotation.lat']
26242625
);
26252626
return drag({
26262627
path: [
@@ -2635,12 +2636,7 @@ describe('Test geo zoom/pan/drag interactions:', function () {
26352636
'after NW-SE drag',
26362637
[[-135.5, 73.8], 1],
26372638
[[135.5, -73.8], 160],
2638-
[
2639-
'geo.projection.rotation.lon',
2640-
'geo.projection.rotation.lat',
2641-
'geo.center.lon',
2642-
'geo.center.lat'
2643-
]
2639+
['geo.projection.rotation.lon', 'geo.projection.rotation.lat']
26442640
);
26452641
return scroll([300, 300], [-200, -200]);
26462642
})
@@ -2649,13 +2645,7 @@ describe('Test geo zoom/pan/drag interactions:', function () {
26492645
'after scroll',
26502646
[[-126.2, 67.1], 1.3],
26512647
[[126.2, -67.1], 211.1],
2652-
[
2653-
'geo.projection.rotation.lon',
2654-
'geo.projection.rotation.lat',
2655-
'geo.center.lon',
2656-
'geo.center.lat',
2657-
'geo.projection.scale'
2658-
]
2648+
['geo.projection.rotation.lon', 'geo.projection.rotation.lat', 'geo.projection.scale']
26592649
);
26602650
return Plotly.relayout(gd, 'geo.showocean', false);
26612651
})
@@ -2682,7 +2672,7 @@ describe('Test geo zoom/pan/drag interactions:', function () {
26822672

26832673
newPlot(fig)
26842674
.then(function () {
2685-
_assert('base', [[76.014, 19.735], 1], [[-76.014, -19.735], 160], undefined);
2675+
_assert('base', [[null, null], null], [[-76.014, -19.735], 160], undefined);
26862676
return drag({
26872677
path: [
26882678
[250, 250],
@@ -2699,8 +2689,7 @@ describe('Test geo zoom/pan/drag interactions:', function () {
26992689
[
27002690
'geo.projection.rotation.lon',
27012691
'geo.projection.rotation.lat',
2702-
'geo.center.lon',
2703-
'geo.center.lat',
2692+
'geo.projection.scale',
27042693
'geo.fitbounds'
27052694
]
27062695
);
@@ -2711,13 +2700,7 @@ describe('Test geo zoom/pan/drag interactions:', function () {
27112700
'after scroll',
27122701
[[58.694, 18.759], 1.1488],
27132702
[[-58.694, -18.759], 183.818],
2714-
[
2715-
'geo.projection.rotation.lon',
2716-
'geo.projection.rotation.lat',
2717-
'geo.center.lon',
2718-
'geo.center.lat',
2719-
'geo.projection.scale'
2720-
]
2703+
['geo.projection.rotation.lon', 'geo.projection.rotation.lat', 'geo.projection.scale']
27212704
);
27222705
return Plotly.relayout(gd, 'geo.showocean', false);
27232706
})
@@ -2731,8 +2714,7 @@ describe('Test geo zoom/pan/drag interactions:', function () {
27312714
return dblClick([350, 250]);
27322715
})
27332716
.then(function () {
2734-
// resets to initial view (viewInitial captured the fit values)
2735-
_assert('after double click', [[76.014, 19.735], 1], [[-76.014, -19.8], 160], 'dblclick');
2717+
_assert('after double click', [[null, null], null], [[-76.014, -19.8], 160], 'dblclick');
27362718
})
27372719
.then(done, done.fail);
27382720
});
@@ -2834,7 +2816,7 @@ describe('Test geo zoom/pan/drag interactions:', function () {
28342816

28352817
newPlot(fig)
28362818
.then(function () {
2837-
_assert('base', [[20.87, 49.33], 1.7303], [[247, 260], [5.7998, 49.29], 504.8559], undefined);
2819+
_assert('base', [[null, null], null], [[247, 260], [5.7998, 49.29], 504.8559], undefined);
28382820
return drag({
28392821
path: [
28402822
[250, 250],
@@ -2848,7 +2830,7 @@ describe('Test geo zoom/pan/drag interactions:', function () {
28482830
'after SW-NE drag',
28492831
[[29.059, 42.38], 1.727],
28502832
[[197, 210], [5.7988, 49.29], 504.8559],
2851-
['geo.center.lon', 'geo.center.lat', 'geo.fitbounds']
2833+
['geo.center.lon', 'geo.center.lat', 'geo.projection.scale', 'geo.fitbounds']
28522834
);
28532835
return scroll([300, 300], [-200, -200]);
28542836
})
@@ -2878,7 +2860,7 @@ describe('Test geo zoom/pan/drag interactions:', function () {
28782860
.then(function () {
28792861
_assert(
28802862
'after double click',
2881-
[[20.87, 49.33], 1.7303],
2863+
[[null, null], null],
28822864
[[247, 260], [5.7998, 49.29], 504.8559],
28832865
'dblclick'
28842866
);

test/jasmine/tests/plot_api_react_test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,7 @@ describe('Plotly.react and uirevision attributes', function() {
14111411
}],
14121412
layout: {
14131413
uirevision: mainRev,
1414-
geo: {uirevision: geoRev}
1414+
geo: {uirevision: geoRev, fitbounds: false}
14151415
}
14161416
};
14171417
}
@@ -2017,7 +2017,8 @@ describe('Test Plotly.react + interactions under uirevision:', function() {
20172017
}], {
20182018
width: 500,
20192019
height: 500,
2020-
uirevision: true
2020+
uirevision: true,
2021+
geo: {fitbounds: false}
20212022
});
20222023
}
20232024

@@ -2044,7 +2045,7 @@ describe('Test Plotly.react + interactions under uirevision:', function() {
20442045

20452046
_react()
20462047
.then(function() {
2047-
expect(gd.layout.geo).toEqual({});
2048+
expect(gd.layout.geo).toEqual({fitbounds: false});
20482049

20492050
var fullGeo = gd._fullLayout.geo;
20502051
expect(fullGeo.projection.rotation.lon).toBe(0);

test/jasmine/tests/scattergeo_test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ describe('Test scattergeo hover', function() {
314314
lon: [10, 20, 30],
315315
lat: [10, 20, 30],
316316
text: ['A', 'B', 'C']
317-
}])
317+
}], {
318+
geo: { fitbounds: false }
319+
})
318320
.then(done);
319321
});
320322

test/jasmine/tests/select_test.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,8 @@ describe('Click-to-select', function() {
654654
{ width: 1100, height: 450 }),
655655
testCase('ohlc', require('../../image/mocks/ohlc_first.json'), 669, 165, [9]),
656656
testCase('candlestick', require('../../image/mocks/finance_style.json'), 331, 162, [[], [5]]),
657-
testCase('choropleth', require('../../image/mocks/geo_choropleth-text.json'), 440, 163, [6]),
658-
testCase('scattergeo', require('../../image/mocks/geo_scattergeo-locations.json'), 285, 240, [1]),
657+
testCase('choropleth', require('../../image/mocks/geo_choropleth-text.json'), 440, 163, [6], {geo: {fitbounds: false}}),
658+
testCase('scattergeo', require('../../image/mocks/geo_scattergeo-locations.json'), 285, 240, [1], {geo: {fitbounds: false}}),
659659
testCase('scatterternary', require('../../image/mocks/ternary_markers.json'), 485, 335, [7]),
660660

661661
// Note that first trace (carpet) in mock doesn't support selection,
@@ -770,7 +770,7 @@ describe('Click-to-select', function() {
770770
describe('triggers \'plotly_selected\' before \'plotly_click\'', function() {
771771
[
772772
testCase('cartesian', require('../../image/mocks/14.json'), 270, 160, [7]),
773-
testCase('geo', require('../../image/mocks/geo_scattergeo-locations.json'), 285, 240, [1]),
773+
testCase('geo', require('../../image/mocks/geo_scattergeo-locations.json'), 285, 240, [1], {geo: {fitbounds: false}}),
774774
testCase('ternary', require('../../image/mocks/ternary_markers.json'), 485, 335, [7]),
775775
testCase('polar', require('../../image/mocks/polar_scatter.json'), 130, 290,
776776
[[], [], [], [19], [], []], { dragmode: 'zoom' })
@@ -2359,7 +2359,8 @@ describe('Test select box and lasso per trace:', function() {
23592359
showlegend: false,
23602360
dragmode: 'select',
23612361
width: 800,
2362-
height: 600
2362+
height: 600,
2363+
geo: {fitbounds: false}
23632364
}
23642365
};
23652366
addInvisible(fig);
@@ -2583,6 +2584,7 @@ describe('Test select box and lasso per trace:', function() {
25832584
fig.layout.height = 450;
25842585
fig.layout.dragmode = 'select';
25852586
fig.layout.geo.scope = 'europe';
2587+
fig.layout.geo.fitbounds = false;
25862588
addInvisible(fig, false);
25872589

25882590
// add a trace with no locations which will then make trace invisible, lacking DOM elements

0 commit comments

Comments
 (0)