Skip to content

Commit

Permalink
chore(select): change to use functions from render instead of screen
Browse files Browse the repository at this point in the history
  • Loading branch information
Kzoeps authored and jannikbuschke committed Nov 24, 2022
1 parent 35d208a commit 4563e51
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/select/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Form } from '../form'
import Select from './index'
import '@testing-library/jest-dom/extend-expect'
import { act } from 'react-dom/test-utils'
import { fireEvent, render, screen } from '@testing-library/react'
import { fireEvent, render } from '@testing-library/react'

const TestSelect = () => {
return (
Expand All @@ -21,8 +21,8 @@ const TestSelect = () => {
}

test('renders select', async () => {
render(<TestSelect/>)
expect(screen.queryByRole('combobox')).toBeInTheDocument()
const { queryByRole } = render(<TestSelect />)
expect(queryByRole('combobox')).toBeInTheDocument()
})

test('sets initial value', async () => {
Expand All @@ -31,12 +31,12 @@ test('sets initial value', async () => {
})

test('changes selected upon clicking', async () => {
const { getByRole, queryByText, getByText, queryAllByText } = render(<TestSelect/>)
const { getByRole, queryByText, getByText, getAllByText } = render(<TestSelect/>)
const selector = getByRole('combobox')
expect(queryByText('Zero')).toBeInTheDocument()
fireEvent.mouseDown(selector)
await act(async () => {
fireEvent.click(getByText('One'))
})
expect(queryAllByText('One').length).toBeGreaterThan(1)
expect(getAllByText('One').length).toBeGreaterThan(1)
})

0 comments on commit 4563e51

Please sign in to comment.