File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
__tests__/components/sections/homepage/_partials
src/components/sections/homepage/_partials/testimonials Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change
1
+ import TestimonialsSection from "@/components/sections/homepage/_partials/testimonials/Stories" ;
2
+ import "@testing-library/jest-dom" ;
3
+ import { render , screen } from "@testing-library/react" ;
4
+ import _ from "lodash" ;
5
+
6
+ const fixtureTestimonials = {
7
+ content : "testimonials content" ,
8
+ icon : "/testimonials-icon" ,
9
+ } ;
10
+
11
+ describe ( "Stories" , ( ) => {
12
+ it ( "should display the storis" , ( ) => {
13
+ render ( < TestimonialsSection testId = "testimonialsId" list = { [ fixtureTestimonials ] } /> ) ;
14
+ expect ( screen . getByTestId ( "testimonialsId" ) ) . toBeInTheDocument ( ) ;
15
+ const mockGrid = _ . chunk ( [ fixtureTestimonials ] , 5 ) ;
16
+ mockGrid . forEach ( ( grid ) => {
17
+ grid . forEach ( ( ) => {
18
+ const storyImage = screen . getByRole ( "img" ) ;
19
+ expect ( storyImage ) . toBeInTheDocument ( ) ;
20
+ expect ( storyImage . hasAttribute ( "src" ) ) . toBeTruthy ( ) ;
21
+ } ) ;
22
+ } ) ;
23
+ } ) ;
24
+ } ) ;
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ interface Testimonial {
21
21
*/
22
22
interface TestimonialsSectionProps {
23
23
list : Testimonial [ ] ;
24
+ testId ?: string ;
24
25
}
25
26
26
27
/**
@@ -35,7 +36,7 @@ interface ShowingBubble {
35
36
grid : number | null ;
36
37
}
37
38
38
- export default function TestimonialsSection ( { list } : TestimonialsSectionProps ) : ReactElement {
39
+ export default function TestimonialsSection ( { list, testId } : TestimonialsSectionProps ) : ReactElement {
39
40
const [ showingBubble , setShowingBubble ] = useState < ShowingBubble > ( ( ) => ( {
40
41
card : 4 ,
41
42
grid : 0 ,
@@ -94,7 +95,7 @@ export default function TestimonialsSection({ list }: TestimonialsSectionProps):
94
95
} ;
95
96
96
97
return (
97
- < div className = "relative w-full top-0 h-screen left-0 z-0 hidden md:block md:max-h-3xl lg:max-h-4xl xl:max-h-7.1xl" >
98
+ < div data-testid = { testId } className = "relative w-full top-0 h-screen left-0 z-0 hidden md:block md:max-h-3xl lg:max-h-4xl xl:max-h-7.1xl" >
98
99
{ grids . map ( ( grid , gridIndex ) => {
99
100
return (
100
101
< span
You can’t perform that action at this time.
0 commit comments