Skip to content

Commit b86a937

Browse files
committed
feat: add test for section homepage partials stories
1 parent 439c459 commit b86a937

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
});

src/components/sections/homepage/_partials/testimonials/Stories.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface Testimonial {
2121
*/
2222
interface TestimonialsSectionProps {
2323
list: Testimonial[];
24+
testId?: string;
2425
}
2526

2627
/**
@@ -35,7 +36,7 @@ interface ShowingBubble {
3536
grid: number | null;
3637
}
3738

38-
export default function TestimonialsSection({ list }: TestimonialsSectionProps): ReactElement {
39+
export default function TestimonialsSection({ list, testId }: TestimonialsSectionProps): ReactElement {
3940
const [showingBubble, setShowingBubble] = useState<ShowingBubble>(() => ({
4041
card: 4,
4142
grid: 0,
@@ -94,7 +95,7 @@ export default function TestimonialsSection({ list }: TestimonialsSectionProps):
9495
};
9596

9697
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">
9899
{grids.map((grid, gridIndex) => {
99100
return (
100101
<span

0 commit comments

Comments
 (0)