Skip to content

Commit 3c03f5e

Browse files
VIA-304 SB Overview component renders HTML.
1 parent 0ea4e78 commit 3c03f5e

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Overview } from "@src/app/_components/content/Overview";
2+
import { VaccineType } from "@src/models/vaccine";
3+
import { mockStyledContent } from "@test-data/content-api/data";
4+
import { render, screen } from "@testing-library/react";
5+
import React from "react";
6+
7+
describe("Overview component", () => {
8+
it("renders correctly", () => {
9+
const vaccineType = VaccineType.SHINGLES;
10+
11+
render(<Overview styledVaccineContent={mockStyledContent} vaccineType={vaccineType} />);
12+
13+
const overviewText: HTMLElement = screen.getByTestId("overview-text");
14+
15+
expect(overviewText).toBeInTheDocument();
16+
17+
const boldElement = screen.getByText("text");
18+
19+
expect(overviewText).toContainElement(boldElement);
20+
expect(boldElement).toBeInTheDocument();
21+
expect(boldElement.tagName).toBe("B");
22+
});
23+
});

src/app/_components/content/Overview.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ import { JSX } from "react";
44

55
const Overview = (props: { styledVaccineContent: StyledVaccineContent; vaccineType: VaccineType }): JSX.Element => {
66
return (
7-
<>
8-
<p data-testid="overview-text">{props.styledVaccineContent?.overview}</p>
9-
</>
7+
<p data-testid="overview-text" dangerouslySetInnerHTML={{ __html: props.styledVaccineContent?.overview || "" }} />
108
);
119
};
1210
export { Overview };

test-data/content-api/data.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ export const genericVaccineContentAPIResponse: ContentApiVaccineResponse = {
559559
};
560560

561561
export const mockStyledContent: StyledVaccineContent = {
562-
overview: "Overview text",
562+
overview: "Overview <b>text</b>",
563563
whatVaccineIsFor: {
564564
heading: "what-heading",
565565
component: <p>What Section styled component</p>,

0 commit comments

Comments
 (0)