create test

This commit is contained in:
Anton Lavrenov 2015-05-06 07:08:31 +07:00
parent ef1f838496
commit 1c7c202b68
2 changed files with 34 additions and 3 deletions

View File

@ -60,7 +60,7 @@ suite('Stage', function() {
test('stage instantiation should clear container', function() {
var container = Konva.document.createElement('div');
var dummy = Konva.document.createElement('p');
container.appendChild(dummy);
konvaContainer.appendChild(container);
@ -560,4 +560,36 @@ suite('Stage', function() {
};
image.src = 'assets/lion.png';
});
});
test('check hit graph with stage listeting property', function() {
var stage = addStage();
var layer = new Konva.Layer();
stage.add(layer);
showHit(layer);
var circle = new Konva.Circle({
fill : 'green',
radius: 50
});
layer.add(circle);
var pos = {
x: stage.width() / 2,
y: stage.height() /2
};
circle.position(pos);
stage.draw();
// try to detect circle via hit graph
assert.equal(stage.getIntersection(pos), circle, 'has circle');
// disable hit graph
stage.listening(false);
stage.draw();
assert.equal(!!stage.getIntersection(pos), false, 'no circle');
// enable it again
stage.listening(true);
stage.draw();
assert.equal(stage.getIntersection(pos), circle, 'circle again');
});
});

View File

@ -217,5 +217,4 @@ suite('Tween', function() {
}, 50);
});
});