import React from 'react'
import { render, snapshot } from '../utils/test-utils'
import { NaturalLanguageDropdownMenu } from './dropdown-menu'
import { ListItem } from '@planview/pv-uikit'
import userEvent from '@testing-library/user-event'
describe('NaturalLanguageDropdownMenu', () => {
describe('snapshots', () => {
snapshot(
'basic',
)
})
describe('rendering', () => {
it('should render a text based trigger as a combobox', () => {
const { getByRole } = render(
)
expect(
getByRole('combobox', { name: 'Team Options' })
).toHaveTextContent('Team 1')
})
it('should render placeholder text if no triggerValue', () => {
const { getByRole } = render(
)
expect(
getByRole('combobox', { name: 'Team Options' })
).toHaveTextContent('some team')
})
})
describe('interaction', () => {
it('should open the dropdown when the trigger is clicked', async () => {
const { getByRole, findByRole } = render(
)
await userEvent.click(
getByRole('combobox', { name: 'Team Options' })
)
expect(
await findByRole('listbox', { name: 'Team Options' })
).toBeInTheDocument()
expect(
await findByRole('option', { name: 'Custom item' })
).toBeInTheDocument()
})
it('should open the dropdown with the keyboard', async () => {
const { findByRole } = render(
)
await userEvent.keyboard('{Tab}{ArrowDown}')
expect(
await findByRole('listbox', { name: 'Team Options' })
).toBeInTheDocument()
expect(
await findByRole('option', { name: 'Custom item' })
).toBeInTheDocument()
})
})
})