-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Primer avance pruebas * All piechart tests passed * Fixes and linting
- Loading branch information
Showing
10 changed files
with
167 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import { render, fireEvent } from '@testing-library/react'; | ||
import Pie from './index'; | ||
|
||
describe('Pie', () => { | ||
const mockData = [ | ||
{ name: 'Group A', value: 400 }, | ||
{ name: 'Group B', value: 300 }, | ||
{ name: 'Group C', value: 300 }, | ||
]; | ||
|
||
it('renders without crashing', () => { | ||
const { container } = render( | ||
<svg> | ||
<Pie data={mockData} dataKey="value" nameKey="name" cx="50%" cy="50%" outerRadius={80} fill="#8884d8" /> | ||
</svg> | ||
); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
|
||
it('displays the correct number of pie segments', () => { | ||
const { container } = render( | ||
<svg> | ||
<Pie data={mockData} dataKey="value" nameKey="name" cx="50%" cy="50%" outerRadius={80} fill="#8884d8" /> | ||
</svg> | ||
); | ||
const paths = container.querySelectorAll('path'); | ||
expect(paths.length).toBe(mockData.length); | ||
}); | ||
|
||
it('changes shape when activeShape is true', () => { | ||
const { container } = render( | ||
<Pie | ||
data={mockData} | ||
dataKey="value" | ||
nameKey="name" | ||
cx="50%" | ||
cy="50%" | ||
outerRadius={80} | ||
fill="#8884d8" | ||
activeShape={true} | ||
/> | ||
); | ||
|
||
const path = container.querySelector('path'); | ||
fireEvent.mouseEnter(path!); | ||
|
||
setTimeout(() => { | ||
expect(path).toHaveStyle('transform: scale(1.05)'); | ||
}, 200); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import PieChart from './index'; | ||
import Pie from '../Pie'; | ||
|
||
describe('PieChart', () => { | ||
const mockData = [ | ||
{ name: 'Group A', value: 400 }, | ||
{ name: 'Group B', value: 300 }, | ||
]; | ||
|
||
it('renders without crashing', () => { | ||
const { container } = render( | ||
<PieChart width={500} height={400}> | ||
<Pie data={mockData} dataKey="value" nameKey="name" cx="50%" cy="50%" outerRadius={80} fill="#8884d8" /> | ||
</PieChart> | ||
); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders with correct width and height', () => { | ||
const { container } = render( | ||
<PieChart width={500} height={400}> | ||
<Pie data={mockData} dataKey="value" nameKey="name" cx="50%" cy="50%" outerRadius={80} fill="#8884d8" /> | ||
</PieChart> | ||
); | ||
const svg = container.querySelector('svg'); | ||
expect(svg).toHaveAttribute('width', '500'); | ||
expect(svg).toHaveAttribute('height', '400'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import PolarGrid from './index'; | ||
|
||
describe('PolarGrid', () => { | ||
it('renders without crashing', () => { | ||
const { container } = render( | ||
<svg> | ||
<PolarGrid cx="50%" cy="50%" /> | ||
</svg> | ||
); | ||
expect(container).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders correct number of radial lines and concentric circles', () => { | ||
const { container } = render( | ||
<svg> | ||
<PolarGrid cx="50%" cy="50%" radialLines={8} concentricCircles={4} /> | ||
</svg> | ||
); | ||
const lines = container.querySelectorAll('line'); | ||
const circles = container.querySelectorAll('circle'); | ||
expect(lines.length).toBe(8); | ||
expect(circles.length).toBe(4); | ||
}); | ||
|
||
it('applies correct stroke color', () => { | ||
const { container } = render( | ||
<svg> | ||
<PolarGrid cx="50%" cy="50%" stroke="#123456" /> | ||
</svg> | ||
); | ||
const lines = container.querySelector('line'); | ||
const circles = container.querySelector('circle'); | ||
expect(lines).toHaveAttribute('stroke', '#123456'); | ||
expect(circles).toHaveAttribute('stroke', '#123456'); | ||
}); | ||
}); |