@@ -3,18 +3,22 @@ import {App} from './App'
33import { server } from './mocks/server'
44import { queryClient , render , screen } from './test-utils'
55
6- it ( 'renders apple' , async ( ) => {
7- const { user} = render ( < App /> )
6+ const widths = [ 360 , 1280 ]
87
9- expect ( screen . getByText ( 'Loading...' ) ) . toBeInTheDocument ( )
8+ it . each ( widths ) (
9+ 'should show a list of fruits and then select one with %o viewport' ,
10+ async width => {
11+ window . happyDOM ?. setViewport ( { width, height : 720 } )
12+ const { user} = render ( < App /> , { route : '/' } )
1013
11- await expect ( screen . findAllByRole ( 'link' ) ) . resolves . toHaveLength ( 6 )
14+ await expect ( screen . findAllByRole ( 'link' ) ) . resolves . toHaveLength ( 6 )
1215
13- const button = await screen . findByRole ( 'link' , { name : / A p p l e / } )
14- await user . click ( button )
16+ const button = await screen . findByRole ( 'link' , { name : / A p p l e / } )
17+ await user . click ( button )
1518
16- await expect ( screen . findByText ( 'Vitamin K' ) ) . resolves . toBeInTheDocument ( )
17- } )
19+ await expect ( screen . findByText ( 'Vitamin K' ) ) . resolves . toBeInTheDocument ( )
20+ }
21+ )
1822
1923it ( 'redirects home page when trying to access an invalid fruit' , async ( ) => {
2024 render ( < App /> , { route : '/invalid-fruit' } )
0 commit comments