From af4775625e41a7c19c78a121fe238bc050ea3eb0 Mon Sep 17 00:00:00 2001 From: Kevin Qi Date: Sat, 11 May 2019 14:55:21 -0700 Subject: [PATCH] set value boundaries in CircularProgressbar, instead of in Path --- src/CircularProgressbar.tsx | 3 ++- src/Path.tsx | 5 +---- test/CircularProgressbar.test.tsx | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/CircularProgressbar.tsx b/src/CircularProgressbar.tsx index 73147cd..93fd46d 100644 --- a/src/CircularProgressbar.tsx +++ b/src/CircularProgressbar.tsx @@ -71,7 +71,8 @@ class CircularProgressbar extends React.Component { } = this.props; const pathRadius = this.getPathRadius(); - const pathRatio = value / (maxValue - minValue); + const boundedValue = Math.min(Math.max(value, minValue), maxValue); + const pathRatio = boundedValue / (maxValue - minValue); return ( ', () => { expect(wrapper.find('.CircularProgressbar-text').text()).toEqual('50%'); }); }); - describe('props.percentage', () => { + describe('props.value', () => { test('Renders correct path', () => { const percentage = 30; const wrapper = mount(