Skip to content

Commit 9b46d33

Browse files
committed
Refactor tests
1 parent 1084264 commit 9b46d33

1 file changed

Lines changed: 30 additions & 20 deletions

File tree

test/jasmine/tests/geo_test.js

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,21 +2980,12 @@ describe('Test geo zoom/pan/drag interactions:', function () {
29802980
afterEach(destroyGraphDiv);
29812981

29822982
const allTests = [
2983-
{
2984-
name: 'non-clipped',
2985-
mock: require('../../image/mocks/geo_winkel-tripel')
2986-
},
2987-
{
2988-
name: 'clipped',
2989-
mock: require('../../image/mocks/geo_orthographic')
2990-
},
2991-
{
2992-
name: 'scoped',
2993-
mock: require('../../image/mocks/geo_europe-bubbles')
2994-
}
2983+
{ name: 'non-clipped', mock: require('../../image/mocks/geo_winkel-tripel') },
2984+
{ name: 'clipped', mock: require('../../image/mocks/geo_orthographic') },
2985+
{ name: 'scoped', mock: require('../../image/mocks/geo_europe-bubbles') }
29952986
];
29962987

2997-
allTests.forEach(({ mock, name }) => {
2988+
allTests.forEach(({ name, mock }) => {
29982989
it(`${name} maxscale`, (done) => {
29992990
const fig = Lib.extendDeep({}, mock, defaultConfig);
30002991
fig.layout.geo.projection.maxscale = 1.2;
@@ -3003,8 +2994,10 @@ describe('Test geo zoom/pan/drag interactions:', function () {
30032994
// Zoom in far enough to hit limit
30042995
.then(() => scroll([200, 250], [-200, -200]))
30052996
.then(() => {
3006-
const maxScale = gd._fullLayout.geo._subplot.projection.scaleExtent()[1];
3007-
expect(gd._fullLayout.geo._subplot.projection.scale()).toEqual(maxScale);
2997+
const subplot = gd._fullLayout.geo._subplot;
2998+
const maxScale = subplot.projection.scaleExtent()[1];
2999+
expect(subplot.projection.scale()).toEqual(maxScale);
3000+
expect(maxScale).toEqual(1.2 * subplot.fitScale);
30083001
})
30093002
.then(done, done.fail);
30103003
});
@@ -3017,21 +3010,38 @@ describe('Test geo zoom/pan/drag interactions:', function () {
30173010
// Zoom out far enough to hit limit
30183011
.then(() => scroll([200, 250], [1000, 1000]))
30193012
.then(() => {
3020-
const minScale = gd._fullLayout.geo._subplot.projection.scaleExtent()[0];
3021-
expect(gd._fullLayout.geo._subplot.projection.scale()).toEqual(minScale);
3013+
const subplot = gd._fullLayout.geo._subplot;
3014+
const minScale = subplot.projection.scaleExtent()[0];
3015+
expect(subplot.projection.scale()).toEqual(minScale);
3016+
expect(minScale).toEqual(0.8 * subplot.fitScale);
30223017
})
30233018
.then(done, done.fail);
30243019
});
30253020

3026-
it(`${name} minscale greater than 1`, (done) => {
3021+
it(`${name} minscale greater than 1 clamps at init`, (done) => {
30273022
const fig = Lib.extendDeep({}, mock, defaultConfig);
30283023
fig.layout.geo.projection.minscale = 3;
30293024

30303025
Plotly.newPlot(gd, fig)
30313026
// The limit should already be hit during plot creation
30323027
.then(() => {
3033-
const minScale = gd._fullLayout.geo._subplot.projection.scaleExtent()[0];
3034-
expect(gd._fullLayout.geo._subplot.projection.scale()).toEqual(minScale);
3028+
const subplot = gd._fullLayout.geo._subplot;
3029+
const minScale = subplot.projection.scaleExtent()[0];
3030+
expect(subplot.projection.scale()).toEqual(minScale);
3031+
})
3032+
.then(done, done.fail);
3033+
});
3034+
3035+
it(`${name} maxscale less than 1 clamps at init`, (done) => {
3036+
const fig = Lib.extendDeep({}, mock, defaultConfig);
3037+
fig.layout.geo.projection.scale = 1;
3038+
fig.layout.geo.projection.maxscale = 0.5;
3039+
3040+
Plotly.newPlot(gd, fig)
3041+
.then(() => {
3042+
const subplot = gd._fullLayout.geo._subplot;
3043+
const maxScale = subplot.projection.scaleExtent()[1];
3044+
expect(subplot.projection.scale()).toEqual(maxScale);
30353045
})
30363046
.then(done, done.fail);
30373047
});

0 commit comments

Comments
 (0)