From ba8ca4333cd3244fa3b6d1e53e95d2642a13d129 Mon Sep 17 00:00:00 2001 From: Andres Rivas Date: Sat, 20 Jan 2024 17:45:32 -0500 Subject: [PATCH] Map Unit Test --- spec/suites/map/MapSpec.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/suites/map/MapSpec.js b/spec/suites/map/MapSpec.js index 1445c6d660d..9923513edad 100644 --- a/spec/suites/map/MapSpec.js +++ b/spec/suites/map/MapSpec.js @@ -2611,4 +2611,30 @@ describe('Map', () => { map.flyToBounds(bounds, {animate: false}); }); }); + describe('#mouseEventToLayerPoint', function () { + var map, container; + beforeEach(function () { + container = document.createElement('div'); + container.style.width = '400px'; + container.style.height = '400px'; + document.body.appendChild(container); + map = L.map(container).setView([0, 0], 1); + }); + + afterEach(function () { + document.body.removeChild(container); + }); + + it('converts a mouse event to the correct layer point', function () { + // Create a fake mouse event at a specific position + var fakeMouseEvent = new MouseEvent('click', { + clientX: 100, + clientY: 100 + }); + container.dispatchEvent(fakeMouseEvent); + var layerPoint = map.mouseEventToLayerPoint(fakeMouseEvent); + var expectedPoint = map.containerPointToLayerPoint(map.mouseEventToContainerPoint(fakeMouseEvent)); + expect(layerPoint).to.eql(expectedPoint); + }); + }); });