The events are very common in any web application and we need to test them as well, so let's learn how to test events. For this, let's create a new ShowInformation component:
import { FC, useState, ChangeEvent } from 'react'
const ShowInformation: FC = () => {
const [state, setState] = useState({ name: '', age: 0, show: false })
const handleOnChange = (e: ChangeEvent<HTMLInputElement>) => {
const { name, value } = e.target
setState({
...state,
[name]: value
})
}
const handleShowInformation = () => {
setState({
...state,
show: true
})
}
if (state.show) {
return (
<div className="ShowInformation">
<h1>Personal Information</h1>
<div className="personalInformation">
<p>
<strong>Name:</strong> {state.name}
</p>
<p>
<strong>Age:</strong>...