Skip to content

Commit

Permalink
Merge pull request #290 from scriptex/feature/hooks
Browse files Browse the repository at this point in the history
Use hooks
  • Loading branch information
scriptex authored Sep 10, 2020
2 parents 5ea478f + 9b73063 commit cc03c13
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 332 deletions.
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ yarn.lock

# Config files
.babelrc
.github
.whitesource
renovate.json
webpack.config.js
_config.yml
_.config.yml
__test__
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

# React SVG Donuts

A ReactJS component for simple (and complex) SVG donuts.
> A ReactJS component for simple (and complex) SVG donuts.
**The current version depends on the Hooks API introduced with React 16. If you need legacy React support, please use a 1.x.x version.**

## Demo

Expand Down
2 changes: 2 additions & 0 deletions __test__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ exports[`Donuts should render a complex donut 1`] = `
</div>
`;

exports[`Donuts should render a complex donut 2`] = `null`;

exports[`Donuts should render a simple donut with custom props 1`] = `
<div
className="donut"
Expand Down
75 changes: 42 additions & 33 deletions __test__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import renderer from 'react-test-renderer';
import renderer, { act } from 'react-test-renderer';

import Donut from '../src';
import ComplexDonut from '../src/complex';

Expand All @@ -17,38 +18,46 @@ describe('Donuts', () => {
});

it('should render a complex donut', () => {
const tree = renderer.create(
<ComplexDonut
size={200}
radius={80}
segments={[
{
color: '#FF8A80',
value: 230
},
{
color: '#FF80AB',
value: 308
},
{
color: '#B9F6CA',
value: 520
},
{
color: '#B388FF',
value: 130
},
{
color: '#8C9EFF',
value: 200
}
]}
thickness={40}
startAngle={-90}
textProps={{}}
circleProps={{}}
/>
);
let tree;

act(() => {
tree = renderer.create(
<ComplexDonut
size={200}
radius={80}
segments={[
{
color: '#FF8A80',
value: 230
},
{
color: '#FF80AB',
value: 308
},
{
color: '#B9F6CA',
value: 520
},
{
color: '#B388FF',
value: 130
},
{
color: '#8C9EFF',
value: 200
}
]}
thickness={40}
startAngle={-90}
textProps={{}}
circleProps={{}}
/>
);
});

expect(tree).toMatchSnapshot();

tree.unmount();

expect(tree).toMatchSnapshot();
});
Expand Down
Loading

0 comments on commit cc03c13

Please sign in to comment.