diff --git a/test/browser/spec/ol/control/scaleline.test.js b/test/browser/spec/ol/control/scaleline.test.js index 076f83ff36..85cdefc536 100644 --- a/test/browser/spec/ol/control/scaleline.test.js +++ b/test/browser/spec/ol/control/scaleline.test.js @@ -79,6 +79,19 @@ describe('ol.control.ScaleLine', function () { }); }); + describe('maxWidth', function () { + it('defaults to undefined', function () { + const ctrl = new ScaleLine(); + expect(ctrl.maxWidth_).to.be(undefined); + }); + it('can be configured', function () { + const ctrl = new ScaleLine({ + maxWidth: 4711, + }); + expect(ctrl.maxWidth_).to.be(4711); + }); + }); + describe('render', function () { it('defaults to `ol.control.ScaleLine.render`', function () { const ctrl = new ScaleLine(); @@ -325,6 +338,21 @@ describe('ol.control.ScaleLine', function () { expect(ctrl.element.innerText).to.be('100 km'); }); + it('maxWidth is applied correctly', function () { + const ctrl = new ScaleLine({maxWidth: 50}); + ctrl.setMap(map); + map.setView( + new View({ + center: fromLonLat([-85.685, 39.891], 'Indiana-East'), + zoom: 7, + projection: 'Indiana-East', + }) + ); + map.renderSync(); + // without maxWidth set this would be 100 km + expect(ctrl.element.innerText).to.be('50 km'); + }); + it('shows the same scale for different projections at higher resolutions', function () { const ctrl = new ScaleLine(); ctrl.setMap(map);