Skip to content

Commit

Permalink
Fix TickerUsersForm Test
Browse files Browse the repository at this point in the history
  • Loading branch information
0x46616c6b committed Apr 27, 2024
1 parent 3917f94 commit 730d1e5
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/components/ticker/TickerUsersForm.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { Ticker } from '../../api/Ticker'
import { User } from '../../api/User'
import { fireEvent, render, screen } from '@testing-library/react'
import { render, screen } from '@testing-library/react'
import TickerUsersForm from './TickerUsersForm'
import { vi } from 'vitest'
import userEvent from '@testing-library/user-event'

describe('TickerUsersForm', () => {
beforeEach(() => {
Expand Down Expand Up @@ -46,12 +47,13 @@ describe('TickerUsersForm', () => {
const handleSubmit = vi.fn()
setup([user], ticker, handleSubmit)

fireEvent.mouseDown(screen.getByRole('button'))
const listbox = await screen.findByRole('listbox')
expect(listbox).toBeInTheDocument()
const option = await screen.findByRole('option')
expect(option).toBeInTheDocument()
fireEvent.click(option)
expect(fetch).toHaveBeenCalledTimes(1)
expect(screen.getByRole('combobox')).toBeInTheDocument()

await userEvent.click(screen.getByRole('combobox'))

expect(screen.getByRole('option')).toBeInTheDocument()
expect(screen.getAllByText('user@systemli.org')).toHaveLength(2)

await userEvent.click(screen.getAllByText('user@systemli.org')[1])
})
})

0 comments on commit 730d1e5

Please sign in to comment.