test(slider): centralize jsdom pointer shims and add vertical drag test

This commit is contained in:
Ilia Mashkov
2026-06-02 11:08:07 +03:00
parent 1209358d40
commit 19d9b07c55
2 changed files with 26 additions and 21 deletions
+17
View File
@@ -44,3 +44,20 @@ Object.defineProperty(window, 'localStorage', {
value: localStorageMock,
writable: true,
});
// jsdom lacks PointerEvent; back it with MouseEvent so clientX/clientY survive.
if (typeof PointerEvent === 'undefined') {
class PointerEventPolyfill extends MouseEvent {
pointerId: number;
constructor(type: string, params: PointerEventInit = {}) {
super(type, params);
this.pointerId = params.pointerId ?? 1;
}
}
// @ts-expect-error assigning polyfill to the global scope
global.PointerEvent = PointerEventPolyfill;
}
// jsdom lacks pointer capture
HTMLElement.prototype.setPointerCapture = vi.fn();
HTMLElement.prototype.releasePointerCapture = vi.fn();