Skip to content

Commit

Permalink
feat: added test cases for circular progressbar
Browse files Browse the repository at this point in the history
  • Loading branch information
yaswanth-deriv committed Mar 26, 2024
1 parent c230cbd commit ab2b762
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import { CircularProgressBar } from '..';

describe('CircularProgressBar Component', () => {
it('renders correctly with default props', () => {
const { container } = render(<CircularProgressBar variant="clockwise" />);
expect(container.querySelector('.deriv-circular-progress__bar')).toBeInTheDocument();
});

it('renders children correctly', () => {
const { getByText } = render(
<CircularProgressBar variant="clockwise">
<div className="circular-progress-content">Child content</div>
</CircularProgressBar>
);
expect(getByText('Child content')).toBeInTheDocument();
});

it('handles selection correctly for selectable variant', () => {
const onSelectMock = jest.fn();
const { container } = render(
<CircularProgressBar variant="selectable" onSelect={onSelectMock} />
);
const progressBar = container.querySelector('.deriv-circular-progress__bar');
if (progressBar) {
fireEvent.click(progressBar);
expect(onSelectMock).toHaveBeenCalled();
} else {
fail('Progress bar not found');
}

});
});
2 changes: 1 addition & 1 deletion src/components/CircularProgressBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "./CircularProgressBar.scss"

type TVariant = "clockwise" | "static" | "selectable"
type TCircularProgressProps = {
children: ReactNode;
children?: ReactNode;
className?: string;
danger_limit?: number;
is_clockwise?: boolean;
Expand Down

0 comments on commit ab2b762

Please sign in to comment.