Skip to content

Commit b9cb448

Browse files
committed
feat: use the right test
1 parent dbb0e5f commit b9cb448

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

__tests__/components/sections/homepage/Testimonials.test.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
import { render, screen } from "@testing-library/react";
1+
import "@testing-library/jest-dom";
2+
import { screen } from "@testing-library/react";
23
import TestimonialsSection from "@/components/sections/homepage/Testimonials";
4+
import { renderWithRedux } from "../../../../__mocks__/renderWithRedux";
35

46
describe("Testimonials Section", () => {
57
const testimonials = [
@@ -15,9 +17,9 @@ describe("Testimonials Section", () => {
1517
];
1618

1719
it("should render testimonials with correct content", () => {
18-
render(<TestimonialsSection />);
19-
expect(screen.getByText("testimonials.community.title")).toBeInTheDocument();
20-
expect(screen.getByText("footer.open.source")).toBeInTheDocument();
20+
renderWithRedux(<TestimonialsSection testId="testimonialsId"/>);
21+
const testimonial = screen.getByTestId("testimonialsId");
22+
expect(testimonial).toBeInTheDocument();
2123

2224
testimonials.forEach((testimonial) => {
2325
expect(screen.getByAltText(testimonial.icon)).toBeInTheDocument();

__tests__/components/sections/homepage/_partials/Stories.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ describe("Stories", () => {
1414
expect(screen.getByTestId("testimonialsId")).toBeInTheDocument();
1515
const mockGrid = _.chunk([fixtureTestimonials], 5);
1616
mockGrid.forEach((grid) => {
17-
grid.forEach(() => {
17+
grid.forEach((story) => {
1818
const storyImage = screen.getByRole("img");
1919
expect(storyImage).toBeInTheDocument();
2020
expect(storyImage.hasAttribute("src")).toBeTruthy();
21+
expect(storyImage.getAttribute("src")).toContain(story.icon.replace("/testimonials-icon", "/_next/image?url=%2Ftestimonials-icon&w=96&q=75"));
22+
expect(storyImage.hasAttribute("alt")).toBeTruthy();
2123
});
2224
});
2325
});

src/components/sections/homepage/Testimonials.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ const stories = (t: TFunction<"translation", undefined, "translation">): Testimo
7575
];
7676
};
7777

78-
export default function TestimonialsSection(): ReactElement {
78+
export default function TestimonialsSection({testId}: {testId?: string}): ReactElement {
7979
const { t } = useTranslation();
8080
return (
81+
<div data-testid={testId}>
8182
<Section type="secondary-light" padding="py-6 xl:py-10 md:py-8 mt-5">
8283
<CommunityStats />
8384
<Stories list={stories(t)} />
8485
<OpenSource/>
8586
</Section>
87+
</div>
8688
);
8789
}

0 commit comments

Comments
 (0)