test: pointercancel
This commit is contained in:
Родитель
71f38aea14
Коммит
c90e2a337d
|
@ -1,5 +1,5 @@
|
|||
import Draggable from '../src/main';
|
||||
import { pointerdown, pointermove, pointerup } from './pointer-util';
|
||||
import { pointerdown, pointermove, pointerup, pointercancel } from './pointer-util';
|
||||
import { aMouseEvent } from './util';
|
||||
|
||||
describe('Draggable with Pointer events', () => {
|
||||
|
@ -148,6 +148,30 @@ describe('Draggable with Pointer events', () => {
|
|||
expect(handler).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("does not triggers release on pointerup if not primary", () => {
|
||||
pointerdown(el, 100, 200);
|
||||
pointermove(el, 101, 201);
|
||||
pointerup(el, 101, 201, false);
|
||||
|
||||
expect(handler).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("triggers release on pointercancel", () => {
|
||||
pointerdown(el, 100, 200);
|
||||
pointercancel(el, 101, 201);
|
||||
pointercancel(el, 101, 201);
|
||||
|
||||
expect(handler).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("does not triggers release on pointercancel if not primary", () => {
|
||||
pointerdown(el, 100, 200);
|
||||
pointermove(el, 101, 201);
|
||||
pointercancel(el, 101, 201, false);
|
||||
|
||||
expect(handler).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("does not trigger release if the element was not pressed", () => {
|
||||
pointerup(el, 100, 200);
|
||||
expect(handler).not.toHaveBeenCalled();
|
||||
|
|
|
@ -23,3 +23,7 @@ export function pointerup(element, x, y, primary, button) {
|
|||
element.dispatchEvent(pointerEvent("pointerup", x, y, primary));
|
||||
}
|
||||
|
||||
export function pointercancel(element, x, y, primary) {
|
||||
element.dispatchEvent(pointerEvent("pointercancel", x, y, primary));
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче