test(slider): centralize jsdom pointer shims and add vertical drag test
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user