2014-05-20 17:52:22 +08:00
|
|
|
suite('BaseLayer', function() {
|
2017-02-24 22:15:33 +08:00
|
|
|
// ======================================================
|
|
|
|
test('width and height', function() {
|
2018-08-01 10:26:13 +08:00
|
|
|
Konva.showWarnings = false;
|
2017-02-24 22:15:33 +08:00
|
|
|
var stage = addStage();
|
2014-05-20 17:52:22 +08:00
|
|
|
|
2017-02-24 22:15:33 +08:00
|
|
|
var layer = new Konva.FastLayer();
|
|
|
|
assert.equal(
|
|
|
|
layer.width(),
|
|
|
|
undefined,
|
|
|
|
'while layer is not on stage width is undefined'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
layer.height(),
|
|
|
|
undefined,
|
|
|
|
'while layer is not on stage height is undefined'
|
|
|
|
);
|
2014-05-20 17:52:22 +08:00
|
|
|
|
2017-02-24 22:15:33 +08:00
|
|
|
layer.width(10);
|
|
|
|
assert.equal(
|
|
|
|
layer.width(),
|
|
|
|
undefined,
|
|
|
|
'while layer is not on stage changing width doing nothing'
|
|
|
|
);
|
|
|
|
layer.height(10);
|
|
|
|
assert.equal(
|
|
|
|
layer.height(),
|
|
|
|
undefined,
|
|
|
|
'while layer is not on stage changing height doing nothing'
|
|
|
|
);
|
|
|
|
stage.add(layer);
|
2014-05-20 17:52:22 +08:00
|
|
|
|
2017-02-24 22:15:33 +08:00
|
|
|
assert.equal(
|
|
|
|
layer.width(),
|
|
|
|
stage.width(),
|
|
|
|
'while layer is on stage width is stage`s width'
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
layer.height(),
|
|
|
|
stage.height(),
|
|
|
|
'while layer is on stage height is stage`s height'
|
|
|
|
);
|
2014-05-20 17:52:22 +08:00
|
|
|
|
2017-02-24 22:15:33 +08:00
|
|
|
layer.width(10);
|
|
|
|
assert.equal(
|
|
|
|
layer.width(),
|
|
|
|
stage.width(),
|
|
|
|
'while layer is on stage changing width doing nothing'
|
|
|
|
);
|
|
|
|
layer.height(10);
|
|
|
|
assert.equal(
|
|
|
|
layer.height(),
|
|
|
|
stage.height(),
|
|
|
|
'while layer is on stage changing height doing nothing'
|
|
|
|
);
|
2018-08-01 10:26:13 +08:00
|
|
|
Konva.showWarnings = true;
|
2017-02-24 22:15:33 +08:00
|
|
|
});
|
|
|
|
});
|