Skip to content

Commit 34ea7a5

Browse files
authored
YH-873: added tests for Skeleton (#949)
1 parent e186564 commit 34ea7a5

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { screen } from '@testing-library/react';
2+
3+
import { renderComponent } from '@/shared/libs/jest/renderComponent/renderComponent';
4+
5+
import { Skeleton } from './Skeleton';
6+
7+
describe('Skeleton', () => {
8+
const testProps = {
9+
dataTestId: 'data-test-id',
10+
width: 50,
11+
height: '50%',
12+
borderRadius: '8px',
13+
style: { marginBottom: '20px' },
14+
className: 'wrapper-skeleton',
15+
};
16+
17+
beforeEach(() => {
18+
renderComponent(<Skeleton {...testProps} />);
19+
});
20+
21+
test('should render with correct props', () => {
22+
const skeletonElement = screen.getByTestId(testProps.dataTestId);
23+
expect(skeletonElement).toBeInTheDocument();
24+
});
25+
test('applies custom width, height and and borderRadius via styles', () => {
26+
const skeletonElement = screen.getByTestId(testProps.dataTestId);
27+
expect(skeletonElement).toHaveStyle({ width: '50px', height: '50%', borderRadius: '8px' });
28+
});
29+
test('applies custom style', () => {
30+
const skeletonElement = screen.getByTestId(testProps.dataTestId);
31+
expect(skeletonElement).toHaveStyle({ marginBottom: '20px' });
32+
});
33+
test('applies custom className', () => {
34+
const skeletonElement = screen.getByTestId(testProps.dataTestId);
35+
expect(skeletonElement).toHaveClass('wrapper-skeleton');
36+
});
37+
test('has base skeleton class', () => {
38+
const skeletonElement = screen.getByTestId(testProps.dataTestId);
39+
expect(skeletonElement).toHaveClass('skeleton');
40+
});
41+
});

0 commit comments

Comments
 (0)