From 354b65b62392b45531161157a4e1ffa09d39ce04 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sun, 18 Feb 2018 15:58:23 -0500 Subject: [PATCH] Adding tests for cubicCurveTo --- src/components/SVG/path.js | 6 ++++-- src/components/SVG/path.test.js | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/components/SVG/path.js b/src/components/SVG/path.js index b39621b..68592fa 100644 --- a/src/components/SVG/path.js +++ b/src/components/SVG/path.js @@ -76,8 +76,10 @@ class Path { this.pathParts.push(`${command}${cx1},${cy1} ${cx2},${cy2} ${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 3cfd2a1..f41d89c 100644 --- a/src/components/SVG/path.test.js +++ b/src/components/SVG/path.test.js @@ -20,6 +20,11 @@ describe('Path', () => { [ 'lineTo', { x: 5, relative: true }, 'h5' ], [ 'lineTo', { y: 1, relative: true }, 'v1' ], [ 'lineTo', { relative: true }, '' ], + // cubicCurveTo + [ 'cubicCurveTo', { cx1: 5, cy1: 6, cx2: 10, cy2: 11, x: 15, y: 16 }, 'C5,6 10,11 15,16' ], + [ 'cubicCurveTo', { cx2: 10, cy2: 11, x: 15, y: 16 }, 'S10,11 15,16' ], + [ 'cubicCurveTo', { cx1: 5, cy1: 6, cx2: 10, cy2: 11, x: 15, y: 16, relative: true }, 'c5,6 10,11 15,16' ], + [ 'cubicCurveTo', { cx2: 10, cy2: 11, x: 15, y: 16, relative: true }, 's10,11 15,16' ] ].forEach(([ cmd, args, str ], i) => ( test(`case #${ i }`, () => { const path = new Path();