Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hooks #290

Merged
merged 5 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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