Skip to content

Commit c0f38f3

Browse files
committed
Add test
1 parent 5c5ea0c commit c0f38f3

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/direct_select.test.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,5 +294,32 @@ test('direct_select', async (t) => {
294294
await cleanUp();
295295
});
296296

297+
await t.test('direct_select - stopping mode mid-drag should reset the plugin state', async () => {
298+
map.dragPan.enable();
299+
300+
const [polygonId] = Draw.add(getGeoJSON('polygon'));
301+
Draw.changeMode(Constants.modes.DIRECT_SELECT, {
302+
featureId: polygonId
303+
});
304+
305+
const originalPolygon = getGeoJSON('polygon');
306+
const centroid = turfCentroid(originalPolygon).geometry.coordinates;
307+
await afterNextRender();
308+
309+
assert.equal(map.dragPan.isEnabled(), true, 'dragPan should be enabled initially');
310+
311+
map.fire('mousedown', makeMouseEvent(centroid[0], centroid[1]));
312+
map.fire('mousemove', makeMouseEvent(centroid[0] + 15, centroid[1] + 15, { buttons: 1 }));
313+
314+
assert.equal(map.dragPan.isEnabled(), false, 'dragPan should be disabled during drag');
315+
316+
Draw.changeMode(Constants.modes.SIMPLE_SELECT);
317+
await afterNextRender();
318+
319+
assert.equal(map.dragPan.isEnabled(), true, 'dragPan should be re-enabled after stopping mode');
320+
321+
await cleanUp();
322+
});
323+
297324
document.body.removeChild(mapContainer);
298325
});

0 commit comments

Comments
 (0)