Skip to content

Commit ef094f7

Browse files
committed
Add tests for Hairball component
1 parent 75ced84 commit ef094f7

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

test/experimantal/hairball.spec.tsx

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React from 'react';
2+
import { render, screen } from '@testing-library/react';
3+
import { Hairball, HairballPreset } from '../../src/beta'
4+
5+
describe('Hairball', () => {
6+
test('renders with default props', () => {
7+
render(<Hairball />);
8+
expect(screen.getByTestId('hairball')).toBeInTheDocument();
9+
});
10+
11+
test('renders with custom props', () => {
12+
render(
13+
<Hairball
14+
preset={HairballPreset.sunrise}
15+
backgroundColor="#000"
16+
speed={3}
17+
width={200}
18+
height={200}
19+
visible={true}
20+
ariaLabel="Custom Hairball loading"
21+
wrapperClass="custom-class"
22+
/>
23+
);
24+
const hairball = screen.getByTestId('hairball');
25+
expect(hairball).toBeInTheDocument();
26+
expect(hairball).toHaveClass('custom-class');
27+
expect(hairball).toHaveStyle({
28+
backgroundColor: '#000',
29+
});
30+
expect(hairball).toHaveAttribute('aria-label', 'Custom Hairball loading');
31+
expect(hairball).toHaveAttribute('role', 'progressbar');
32+
expect(hairball).toHaveAttribute('width', '200');
33+
expect(hairball).toHaveAttribute('height', '200');
34+
});
35+
36+
test('renders with preset', () => {
37+
render(<Hairball preset="sunrise" />);
38+
const hairball = screen.getByTestId('hairball');
39+
expect(hairball).toBeInTheDocument();
40+
hairball.querySelectorAll('path').forEach((path) => {
41+
expect(path).toHaveAttribute('fill');
42+
});
43+
});
44+
45+
test('should not render when visible is false', () => {
46+
render(<Hairball visible={false} />);
47+
expect(screen.queryByTestId('hairball')).not.toBeInTheDocument();
48+
});
49+
});

0 commit comments

Comments
 (0)