-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDualScrollSyncNav.test.tsx
More file actions
60 lines (49 loc) · 1.55 KB
/
DualScrollSyncNav.test.tsx
File metadata and controls
60 lines (49 loc) · 1.55 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
55
56
57
58
59
60
import { render } from '@testing-library/react';
import { vi } from 'vitest';
import { DualScrollSyncNav } from './DualScrollSyncNav';
describe('DualScrollSyncNav', () => {
afterEach(() => {
vi.clearAllMocks();
});
it('should render children correctly', () => {
const { getByTestId } = render(
<DualScrollSyncNav>
<div>Test Content</div>
</DualScrollSyncNav>
);
expect(getByTestId('test-nav-id')).toBeInTheDocument();
});
it('should apply maxVisibleItems correctly', () => {
const { getByTestId } = render(
<DualScrollSyncNav maxVisibleItems={3}>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
<div>Item 4</div>
</DualScrollSyncNav>
);
const navElement = getByTestId('test-nav-id');
expect(navElement).toHaveStyle({ '--menu-nav-visible-count': '3' });
});
it('should limit visible items to the number of children if fewer than maxVisibleItems', () => {
const { getByTestId } = render(
<DualScrollSyncNav maxVisibleItems={5}>
<div>Item 1</div>
<div>Item 2</div>
<div>Item 3</div>
</DualScrollSyncNav>
);
const navElement = getByTestId('test-nav-id');
expect(navElement).toHaveStyle({ '--menu-nav-visible-count': '3' });
});
it('should apply custom className and style', () => {
const { getByTestId } = render(
<DualScrollSyncNav className="custom-class" style={{ borderWidth: '1px' }}>
<div>Styled Content</div>
</DualScrollSyncNav>
);
const nav = getByTestId('test-nav-id');
expect(nav).toHaveClass('custom-class');
expect(nav).toHaveStyle('border-width: 1px');
});
});