From 238cdc392e1d7612ae021cb6f409f628ef32969b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Fri, 7 May 2021 14:13:19 +0200 Subject: [PATCH] Add test for DragZoom with view padding --- .../spec/ol/interaction/dragzoom.test.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/browser/spec/ol/interaction/dragzoom.test.js b/test/browser/spec/ol/interaction/dragzoom.test.js index 9fef5182b2..f26d7af092 100644 --- a/test/browser/spec/ol/interaction/dragzoom.test.js +++ b/test/browser/spec/ol/interaction/dragzoom.test.js @@ -79,6 +79,27 @@ describe('ol.interaction.DragZoom', function () { }, 50); }); + it('centers the view with padding on the box geometry', function (done) { + map.getView().padding = [0, 180, 0, 0]; + + const interaction = new DragZoom({ + duration: 10, + }); + map.addInteraction(interaction); + + const box = new RenderBox(); + const extent = [-180, -90, 0, 90]; + box.geometry_ = polygonFromExtent(extent); + interaction.box_ = box; + + interaction.onBoxEnd(); + setTimeout(function () { + const view = map.getView(); + expect(view.getResolution()).to.be(1); + expect(view.calculateExtentInternal()).to.eql([-180, -90, 180, 90]); + done(); + }, 50); + }); it('sets new resolution while zooming out', function (done) { const interaction = new DragZoom({ duration: 10,