forked from deriv-com/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCircularProgressBar.spec.tsx
34 lines (30 loc) · 1.26 KB
/
CircularProgressBar.spec.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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');
}
});
});