warning on dublicate ids

This commit is contained in:
Anton Lavrenov
2019-01-24 22:52:16 -05:00
parent 645c344d32
commit 11d805795a
8 changed files with 67 additions and 78 deletions

View File

@@ -118,20 +118,23 @@ suite('Node', function() {
assert.equal(layer.getAbsoluteOpacity(), 0.5);
});
test.skip('warn on duplicate id', function() {
test.only('warn on duplicate id', function() {
var oldWarn = Konva.Util.warn;
var called = false;
Konva.Util.warn = function() {
called = true;
};
var circle = new Konva.Circle({
var circle1 = new Konva.Circle({
id: 'circle'
});
var circle = new Konva.Circle({
var circle2 = new Konva.Circle({
id: 'circle'
});
assert.equal(called, true);
Konva.Util.warn = oldWarn;
circle1.destroy();
circle2.destroy();
});
// ======================================================
@@ -1153,8 +1156,6 @@ suite('Node', function() {
layer.add(circle);
stage.add(layer);
/*
* add custom attr that points to self. The setAttrs method should
* not inifinitely recurse causing a stack overflow
@@ -3085,7 +3086,7 @@ suite('Node', function() {
// last shape is registered
assert.equal(Konva.ids.shape, rect);
// destroying circle should not remove rect from regiter
circle.destroy();

View File

@@ -1231,12 +1231,11 @@ suite('Stage', function() {
image.src = url;
});
test.only('show a warning if the stage has too many layers', function() {
test('show a warning if the stage has too many layers', function() {
var stage = addStage();
var oldWarn = Konva.Util.warn;
var called = false;
Konva.Util.warn = function() {
oldWarn.apply(null, arguments);
called = true;
};