From c9fe948b903fb3e74ef31ff115bb28c73bc311e7 Mon Sep 17 00:00:00 2001 From: Brian Mearns Date: Sat, 5 Oct 2019 13:48:20 -0400 Subject: [PATCH] #530 Finished basic unit tests for flow shapes --- src/diagrams/flowchart/flowChartShapes.js | 2 +- .../flowchart/flowChartShapes.spec.js | 28 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/diagrams/flowchart/flowChartShapes.js b/src/diagrams/flowchart/flowChartShapes.js index 4ceecbf29..e9b17ae89 100644 --- a/src/diagrams/flowchart/flowChartShapes.js +++ b/src/diagrams/flowchart/flowChartShapes.js @@ -54,7 +54,7 @@ function rect_left_inv_arrow(parent, bbox, node) { return shapeSvg; } -function lean_right (parent, bbox, node) { +function lean_right(parent, bbox, node) { const w = bbox.width; const h = bbox.height; const points = [ diff --git a/src/diagrams/flowchart/flowChartShapes.spec.js b/src/diagrams/flowchart/flowChartShapes.spec.js index 4d63314ae..de3f05a1d 100644 --- a/src/diagrams/flowchart/flowChartShapes.spec.js +++ b/src/diagrams/flowchart/flowChartShapes.spec.js @@ -18,20 +18,14 @@ describe('flowchart shapes', function() { function(w, h) { return w + h / 2; }, - function(w, h) { - return h; - } + useHeight ], - [ - 'rect_left_inv_arrow', - 5, - function(w) { - return w; - }, - function(w, h) { - return h; - } - ] + ['rect_left_inv_arrow', 5, useWidth, useHeight], + ['rect_right_inv_arrow', 5, useWidth, useHeight], + ['lean_right', 4, useWidth, useHeight], + ['lean_left', 4, useWidth, useHeight], + ['trapezoid', 4, useWidth, useHeight], + ['inv_trapezoid', 4, useWidth, useHeight] ].forEach(function([shapeType, expectedPointCount, getW, getH]) { it(`should add a ${shapeType} shape that renders a properly translated polygon element`, function() { const mockRender = MockRender(); @@ -87,3 +81,11 @@ function MockSvg(tag, ...args) { } }; } + +function useWidth(w, h) { + return w; +} + +function useHeight(w, h) { + return h; +}