Add test for project method (#9303)

Co-authored-by: Florian Bischof <design.falke@gmail.com>
This commit is contained in:
AshwinNema
2025-03-01 14:14:37 +05:30
committed by GitHub
parent d1d4d17a53
commit ecdb13df2e

View File

@ -2219,6 +2219,34 @@ describe('Map', () => {
});
});
describe('#project', () => {
const tolerance = 1 / 1000000;
it('returns pixel coordinates relative to the top-left of the CRS extents', () => {
map.setView([40, -83], 5);
const x = latLng([40, -83]);
const a = map.project(x, 5);
expect(a.x).to.be.approximately(2207.288888, tolerance);
expect(a.y).to.be.approximately(3101.320460, tolerance);
});
it('test the other coordinates', () => {
map.setView([40, 83], 5);
const x = latLng([40, 83]);
const b = map.project(x, 5);
expect(b.x).to.be.approximately(5984.7111111, tolerance);
expect(b.y).to.be.approximately(3101.3204602, tolerance);
});
it('test the prev coordinates with different zoom', () => {
map.setView([40, 83], 5);
const x = latLng([40, 83]);
const b = map.project(x, 6);
expect(b.x).to.be.approximately(11969.422222, tolerance);
expect(b.y).to.be.approximately(6202.640920, tolerance);
});
});
describe('#latLngToLayerPoint', () => {
it('throws if map is not set before', () => {