Mock PointerEvent in tests to include target

The `target` Event property is readonly as it is set internally when an
event is dispatched. This change uses a plain object with the essential
properties that a PointerEvent has which is sufficent for map event handling
This commit is contained in:
Matt Walker
2020-01-13 10:46:40 +00:00
parent f3d94b3132
commit 5ce532e3e4
5 changed files with 18 additions and 11 deletions
+9 -7
View File
@@ -65,13 +65,15 @@ describe('ol.interaction.Translate', function() {
// calculated in case body has top < 0 (test runner with small window)
const position = viewport.getBoundingClientRect();
const shiftKey = opt_shiftKey !== undefined ? opt_shiftKey : false;
const event = new MapBrowserPointerEvent(type, map,
new PointerEvent(type, {
clientX: position.left + x + width / 2,
clientY: position.top + y + height / 2,
shiftKey: shiftKey,
preventDefault: function() {}
}));
const event = new MapBrowserPointerEvent(type, map, {
type: type,
target: viewport.firstChild,
pointerId: 0,
clientX: position.left + x + width / 2,
clientY: position.top + y + height / 2,
shiftKey: shiftKey,
preventDefault: function() {}
});
map.handleMapBrowserEvent(event);
}