Skip to content

Commit 269f678

Browse files
committed
Fix select componenet
1 parent 3c9a5bc commit 269f678

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

packages/components/src/components/Select/__tests__/index.browser.test.tsx

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,12 @@ describe('Select', () => {
374374

375375
it('should render with options properties', () => {
376376
const { container } = render(
377-
<Select options={[{ label: 'Option 1', value: 'Option 1' }]}>
377+
<Select
378+
options={[
379+
{ label: 'Option 1', value: 'Option 1' },
380+
{ value: 'Option 2' },
381+
]}
382+
>
378383
Select
379384
</Select>,
380385
)
@@ -384,6 +389,27 @@ describe('Select', () => {
384389
expect(option1).toBeInTheDocument()
385390
})
386391

392+
it('should call onChange function when it is provided to SelectOption', () => {
393+
const onValueChange = vi.fn()
394+
const { container } = render(
395+
<Select
396+
onChange={onValueChange}
397+
options={[
398+
{ label: 'Option 1', value: 'Option 1' },
399+
{ value: 'Option 2' },
400+
]}
401+
>
402+
Select
403+
</Select>,
404+
)
405+
const selectToggle = container.querySelector('[aria-label="Select toggle"]')
406+
fireEvent.click(selectToggle!)
407+
const option2 = container.querySelector('[data-value="Option 2"]')
408+
expect(option2).toBeInTheDocument()
409+
fireEvent.click(option2!)
410+
expect(onValueChange).toHaveBeenCalledWith('Option 2')
411+
})
412+
387413
it('should render with x and y properties', () => {
388414
const { container } = render(
389415
<Select>
@@ -396,4 +422,13 @@ describe('Select', () => {
396422
)
397423
expect(container).toMatchSnapshot()
398424
})
425+
426+
it('should render with overflow screen', () => {
427+
const { container } = render(
428+
<Flex alignItems="flex-end" h="100vh" justifyContent="center" w="100vw">
429+
<Select>{children}</Select>
430+
</Flex>,
431+
)
432+
expect(container).toMatchSnapshot()
433+
})
399434
})

0 commit comments

Comments
 (0)