mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-08-16 16:45:22 +00:00
test: add coverage for Layer\_addZoomLimit (#8037)
* test: add coverage for Layer\_addZoomLimit Resolves #7762 Checks that zoom levels are updated to non-NaN values when minZoom and maxZoom are set to non-NaN values in one or many layers that are passed into addZoomLimit. Checks that min zoom level is updated to NaN when minZoom is set to NaN in at least one layer that passed into addZoomLimit, but maxZoom is never set in any layer. Vice versa for when maxZoom is set to NaN in at least one layer but minZoom is never set in any layer. Not sure if this is a feature or a bug, so need to followup with reviewers. Checks that zoom levels are undefined when minZoom and maxZoom are both set to NaN in a layer that is passed into addZoomLimit. * test: add notes to tests showing NaN usage in zoom levels * Disable test Co-authored-by: Florian Bischof <design.falke@gmail.com>
This commit is contained in:
@ -1906,4 +1906,63 @@ describe("Map", function () {
|
||||
map.panBy([50, 50]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("_addZoomLimit", function () {
|
||||
it("update zoom levels when min zoom is a number in a layer that is added to map", function () {
|
||||
map._addZoomLimit(L.tileLayer("", {minZoom: 4}));
|
||||
expect(map._layersMinZoom).to.be(4);
|
||||
});
|
||||
|
||||
it("update zoom levels when max zoom is a number in a layer that is added to map", function () {
|
||||
map._addZoomLimit(L.tileLayer("", {maxZoom: 10}));
|
||||
expect(map._layersMaxZoom).to.be(10);
|
||||
});
|
||||
|
||||
it("update zoom levels when min zoom is a number in two layers that are added to map", function () {
|
||||
map._addZoomLimit(L.tileLayer("", {minZoom: 6}));
|
||||
map._addZoomLimit(L.tileLayer("", {minZoom: 4}));
|
||||
expect(map._layersMinZoom).to.be(4);
|
||||
});
|
||||
|
||||
it("update zoom levels when max zoom is a number in two layers that are added to map", function () {
|
||||
map._addZoomLimit(L.tileLayer("", {maxZoom: 10}));
|
||||
map._addZoomLimit(L.tileLayer("", {maxZoom: 8}));
|
||||
expect(map._layersMaxZoom).to.be(10);
|
||||
});
|
||||
|
||||
// This test shows the NaN usage - it's not clear if NaN is a wanted "feature"
|
||||
it("update zoom levels when min zoom is NaN in a layer that is added to map, so that min zoom becomes NaN,", function () {
|
||||
map._addZoomLimit(L.tileLayer("", {minZoom: NaN}));
|
||||
expect(isNaN(map._layersMinZoom)).to.be(true);
|
||||
});
|
||||
|
||||
// This test shows the NaN usage - it's not clear if NaN is a wanted "feature"
|
||||
it("update zoom levels when max zoom is NaN in a layer that is added to map, so that max zoom becomes NaN", function () {
|
||||
map._addZoomLimit(L.tileLayer("", {maxZoom: NaN}));
|
||||
expect(isNaN(map._layersMaxZoom)).to.be(true);
|
||||
});
|
||||
|
||||
// This test shows the NaN usage - it's not clear if NaN is a wanted "feature"
|
||||
// Test is clearly wrong, but kept for future fixes
|
||||
// it("update zoom levels when min zoom is NaN in at least one of many layers that are added to map, so that min zoom becomes NaN", function () {
|
||||
// map._addZoomLimit(L.tileLayer("", {minZoom: 6}));
|
||||
// map._addZoomLimit(L.tileLayer("", {minZoom: NaN})); --> Results in maxZoom = NaN --> _updateZoomLevels is not called.
|
||||
// Not same logic as for maxZoom.
|
||||
// map._addZoomLimit(L.tileLayer("", {minZoom: 4}));
|
||||
// expect(isNaN(map._layersMinZoom)).to.be(true);
|
||||
// });
|
||||
|
||||
// This test shows the NaN usage - it's not clear if NaN is a wanted "feature"
|
||||
it("update zoom levels when max zoom is NaN in at least one of many layers that are added to map, so that max zoom becomes NaN", function () {
|
||||
map._addZoomLimit(L.tileLayer("", {maxZoom: 10}));
|
||||
map._addZoomLimit(L.tileLayer("", {maxZoom: 8}));
|
||||
map._addZoomLimit(L.tileLayer("", {maxZoom: NaN}));
|
||||
expect(isNaN(map._layersMaxZoom)).to.be(true);
|
||||
});
|
||||
|
||||
it("doesn't update zoom levels when min and max zoom are both NaN in a layer that is added to map", function () {
|
||||
map._addZoomLimit(L.tileLayer("", {minZoom: NaN, maxZoom: NaN}));
|
||||
expect(map._layersMinZoom === undefined && map._layersMaxZoom === undefined).to.be(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user