diff --git a/test/simple_select.test.js b/test/simple_select.test.js index 0902405f2..b82132c1b 100644 --- a/test/simple_select.test.js +++ b/test/simple_select.test.js @@ -342,6 +342,32 @@ test('simple_select', async (t) => { cleanUp(); }); + await t.test('simple_select - tap dragging fires an update event', async () => { + const point = getGeoJSON('point'); + const pointId = Draw.add(point)[0]; + const translatePosition = (point, d) => [point[0] + d, point[1] + d]; + + const startPosition = point.geometry.coordinates; + const endPosition = translatePosition(startPosition, 25); + + Draw.changeMode('simple_select', { + featureIds: [pointId] + }); + + await afterNextRender(); + map.fire.resetHistory(); + map.fire('touchstart', makeTouchEvent(...startPosition)); + map.fire('touchmove', makeTouchEvent(...translatePosition(startPosition, 15))); + map.fire('touchmove', makeTouchEvent(...endPosition)); + map.fire('touchend', makeTouchEvent(...endPosition)); + + const movedPoint = Draw.get(pointId); + const args = getFireArgs().filter(arg => arg[0] === 'draw.update'); + assert.equal(args.length, 1, 'draw.update called once'); + assert.equal(movedPoint.geometry.coordinates[0], endPosition[0], 'point lng moved to touchend location'); + assert.equal(movedPoint.geometry.coordinates[1], endPosition[1], 'point lat moved to touchend location'); + }); + await t.test('simple_select - click on a deselected feature with shift down while having another feature selected', async () => { const pointId = Draw.add(getGeoJSON('point'))[0]; const id = Draw.add(getGeoJSON('polygon'))[0];