File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,3 +22,4 @@ dist-ssr
2222* .njsproj
2323* .sln
2424* .sw ?
25+ .slingshot /
Original file line number Diff line number Diff line change 1+ import React from "react" ;
2+ import { render , screen , fireEvent } from "@testing-library/react" ;
3+ import "@testing-library/jest-dom/extend-expect" ;
4+ import App from "../components/app.jsx" ; // Adjust the import path as necessary
5+
6+ test ( "rendersAppWithoutCrashing" , ( ) => {
7+ render ( < App /> ) ;
8+ expect ( screen . getByText ( / W e l c o m e t o t h e A p p / i) ) . toBeInTheDocument ( ) ;
9+ } ) ;
10+
11+ test ( "displaysInitialStateCorrectly" , ( ) => {
12+ render ( < App /> ) ;
13+ expect ( screen . getByText ( / I n i t i a l S t a t e / i) ) . toBeInTheDocument ( ) ;
14+ } ) ;
15+
16+ test ( "handlesButtonClickEvent" , ( ) => {
17+ render ( < App /> ) ;
18+ const button = screen . getByRole ( "button" , { name : / C l i c k M e / i } ) ;
19+ fireEvent . click ( button ) ;
20+ expect ( screen . getByText ( / B u t t o n C l i c k e d / i) ) . toBeInTheDocument ( ) ;
21+ } ) ;
22+
23+ test ( "rendersErrorMessageOnInvalidInput" , ( ) => {
24+ render ( < App /> ) ;
25+ const input = screen . getByLabelText ( / I n p u t / i) ;
26+ fireEvent . change ( input , { target : { value : "invalid" } } ) ;
27+ expect ( screen . getByText ( / E r r o r : I n v a l i d I n p u t / i) ) . toBeInTheDocument ( ) ;
28+ } ) ;
29+
30+ test ( "updatesStateOnValidInput" , ( ) => {
31+ render ( < App /> ) ;
32+ const input = screen . getByLabelText ( / I n p u t / i) ;
33+ fireEvent . change ( input , { target : { value : "valid" } } ) ;
34+ expect ( screen . getByText ( / S t a t e U p d a t e d / i) ) . toBeInTheDocument ( ) ;
35+ } ) ;
You can’t perform that action at this time.
0 commit comments