#291 added unit test for creating a blob via json who has the tension defined before the points array

This commit is contained in:
Eric Rowell 2013-07-24 21:57:45 -07:00
parent e65b975a6a
commit 7a1b854a12
2 changed files with 53 additions and 10 deletions

View File

@ -27,7 +27,7 @@ Test.Modules.BLOB = {
fill: '#aaf',
tension: 0.8
});
var blob2 = new Kinetic.Blob({
points: [{
x: 73,
@ -48,7 +48,7 @@ Test.Modules.BLOB = {
x: 100,
y: 50
});
layer.add(blob1);
layer.add(blob2);
@ -56,11 +56,54 @@ Test.Modules.BLOB = {
test(blob1.getTension() === 0.8, 'blob1 tension should be 0.8');
test(blob2.getTension() === 1.2, 'blob2 tension should be 1.2');
test(blob1.getClassName() === 'Blob', 'getClassName should be Blob');
//console.log(blob1.getPoints())
},
'add blob and define tension first': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 200
});
var layer = new Kinetic.Layer();
/*
var blob = new Kinetic.Blob({
tension: 0.8,
points: [{
x: 73,
y: 140
}, {
x: 340,
y: 23
}, {
x: 500,
y: 109
}, {
x: 300,
y: 170
}],
stroke: 'blue',
strokeWidth: 10,
draggable: true,
fill: '#aaf'
});
*/
var json = '{"attrs":{"tension":0.8,"points":[{"x":73,"y":140},{"x":340,"y":23},{"x":500,"y":109},{"x":300,"y":170}],"stroke":"blue","strokeWidth":10,"draggable":true,"fill":"#aaf"},"className":"Blob"}';
var blob = Kinetic.Node.create(json);
layer.add(blob);
stage.add(layer);
//console.log(blob.toJSON());
test(stage.get('Blob')[0].getPoints().length === 4, 'created blob should have 4 points');
}
};

View File

@ -28,7 +28,7 @@ Test.Modules.SPLINE = {
draggable: true,
tension: 1
});
var line2 = new Kinetic.Spline({
points: [{
x: 73,
@ -47,7 +47,7 @@ Test.Modules.SPLINE = {
draggable: true,
tension: 1
});
var line3 = new Kinetic.Spline({
points: [{
x: 73,
@ -68,7 +68,7 @@ Test.Modules.SPLINE = {
layer.add(line2);
layer.add(line3);
stage.add(layer);
test(line1.getClassName() === 'Spline', 'getClassName should be Spline');
@ -102,7 +102,7 @@ Test.Modules.SPLINE = {
draggable: true,
tension: 1
});
layer.add(spline);
stage.add(layer);
@ -123,7 +123,7 @@ Test.Modules.SPLINE = {
test(spline.allPoints.length === 3, 'spline all points should have 3 points');
layer.draw();
},
'add point to spline points': function(containerId) {
@ -155,7 +155,7 @@ Test.Modules.SPLINE = {
draggable: true,
tension: 1
});
layer.add(spline);
stage.add(layer);