Skip to content

Commit

Permalink
Added unit tests for flyTo min/maxZoom clamping
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanSanchez authored and jfirebaugh committed May 22, 2017
1 parent c9b1c3a commit 92fafd0
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/unit/ui/camera.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,46 @@ test('camera', (t) => {
camera.flyTo(options);
});

t.test('respects transform\'s maxZoom', (t) => {

const transform = new Transform(2, 10, false);
transform.resize(512, 512);

const camera = new Camera(transform, {});

camera.on('moveend', () => {
t.equalWithPrecision(camera.getZoom(), 10, 1e-10);
const { lng, lat } = camera.getCenter();
t.equalWithPrecision(lng, 12, 1e-10);
t.equalWithPrecision(lat, 34, 1e-10);

t.end();
});

const flyOptions = { center: [12, 34], zoom: 30};
camera.flyTo(flyOptions);
});

t.test('respects transform\'s minZoom', (t) => {

const transform = new Transform(2, 10, false);
transform.resize(512, 512);

const camera = new Camera(transform, {});

camera.on('moveend', () => {
t.equalWithPrecision(camera.getZoom(), 2, 1e-10);
const { lng, lat } = camera.getCenter();
t.equalWithPrecision(lng, 12, 1e-10);
t.equalWithPrecision(lat, 34, 1e-10);

t.end();
});

const flyOptions = { center: [12, 34], zoom: 1};
camera.flyTo(flyOptions);
});

t.end();
});

Expand Down

0 comments on commit 92fafd0

Please sign in to comment.