File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
src/components/SearchResult/__test__ Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ import TableBody from "../TableBody" ;
2+ import { render , screen , fireEvent } from "@testing-library/react" ;
3+
4+ test ( "Verify that each row of your table can be highlighted (on and off) independently when being clicked." , ( ) => {
5+ render (
6+ < table >
7+ < tbody >
8+ < TableBody
9+ id = { 1 }
10+ title = { "tab" }
11+ name = { "he" }
12+ firstName = { "gr" }
13+ surName = { "dj" }
14+ email = { "df" }
15+ roomId = { "kd" }
16+ checkInDate = { "fd" }
17+ checkOutDate = { "v" }
18+ stayNights = { "om" }
19+ />
20+ </ tbody >
21+ </ table >
22+ ) ;
23+
24+ const tableRows = screen . getAllByRole ( "row" ) ;
25+
26+ tableRows . forEach ( ( row ) => {
27+ fireEvent . click ( row ) ;
28+ expect ( row ) . toHaveClass ( "selected" ) ;
29+ fireEvent . click ( row ) ;
30+ expect ( row ) . not . toHaveClass ( "selected" ) ;
31+ } ) ;
32+ } ) ;
You can’t perform that action at this time.
0 commit comments