File tree Expand file tree Collapse file tree 1 file changed +32
-5
lines changed
Expand file tree Collapse file tree 1 file changed +32
-5
lines changed Original file line number Diff line number Diff line change 1- import { render } from '@testing-library/react' ;
2- import App from './App.jsx ' ;
1+ import { render , screen , fireEvent } from '@testing-library/react' ;
2+ import App from './App' ;
33
4- test ( 'App renders without crashing' , ( ) => {
5- const { unmount } = render ( < App /> ) ;
6- unmount ( ) ;
4+ test ( 'renders counter button' , ( ) => {
5+ render ( < App /> ) ;
6+ const buttonElement = screen . getByText ( / c o u n t i s 0 / i) ;
7+ expect ( buttonElement ) . toBeInTheDocument ( ) ;
8+ expect ( buttonElement ) . toHaveTextContent ( / c o u n t i s 0 / i) ;
9+ screen . debug ( ) ;
10+ } ) ;
11+
12+ test ( 'count increases on button click' , ( ) => {
13+ render ( < App /> ) ;
14+ const buttonElement = screen . getByText ( / c o u n t i s 0 / i) ;
15+ fireEvent . click ( buttonElement ) ;
16+ expect ( buttonElement ) . toHaveTextContent ( / c o u n t i s 1 / i) ;
17+ screen . debug ( ) ;
18+
19+ fireEvent . click ( buttonElement ) ;
20+ expect ( buttonElement ) . toHaveTextContent ( / c o u n t i s 2 / i) ;
21+ screen . debug ( ) ;
22+ } ) ;
23+
24+ test ( 'renders learn react link' , ( ) => {
25+ render ( < App /> ) ;
26+ const linkElement = screen . getByText ( / l e a r n r e a c t / i) ;
27+ expect ( linkElement ) . toBeInTheDocument ( ) ;
28+ } ) ;
29+
30+ test ( 'renders vite docs link' , ( ) => {
31+ render ( < App /> ) ;
32+ const linkElement = screen . getByText ( / v i t e d o c s / i) ;
33+ expect ( linkElement ) . toBeInTheDocument ( ) ;
734} ) ;
You can’t perform that action at this time.
0 commit comments