Skip to content

Commit

Permalink
Merge ee1478e into 101a312
Browse files Browse the repository at this point in the history
  • Loading branch information
toomuchdesign committed Feb 22, 2019
2 parents 101a312 + ee1478e commit 285fe29
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.4.1

- Fix chart to render `data.title` value as `<title>` inside `<path>` element

# 3.4.0

- Support `injectSvg` function property to inject any element into rendered `<svg>` element
Expand Down
1 change: 1 addition & 0 deletions src/ReactMinimalPieChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const makeSegments = (data, props, hide) => {
radius={props.radius}
lineWidth={(props.radius / 100) * props.lineWidth}
reveal={reveal}
title={dataEntry.title}
style={style}
stroke={dataEntry.color}
strokeLinecap={props.rounded ? 'round' : undefined}
Expand Down
14 changes: 13 additions & 1 deletion src/__tests__/ReactMinimalPieChart.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow, mount } from 'enzyme';

import PieChart from '../../src/index';

Expand Down Expand Up @@ -237,6 +237,18 @@ describe('ReactMinimalPieChart component', () => {
});
});

describe('"data.title"', () => {
it('Should render a <Title> element in its Path', () => {
const wrapper = mount(
<PieChart data={[{ title: 'title-value', value: 10, color: 'blue' }]} />
);

const title = wrapper.find('title');
expect(title.length).toEqual(1);
expect(title.text()).toEqual('title-value');
});
});

describe('"injectSvg"', () => {
it('Should inject anything into rendered <svg>', () => {
const wrapper = shallow(
Expand Down
15 changes: 0 additions & 15 deletions src/__tests__/ReactMinimalPieChartPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,4 @@ describe('ReactMinimalPieChartPath component', () => {
const strokeDasharray = wrapper.prop('strokeDasharray');
expect(strokeDashoffset).toEqual(strokeDasharray + strokeDasharray / 4);
});

it('Should render a <Title> element when "title" prop provided', () => {
const wrapper = shallow(
<PieChartPath
cx={100}
cy={100}
title="title-value"
/>
);

const title = wrapper.find('title');

expect(title.length).toEqual(1);
expect(title.text()).toEqual('title-value');
});
});

0 comments on commit 285fe29

Please sign in to comment.