File tree Expand file tree Collapse file tree 3 files changed +25
-4
lines changed
src/app/_components/content Expand file tree Collapse file tree 3 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 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+ } ) ;
Original file line number Diff line number Diff line change @@ -4,9 +4,7 @@ import { JSX } from "react";
44
55const 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} ;
1210export { Overview } ;
Original file line number Diff line number Diff line change @@ -559,7 +559,7 @@ export const genericVaccineContentAPIResponse: ContentApiVaccineResponse = {
559559} ;
560560
561561export 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 > ,
You can’t perform that action at this time.
0 commit comments