Skip to content

Commit

Permalink
Ensure tap-dragging fires an update event (#881)
Browse files Browse the repository at this point in the history
* Ensure tap-dragging fires an update event

---------

Co-authored-by: Stepan Kuzmin <[email protected]>
  • Loading branch information
Zirak and stepankuzmin authored Jun 28, 2024
1 parent 5d9a7b8 commit abbb41a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/simple_select.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit abbb41a

Please sign in to comment.