Skip to content

Commit 3c280d5

Browse files
committed
add tests for various cases
1 parent 603dbe2 commit 3c280d5

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

test/jasmine/tests/geo_test.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2824,3 +2824,84 @@ describe('plotly_relayouting', function() {
28242824
});
28252825
});
28262826
});
2827+
2828+
2829+
describe('minscale and maxscale', function() {
2830+
function scroll(pos, delta) {
2831+
return new Promise(function(resolve) {
2832+
mouseEvent('mousemove', pos[0], pos[1]);
2833+
mouseEvent('scroll', pos[0], pos[1], {deltaX: delta[0], deltaY: delta[1]});
2834+
setTimeout(resolve, 100);
2835+
});
2836+
}
2837+
2838+
var gd;
2839+
2840+
beforeEach(function() { gd = createGraphDiv(); });
2841+
2842+
afterEach(destroyGraphDiv);
2843+
2844+
var allTests = [
2845+
{
2846+
name: 'non-clipped',
2847+
mock: require('../../image/mocks/geo_winkel-tripel'),
2848+
initialScale: 101.85972947889438
2849+
},
2850+
{
2851+
name: 'clipped',
2852+
mock: require('../../image/mocks/geo_orthographic'),
2853+
initialScale: 160.0000000243694,
2854+
},
2855+
{
2856+
name: 'scoped',
2857+
mock: require('../../image/mocks/geo_europe-bubbles'),
2858+
initialScale: 294.0932287044594
2859+
}
2860+
];
2861+
2862+
allTests.forEach(function(test) {
2863+
it(test.name + ' maxscale', function(done) {
2864+
var initialScale = test.initialScale;
2865+
2866+
var fig = Lib.extendDeep({}, test.mock);
2867+
fig.layout.width = 700;
2868+
fig.layout.height = 500;
2869+
fig.layout.dragmode = 'pan';
2870+
if(!fig.layout.geo.projection) fig.layout.geo.projection = {};
2871+
fig.layout.geo.projection.maxscale = 1.1;
2872+
2873+
Plotly.newPlot(gd, fig)
2874+
.then(function() {
2875+
expect(gd._fullLayout.geo._subplot.projection.scale()).toEqual(initialScale);
2876+
2877+
return scroll([200, 250], [-200, -200]);
2878+
})
2879+
.then(function() {
2880+
expect(gd._fullLayout.geo._subplot.projection.scale()).toEqual(1.1 * initialScale);
2881+
})
2882+
.then(done, done.fail);
2883+
});
2884+
2885+
it(test.name + ' minscale', function(done) {
2886+
var initialScale = test.initialScale;
2887+
2888+
var fig = Lib.extendDeep({}, test.mock);
2889+
fig.layout.width = 700;
2890+
fig.layout.height = 500;
2891+
fig.layout.dragmode = 'pan';
2892+
if(!fig.layout.geo.projection) fig.layout.geo.projection = {};
2893+
fig.layout.geo.projection.minscale = 0.9;
2894+
2895+
Plotly.newPlot(gd, fig)
2896+
.then(function() {
2897+
expect(gd._fullLayout.geo._subplot.projection.scale()).toEqual(initialScale);
2898+
2899+
return scroll([200, 250], [200, 200]);
2900+
})
2901+
.then(function() {
2902+
expect(gd._fullLayout.geo._subplot.projection.scale()).toEqual(0.9 * initialScale);
2903+
})
2904+
.then(done, done.fail);
2905+
});
2906+
});
2907+
});

0 commit comments

Comments
 (0)