From 07b58e928e1a2e1f3db565a7db0e8ca03564a0cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 16 Jun 2015 18:38:57 +0200 Subject: [PATCH] Implement unit test for shape.toPath().toShape() Currently failing for rect. --- test/tests/Shape.js | 55 +++++++++++++++++++++++++++++++++++++++++++++ test/tests/load.js | 2 ++ 2 files changed, 57 insertions(+) create mode 100644 test/tests/Shape.js diff --git a/test/tests/Shape.js b/test/tests/Shape.js new file mode 100644 index 00000000..d246874d --- /dev/null +++ b/test/tests/Shape.js @@ -0,0 +1,55 @@ +/* + * Paper.js - The Swiss Army Knife of Vector Graphics Scripting. + * http://paperjs.org/ + * + * Copyright (c) 2011 - 2014, Juerg Lehni & Jonathan Puckey + * http://scratchdisk.com/ & http://jonathanpuckey.com/ + * + * Distributed under the MIT license. See LICENSE file for details. + * + * All rights reserved. + */ + +module('Shape'); + +test('shape.toPath().toShape()', function() { + var shapes = { + circle: new Shape.Circle({ + center: [100, 100], + radius: 50, + fillColor: 'red' + }), + + ellipse: new Shape.Ellipse({ + center: [100, 200], + radius: [50, 25], + fillColor: 'blue', + strokeColor: 'black', + strokeWidth: 4, + rotation: 20 + }), + + rect: new Shape.Rectangle({ + center: [100, 300], + size: [100, 50], + fillColor: 'green', + strokeColor: 'black', + strokeWidth: 4, + rotation: -20 + }), + + roundRect: new Shape.Rectangle({ + center: [100, 400], + size: [50, 100], + radius: [15, 20], + fillColor: 'orange', + strokeColor: 'black', + strokeWidth: 4, + rotation: 20 + }) + }; + + Base.each(shapes, function(shape, name) { + equals(shape, shape.toPath().toShape(), name + '.toPath().toShape()'); + }); +}); diff --git a/test/tests/load.js b/test/tests/load.js index 33b03e93..acc8fdc7 100644 --- a/test/tests/load.js +++ b/test/tests/load.js @@ -40,6 +40,8 @@ /*#*/ include('Path_Intersections.js'); /*#*/ include('Path_Boolean.js'); +/*#*/ include('Shape.js'); + /*#*/ include('Curve.js'); /*#*/ include('CurveLocation.js');