11import '@testing-library/jest-dom'
2- import { render } from '@testing-library/vue'
2+ import { render , waitFor } from '@testing-library/vue'
33import userEvent from '@testing-library/user-event'
44import Form from './components/Form'
55import Select from './components/Select'
@@ -24,49 +24,49 @@ test('User events in a form', async () => {
2424 expect ( submitButton ) . toBeDisabled ( )
2525
2626 const titleInput = getByLabelText ( / t i t l e o f t h e m o v i e / i)
27- await userEvent . type ( titleInput , fakeReview . title )
27+ userEvent . type ( titleInput , fakeReview . title )
2828 expect ( titleInput . value ) . toEqual ( fakeReview . title )
2929
3030 const textArea = getByLabelText ( / Y o u r r e v i e w / i)
31- await userEvent . type ( textArea , 'The t-rex went insane!' )
31+ userEvent . type ( textArea , 'The t-rex went insane!' )
3232 expect ( textArea . value ) . toEqual ( 'The t-rex went insane!' )
3333
34- await userEvent . clear ( textArea )
34+ userEvent . clear ( textArea )
3535 expect ( textArea . value ) . toEqual ( '' )
36- await userEvent . type ( textArea , fakeReview . review )
36+ userEvent . type ( textArea , fakeReview . review )
3737 expect ( textArea . value ) . toEqual ( fakeReview . review )
3838
3939 const initialSelectedRating = getByLabelText ( / A w f u l / i)
4040 const wonderfulRadioInput = getByLabelText ( / W o n d e r f u l / i)
4141 expect ( initialSelectedRating ) . toBeChecked ( )
4242 expect ( wonderfulRadioInput ) . not . toBeChecked ( )
4343
44- await userEvent . click ( wonderfulRadioInput )
44+ userEvent . click ( wonderfulRadioInput )
4545 expect ( wonderfulRadioInput ) . toBeChecked ( )
46- expect ( initialSelectedRating ) . not . toBeChecked ( )
46+ await waitFor ( ( ) => expect ( initialSelectedRating ) . not . toBeChecked ( ) )
4747
4848 const recommendInput = getByLabelText ( / W o u l d y o u r e c o m m e n d t h i s m o v i e ? / i)
49- await userEvent . click ( recommendInput )
49+ userEvent . click ( recommendInput )
5050 expect ( recommendInput ) . toBeChecked ( )
5151
5252 userEvent . tab ( )
5353 expect ( submitButton ) . toHaveFocus ( )
5454 expect ( submitButton ) . toBeEnabled ( )
55- await userEvent . type ( submitButton , '{enter}' )
55+ userEvent . type ( submitButton , '{enter}' )
5656 expect ( emitted ( ) . submit [ 0 ] [ 0 ] ) . toMatchObject ( fakeReview )
5757
5858 expect ( console . warn ) . not . toHaveBeenCalled ( )
5959} )
6060
61- test ( 'selecting option with user events' , async ( ) => {
61+ test ( 'selecting option with user events' , ( ) => {
6262 const { getByDisplayValue} = render ( Select )
6363 const select = getByDisplayValue ( 'Tyrannosaurus' )
6464 expect ( select . value ) . toBe ( 'dino1' )
6565
66- await userEvent . selectOptions ( select , 'dino2' )
66+ userEvent . selectOptions ( select , 'dino2' )
6767 expect ( select . value ) . toBe ( 'dino2' )
6868
69- await userEvent . selectOptions ( select , 'dino3' )
69+ userEvent . selectOptions ( select , 'dino3' )
7070 expect ( select . value ) . not . toBe ( 'dino2' )
7171 expect ( select . value ) . toBe ( 'dino3' )
7272} )
0 commit comments