Add tests

This commit is contained in:
Bart van den Eijnden
2022-04-01 14:29:01 +02:00
parent 5d5deee517
commit 5742f0c068

View File

@@ -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);