File tree Expand file tree Collapse file tree 3 files changed +27
-21
lines changed Expand file tree Collapse file tree 3 files changed +27
-21
lines changed Original file line number Diff line number Diff line change 1+ {
2+ "editor.autoSave" : " on" ,
3+ "typescript.tsdk" : " node_modules/typescript/lib"
4+ }
Original file line number Diff line number Diff line change @@ -2,8 +2,13 @@ import React from 'react';
22import { render , screen } from '@testing-library/react' ;
33import App from './App' ;
44
5- test ( 'renders learn react link' , ( ) => {
6- render ( < App /> ) ;
7- const linkElement = screen . getByText ( / l e a r n r e a c t / i) ;
8- expect ( linkElement ) . toBeInTheDocument ( ) ;
9- } ) ;
5+ describe ( '<App />' , ( ) => {
6+ test ( 'render elements without any problem' , ( ) => {
7+ render ( < App /> ) ;
8+ const wrapper = screen . getByTestId ( 'app-wrapper' ) ;
9+ expect ( wrapper ) . toBeInTheDocument ( ) ;
10+
11+ const input = screen . getByTestId ( 'app-input' ) ;
12+ expect ( input ) . toBeInTheDocument ( ) ;
13+ } ) ;
14+ } )
Original file line number Diff line number Diff line change 1- import React from 'react' ;
1+ import React , { useState } from 'react' ;
22import logo from './logo.svg' ;
33import './App.css' ;
44
55function App ( ) {
6+ const [ text , setText ] = useState ( '' ) ;
7+
8+ const updateState = ( event : any ) => {
9+ setText ( event . target . value )
10+ }
11+
612 return (
7- < div className = "App" >
8- < header className = "App-header" >
9- < img src = { logo } className = "App-logo" alt = "logo" />
10- < p >
11- Edit < code > src/App.tsx</ code > and save to reload.
12- </ p >
13- < a
14- className = "App-link"
15- href = "https://reactjs.org"
16- target = "_blank"
17- rel = "noopener noreferrer"
18- >
19- Learn React
20- </ a >
21- </ header >
13+ < div data-testid = "app-wrapper" >
14+ < input
15+ onChange = { ( event ) => updateState ( event ) }
16+ type = "text"
17+ data-testid = "app-input"
18+ />
2219 </ div >
2320 ) ;
2421}
You can’t perform that action at this time.
0 commit comments