From ef33cdab0416f98e01252ff4421881eeddff348f Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sun, 18 Feb 2018 16:03:46 -0500 Subject: [PATCH] Adding tests for Path#arcTo --- src/components/SVG/path.js | 8 +++++--- src/components/SVG/path.test.js | 5 ++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/SVG/path.js b/src/components/SVG/path.js index 178e46e..cb010a8 100644 --- a/src/components/SVG/path.js +++ b/src/components/SVG/path.js @@ -106,10 +106,12 @@ class Path { relative = relative === undefined ? this.relative : relative; const command = relative ? 'a' : 'A'; - this.pathParts.push(`${command}${rx},${ry} ${rotation} ${arc} ${sweep},${x},${y}`); + this.pathParts.push(`${command}${rx},${ry} ${rotation} ${arc} ${sweep} ${x},${y}`); - this.currentPosition.x = relative ? this.currentPosition.x + x : x; - this.currentPosition.y = relative ? this.currentPosition.y + y : y; + this.currentPosition = { + x: relative ? this.currentPosition.x + x : x, + y: relative ? this.currentPosition.y + y : y + }; return this; } diff --git a/src/components/SVG/path.test.js b/src/components/SVG/path.test.js index 2374a39..bcf62f8 100644 --- a/src/components/SVG/path.test.js +++ b/src/components/SVG/path.test.js @@ -29,7 +29,10 @@ describe('Path', () => { [ 'quadraticCurveTo', { cx: 5, cy: 6, x: 10, y: 11 }, 'Q5,6 10,11' ], [ 'quadraticCurveTo', { x: 10, y: 11 }, 'T10,11' ], [ 'quadraticCurveTo', { cx: 5, cy: 6, x: 10, y: 11, relative: true }, 'q5,6 10,11' ], - [ 'quadraticCurveTo', { x: 10, y: 11, relative: true }, 't10,11' ] + [ 'quadraticCurveTo', { x: 10, y: 11, relative: true }, 't10,11' ], + // arcTo + [ 'arcTo', { rx: 5, ry: 6, rotation: 1, arc: 0, sweep: 0, x: 10, y: 11 }, 'A5,6 1 0 0 10,11' ], + [ 'arcTo', { rx: 5, ry: 6, rotation: 1, arc: 0, sweep: 0, x: 10, y: 11, relative: true }, 'a5,6 1 0 0 10,11' ] ].forEach(([ cmd, args, str ], i) => ( test(`case #${ i }`, () => { const path = new Path();