Skip to content

Commit

Permalink
add failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
lavrton committed May 15, 2024
1 parent 88861b3 commit fdd0e64
Showing 1 changed file with 55 additions and 4 deletions.
59 changes: 55 additions & 4 deletions test/unit/DragAndDropEvents-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import {
simulateMouseDown,
simulateMouseMove,
simulateMouseUp,
simulatePointerDown,
simulatePointerMove,
simulatePointerUp,
} from './test-utils';

describe('DragAndDropEvents', function () {
Expand Down Expand Up @@ -219,10 +222,6 @@ describe('DragAndDropEvents', function () {
clicked = true;
});

circle.on('dblclick', function () {
//console.log('dblclick');
});

simulateMouseDown(stage, {
x: 40,
y: 40,
Expand All @@ -245,6 +244,58 @@ describe('DragAndDropEvents', function () {
}, 20);
});

// TODO: how to solve it?
// hint: every shape has pointerId that indicates which pointer is dragging it
// but "pointer" event and mouse event has different pointerId
// so we need to find a way to match them
// should we save several pointers per shape?
// doesn't sound good
// switch to pointer only event handling?
it.skip('click should not occur after drag and drop', function (done) {
var stage = addStage();
var layer = new Konva.Layer();

var circle = new Konva.Circle({
x: 40,
y: 40,
radius: 20,
strokeWidth: 4,
fill: 'green',
stroke: 'black',
draggable: true,
});

layer.add(circle);
stage.add(layer);

var clicked = false;

stage.on('pointerclick', function () {
clicked = true;
});

simulatePointerDown(stage, {
x: 40,
y: 40,
});

setTimeout(function () {
simulatePointerMove(stage, {
x: 100,
y: 100,
});

simulatePointerUp(stage, {
x: 100,
y: 100,
});

assert(!clicked, 'click event should not have been fired');

done();
}, 20);
});

// ======================================================
it('drag and drop distance', function (done) {
var stage = addStage();
Expand Down

0 comments on commit fdd0e64

Please sign in to comment.