Add tests
This commit is contained in:
@@ -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 () {
|
describe('render', function () {
|
||||||
it('defaults to `ol.control.ScaleLine.render`', function () {
|
it('defaults to `ol.control.ScaleLine.render`', function () {
|
||||||
const ctrl = new ScaleLine();
|
const ctrl = new ScaleLine();
|
||||||
@@ -325,6 +338,21 @@ describe('ol.control.ScaleLine', function () {
|
|||||||
expect(ctrl.element.innerText).to.be('100 km');
|
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 () {
|
it('shows the same scale for different projections at higher resolutions', function () {
|
||||||
const ctrl = new ScaleLine();
|
const ctrl = new ScaleLine();
|
||||||
ctrl.setMap(map);
|
ctrl.setMap(map);
|
||||||
|
|||||||
Reference in New Issue
Block a user