From bb37848265f0cba474561e2235bfc1a10f1d4b8e Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sun, 18 Feb 2018 15:46:17 -0500 Subject: [PATCH] Adding specs and some refactoring for the Path#lineTo method --- .../__snapshots__/VerticalLayout.test.js.snap | 2 +- src/components/SVG/path.js | 29 ++++++++++++++----- src/components/SVG/path.test.js | 27 +++++++++++++++++ 3 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 src/components/SVG/path.test.js diff --git a/src/components/SVG/__snapshots__/VerticalLayout.test.js.snap b/src/components/SVG/__snapshots__/VerticalLayout.test.js.snap index b4efb8b..d24d22c 100644 --- a/src/components/SVG/__snapshots__/VerticalLayout.test.js.snap +++ b/src/components/SVG/__snapshots__/VerticalLayout.test.js.snap @@ -75,7 +75,7 @@ exports[`VerticalLayout rendering with connectors 1`] = ` withConnectors={true} > { + [ + // lineTo + [ 'lineTo', { x: 5, y: 1 }, 'L5,1' ], + [ 'lineTo', { x: 5, y: 0 }, 'H5' ], + [ 'lineTo', { x: 0, y: 1 }, 'V1' ], + [ 'lineTo', { x: 0, y: 0 }, '' ], + [ 'lineTo', { x: 5 }, 'H5' ], + [ 'lineTo', { y: 1 }, 'V1' ], + [ 'lineTo', {}, '' ], + [ 'lineTo', { x: 5, y: 1, relative: true }, 'l5,1' ], + [ 'lineTo', { x: 5, y: 0, relative: true }, 'h5' ], + [ 'lineTo', { x: 0, y: 1, relative: true }, 'v1' ], + [ 'lineTo', { x: 0, y: 0, relative: true }, '' ], + [ 'lineTo', { x: 5, relative: true }, 'h5' ], + [ 'lineTo', { y: 1, relative: true }, 'v1' ], + [ 'lineTo', { relative: true }, '' ], + ].forEach(([ cmd, args, str ], i) => ( + test(`case #${ i }`, () => { + const path = new Path(); + path[cmd](args); + expect(path.toString()).toEqual(str); + }) + )); +});