This commit is contained in:
Daniel Karadachki 2019-03-27 17:03:06 +02:00
Родитель 71f38aea14
Коммит c90e2a337d
2 изменённых файлов: 29 добавлений и 1 удалений

Просмотреть файл

@ -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));
}