more warnings and methods

This commit is contained in:
Anton Lavrenov
2019-02-13 23:41:32 -05:00
parent 99e66c380f
commit dcff79eb63
10 changed files with 122 additions and 47 deletions

View File

@@ -3804,4 +3804,30 @@ suite('Node', function() {
assert.equal(callCount, 1);
Konva.Util.warn = oldWarn;
});
test('show warning for unexpected zIndexes', function() {
var stage = addStage();
var layer = new Konva.Layer();
stage.add(layer);
var shape = new Konva.Circle({
radius: 50,
fill: 'red'
});
layer.add(shape);
var callCount = 0;
var oldWarn = Konva.Util.warn;
Konva.Util.warn = function() {
callCount += 1;
};
shape.zIndex(-1);
shape.zIndex(0);
shape.zIndex(10);
assert.equal(callCount, 2);
Konva.Util.warn = oldWarn;
});
});

View File

@@ -988,7 +988,6 @@ suite('Shape', function() {
y: 120
});
//TODO: can't get this to pass
assert.equal(
click,
true,
@@ -1774,4 +1773,37 @@ suite('Shape', function() {
layer.draw();
});
test('try to add destroyed shape', function() {
var stage = addStage();
var layer = new Konva.Layer();
stage.add(layer);
var star = new Konva.Star({
x: 200,
y: 100,
numPoints: 5,
innerRadius: 40,
outerRadius: 70,
stroke: 'blue',
strokeWidth: 5,
draggable: true
});
star.destroy();
var callCount = 0;
var oldWarn = Konva.Util.warn;
Konva.Util.warn = function() {
callCount += 1;
};
layer.add(star);
layer.draw();
assert.equal(callCount, 1);
Konva.Util.warn = oldWarn;
});
});