-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDualScrollSyncLabel.test.tsx
More file actions
54 lines (42 loc) · 1.5 KB
/
DualScrollSyncLabel.test.tsx
File metadata and controls
54 lines (42 loc) · 1.5 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { render } from '@testing-library/react';
import { vi } from 'vitest';
import { DualScrollSyncLabel } from './DualScrollSyncLabel';
describe('DualScrollSyncLabel', () => {
afterEach(() => {
vi.clearAllMocks();
});
it('should render with correct label', () => {
const { getByText } = render(<DualScrollSyncLabel>Test Label</DualScrollSyncLabel>);
expect(getByText('Test Label')).toBeInTheDocument();
});
it('should render children when not a string', () => {
const { getByText } = render(
<DualScrollSyncLabel>
<strong>Bold Label</strong>
</DualScrollSyncLabel>
);
expect(getByText('Bold Label')).toBeInTheDocument();
expect(getByText('Bold Label').tagName).toBe('STRONG');
});
it('should apply custom className and style', () => {
const { getByText } = render(
<DualScrollSyncLabel className="custom-class" style={{ borderWidth: '1px' }}>
Styled Label
</DualScrollSyncLabel>
);
const label = getByText('Styled Label');
expect(label).toHaveClass('custom-class');
expect(label).toHaveStyle('border-width: 1px');
});
it('should not apply custom className or style if children is not a string', () => {
const { getByText } = render(
<DualScrollSyncLabel className="custom-class" style={{ borderWidth: '1px' }}>
<span>Styled Child</span>
</DualScrollSyncLabel>
);
const label = getByText('Styled Child');
expect(label).toBeInTheDocument();
expect(label).not.toHaveClass('custom-class');
expect(label).not.toHaveStyle('border-width: 1px');
});
});