diff --git a/test/browser/fixtures/scaled-land.html b/test/browser/fixtures/scaled-land.html new file mode 100644 index 00000000000..13cebf74dc9 --- /dev/null +++ b/test/browser/fixtures/scaled-land.html @@ -0,0 +1,59 @@ + + + + Mapbox GL JS debug page + + + + + + + +
+ + + + + + + + diff --git a/test/browser/zoom.test.js b/test/browser/zoom.test.js index a778eb54b2a..f06c856eb73 100644 --- a/test/browser/zoom.test.js +++ b/test/browser/zoom.test.js @@ -1,11 +1,12 @@ import {test} from '../util/test'; import browser from './util/browser'; +import {equalWithPrecision} from '../util'; test("zooming", async t => { const {driver} = browser; await t.test("double click at the center", async t => { - const canvas = await browser.getMapCanvas(`${browser.basePath}/test/browser/fixtures/land.html`); + const canvas = await browser.getMapCanvas(`${browser.basePath}/test/browser/fixtures/land.html`, 'canvas'); // Double-click on the center of the map. await driver.executeScript(browser.doubleClick, canvas); @@ -18,4 +19,20 @@ test("zooming", async t => { t.equals(zoom, 2, 'zoomed in by 1 zoom level'); }); + + await t.test("double click at the center with scaled map", async t => { + const canvas = await browser.getMapCanvas(`${browser.basePath}/test/browser/fixtures/scaled-land.html`); + + // Double-click on the center of the map. + await driver.executeScript(browser.doubleClick, canvas); + + // Wait until the map has settled, then report the zoom level back. + const center = await driver.executeAsyncScript(callback => { + /* eslint-disable no-undef */ + map.once('idle', () => callback(map.getCenter())); + }); + + equalWithPrecision(t, center.lng, -0.044, 0.001); + equalWithPrecision(t, center.lat, 0, 0.001); + }); });