summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Demaine <edemaine@mit.edu>2018-12-14 09:13:03 -0500
committerErik Demaine <edemaine@mit.edu>2018-12-14 09:13:03 -0500
commit968b3f7e30f4c536727d7536f0b042c71682265a (patch)
tree290f47fdbd18bdafa4be0fce7f2fc2f12a8349ea
parent7a67de3aa992e8cf9b9110832f6ec2a55b378df7 (diff)
downloadsvg.js-968b3f7e30f4c536727d7536f0b042c71682265a.tar.gz
svg.js-968b3f7e30f4c536727d7536f0b042c71682265a.zip
Add tests
-rw-r--r--spec/spec/pointarray.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/spec/pointarray.js b/spec/spec/pointarray.js
new file mode 100644
index 0000000..f50f981
--- /dev/null
+++ b/spec/spec/pointarray.js
@@ -0,0 +1,28 @@
+describe('PointArray', function() {
+ const squareString = '0,0 1,0 1,1 0,1';
+ const square = new SVG.PointArray(squareString)
+
+ describe('toString()', function() {
+ it('round trips with string', () => {
+ expect(square.toString()).toEqual(squareString)
+ })
+ })
+
+ describe('transform()', function() {
+ it('translates correctly', () => {
+ const translation = new SVG.Matrix().translate(2,1)
+ const newSquare = square.transform(translation)
+ expect(newSquare.toString()).toEqual('2,1 3,1 3,2 2,2')
+ })
+
+ it('transforms like Point', () => {
+ const matrix = new SVG.Matrix(1, 2, 3, 4, 5, 6)
+ const newSquare = square.transform(matrix)
+ for (let i = 0; i < square.length; i++) {
+ const squarePoint = new SVG.Point(square[i])
+ const newSquarePoint = new SVG.Point(newSquare[i])
+ expect(squarePoint.transform(matrix)).toEqual(newSquarePoint)
+ }
+ })
+ })
+})