File tree Expand file tree Collapse file tree
src/components/Card/__test__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import Card from "../Card" ;
2+ import { render , screen } from "@testing-library/react" ;
3+
4+ test ( "should render a title" , ( ) => {
5+ render (
6+ < Card
7+ title = "countryName"
8+ url = "https://example.com"
9+ image = "test-image.jpg"
10+ />
11+ ) ;
12+ const titleElement = screen . getAllByText ( "countryName" ) ;
13+ expect ( titleElement ) . toBeInTheDocument ( ) ;
14+ } ) ;
15+
16+ test ( "should render a link with the correct URL" , ( ) => {
17+ render (
18+ < Card title = "Manchester" url = "https://example.com" image = "test-image.jpg" />
19+ ) ;
20+ const linkElement = screen . getByRole ( "link" , { name : "Manchester" } ) ;
21+ expect ( linkElement ) . toBeInTheDocument ( ) ;
22+ expect ( linkElement ) . toHaveAttribute ( "href" , "https://example.com" ) ;
23+ } ) ;
24+
25+ test ( "should render an image with alt text" , ( ) => {
26+ render (
27+ < Card title = "Manchester" url = "https://example.com" image = "test-image.jpg" />
28+ ) ;
29+ const imageElement = screen . getByAltText ( "Manchester" ) ;
30+ expect ( imageElement ) . toBeInTheDocument ( ) ;
31+ } ) ;
Original file line number Diff line number Diff line change 1+ Feature-Active-row[m
2+ Feature-Search-State[m
3+ Feature-implement-Search-functionality[m
4+ FeatureCalculateDuration[m
5+ Search-onSubmit[m
6+ feature-booking-state[m
7+ * [32mfeature-card[m
8+ feature-deck[m
9+ fetch-bookings[m
10+ main[m
11+ search-results[m
You can’t perform that action at this time.
0 commit comments