-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added test cases for circular progressbar
- Loading branch information
1 parent
c230cbd
commit ab2b762
Showing
2 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/components/CircularProgressBar/__test__/CircularProgressBar.spec.tsx
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,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'); | ||
} | ||
|
||
}); | ||
}); |
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