Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add tests for various cases
  • Loading branch information
archmoj committed Jul 21, 2025
commit 6f2bca3b40023c8e490857db1bd07b9281047a14
78 changes: 78 additions & 0 deletions test/jasmine/tests/geo_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2824,3 +2824,81 @@ describe('plotly_relayouting', function() {
});
});
});


describe('minscale and maxscale', function() {
function scroll(pos, delta) {
return new Promise(function(resolve) {
mouseEvent('mousemove', pos[0], pos[1]);
mouseEvent('scroll', pos[0], pos[1], {deltaX: delta[0], deltaY: delta[1]});
setTimeout(resolve, 100);
});
}

var gd;

beforeEach(function() { gd = createGraphDiv(); });

afterEach(destroyGraphDiv);

var allTests = [
{
name: 'non-clipped',
mock: require('../../image/mocks/geo_winkel-tripel')
},
{
name: 'clipped',
mock: require('../../image/mocks/geo_orthographic')
},
{
name: 'scoped',
mock: require('../../image/mocks/geo_europe-bubbles')
}
];

allTests.forEach(function(test) {
it(test.name + ' maxscale', function(done) {
var fig = Lib.extendDeep({}, test.mock);
fig.layout.width = 700;
fig.layout.height = 500;
fig.layout.dragmode = 'pan';
if(!fig.layout.geo.projection) fig.layout.geo.projection = {};
fig.layout.geo.projection.maxscale = 1.2;

var initialScale;

Plotly.newPlot(gd, fig)
.then(function() {
initialScale = gd._fullLayout.geo._subplot.projection.scale();

return scroll([200, 250], [-200, -200]);
})
.then(function() {
expect(gd._fullLayout.geo._subplot.projection.scale()).toEqual(1.2 * initialScale);
})
.then(done, done.fail);
});

it(test.name + ' minscale', function(done) {
var fig = Lib.extendDeep({}, test.mock);
fig.layout.width = 700;
fig.layout.height = 500;
fig.layout.dragmode = 'pan';
if(!fig.layout.geo.projection) fig.layout.geo.projection = {};
fig.layout.geo.projection.minscale = 0.8;

var initialScale;

Plotly.newPlot(gd, fig)
.then(function() {
initialScale = gd._fullLayout.geo._subplot.projection.scale();

return scroll([200, 250], [200, 200]);
})
.then(function() {
expect(gd._fullLayout.geo._subplot.projection.scale()).toEqual(0.8 * initialScale);
})
.then(done, done.fail);
});
});
});