-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathVerticalContainer.test.tsx
More file actions
61 lines (55 loc) · 1.69 KB
/
VerticalContainer.test.tsx
File metadata and controls
61 lines (55 loc) · 1.69 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
61
import { createRef } from 'react'
import { describe, expect, it } from 'vitest'
import { render, screen } from '@testing-library/react'
import { VerticalContainer } from './VerticalContainer'
describe('VerticalContainer', () => {
it('renders children correctly', () => {
render(
<VerticalContainer>
<div>Test Child</div>
</VerticalContainer>,
)
expect(screen.getByText('Test Child')).toBeInTheDocument()
})
it('should force layout to be vertical (still having flex-col)', () => {
render(
<VerticalContainer className="flex-row">
<div>Child</div>
</VerticalContainer>,
)
const container = screen.getByText('Child').parentElement
expect(container).toHaveClass('flex-col')
})
it('renders ScrollContainer when scroll is true', () => {
render(
<VerticalContainer scroll={true}>
<div>Scroll Child</div>
</VerticalContainer>,
)
expect(
screen.getByText('Scroll Child').parentElement?.parentElement,
).toHaveClass('overflow-y-scroll scrollbar-w-[6px]')
})
it('renders a div when scroll is false', () => {
render(
<VerticalContainer scroll={false}>
<div>Div Child</div>
</VerticalContainer>,
)
const container = screen.getByText('Div Child').parentElement
expect(container).toHaveClass('overflow-hidden')
})
it('forwards ref to the div element when scroll is false', () => {
const ref = createRef<HTMLDivElement>()
render(
<VerticalContainer
ref={ref}
scroll={false}
>
<div>Ref Child</div>
</VerticalContainer>,
)
expect(ref.current).toBeInstanceOf(HTMLElement)
expect(ref.current?.tagName).toBe('DIV')
})
})