@@ -30,6 +30,20 @@ describe("ContentStylingService", () => {
3030 headline : "Headline" ,
3131 } ;
3232
33+ const mockMarkdown2Subsection : VaccinePageSubsection = {
34+ type : "simpleElement" ,
35+ text : "<h2>This is second styled paragraph markdown subsection</h2>" ,
36+ name : "markdown" ,
37+ headline : "Headline2" ,
38+ } ;
39+
40+ const mockMarkdown3Subsection : VaccinePageSubsection = {
41+ type : "simpleElement" ,
42+ text : "<h2>This is third styled paragraph markdown subsection</h2>" ,
43+ name : "markdown" ,
44+ headline : "Headline3" ,
45+ } ;
46+
3347 const mockHowToGetMarkdownSubsection : VaccinePageSubsection = {
3448 type : "simpleElement" ,
3549 text : "<p>para</p><h3>If you're aged 75 to 79</h3><p>para1</p><p>para2</p><h3>If you're pregnant</h3><p>para3</p><p>para4</p>" ,
@@ -66,7 +80,7 @@ describe("ContentStylingService", () => {
6680
6781 describe ( "styleSubsection" , ( ) => {
6882 it ( "should return styled markdown component for subsection beginning with headline" , async ( ) => {
69- const styledSubsection : JSX . Element | undefined = styleSubsection ( mockMarkdownSubsection , 1 ) ;
83+ const styledSubsection : JSX . Element | undefined = styleSubsection ( mockMarkdownSubsection , 1 , false ) ;
7084 render ( styledSubsection ) ;
7185
7286 const heading1 : HTMLElement = screen . getByRole ( "heading" , {
@@ -87,7 +101,7 @@ describe("ContentStylingService", () => {
87101 headline : "" ,
88102 } ;
89103
90- const styledSubsection : JSX . Element | undefined = styleSubsection ( mockMarkdownSubsection , 1 ) ;
104+ const styledSubsection : JSX . Element | undefined = styleSubsection ( mockMarkdownSubsection , 1 , false ) ;
91105 render ( styledSubsection ) ;
92106
93107 const div : HTMLElement = screen . getByRole ( "section" ) ;
@@ -105,7 +119,7 @@ describe("ContentStylingService", () => {
105119 headline : "" ,
106120 } ;
107121
108- const styledSubsection : JSX . Element = styleSubsection ( mockInformationSubsection , 1 ) ;
122+ const styledSubsection : JSX . Element = styleSubsection ( mockInformationSubsection , 1 , false ) ;
109123 render ( styledSubsection ) ;
110124
111125 const text : HTMLElement = screen . getByText ( "This is a styled paragraph information subsection" ) ;
@@ -117,7 +131,7 @@ describe("ContentStylingService", () => {
117131 } ) ;
118132
119133 it ( "should return styled non-urgent component for subsection" , async ( ) => {
120- const styledSubsection : JSX . Element = styleSubsection ( mockNonUrgentSubsection , 1 ) ;
134+ const styledSubsection : JSX . Element = styleSubsection ( mockNonUrgentSubsection , 1 , false ) ;
121135 render ( styledSubsection ) ;
122136
123137 const text : HTMLElement = screen . getByText ( "This is a styled paragraph non-urgent subsection" ) ;
@@ -130,7 +144,7 @@ describe("ContentStylingService", () => {
130144 } ) ;
131145
132146 it ( "should return styled urgent component for subsection" , async ( ) => {
133- const styledSubsection : JSX . Element = styleSubsection ( mockUrgentSubsection , 1 ) ;
147+ const styledSubsection : JSX . Element = styleSubsection ( mockUrgentSubsection , 1 , false ) ;
134148 render ( styledSubsection ) ;
135149
136150 const text : HTMLElement = screen . getByText ( "This is a styled paragraph urgent subsection" ) ;
@@ -143,7 +157,7 @@ describe("ContentStylingService", () => {
143157 } ) ;
144158
145159 it ( "should return table component for subsection" , async ( ) => {
146- const styledSubsection : JSX . Element = styleSubsection ( mockTableSubsection , 1 ) ;
160+ const styledSubsection : JSX . Element = styleSubsection ( mockTableSubsection , 1 , false ) ;
147161 render ( styledSubsection ) ;
148162
149163 const column1 : HTMLElement = screen . getByText ( "Name" ) ;
@@ -158,7 +172,7 @@ describe("ContentStylingService", () => {
158172 } ) ;
159173
160174 it ( "should return styled callout component for subsection" , async ( ) => {
161- const styledSubsection : JSX . Element = styleSubsection ( mockCalloutSubsection , 1 ) ;
175+ const styledSubsection : JSX . Element = styleSubsection ( mockCalloutSubsection , 1 , false ) ;
162176 render ( styledSubsection ) ;
163177
164178 const text : HTMLElement = screen . getByText ( "This is a styled paragraph callout subsection" ) ;
@@ -193,6 +207,23 @@ describe("ContentStylingService", () => {
193207 expect ( urgentSubsection ) . toBeInTheDocument ( ) ;
194208 expect ( columnOfTable ) . toBeInTheDocument ( ) ;
195209 } ) ;
210+
211+ it ( "should display last subsection with zero margin in a section" , async ( ) => {
212+ const mockSection : VaccinePageSection = {
213+ headline : "This is a heading" ,
214+ subsections : [ mockMarkdownSubsection , mockMarkdown2Subsection , mockMarkdown3Subsection ] ,
215+ } ;
216+
217+ const styledSection : StyledPageSection = styleSection ( mockSection ) ;
218+ render ( styledSection . component ) ;
219+ const markdownSubsection : HTMLElement = screen . getByText ( "This is a styled paragraph markdown subsection" ) ;
220+ const markdown2Subsection : HTMLElement = screen . getByText ( "This is second styled paragraph markdown subsection" ) ;
221+ const markdown3Subsection : HTMLElement = screen . getByText ( "This is third styled paragraph markdown subsection" ) ;
222+
223+ expect ( markdownSubsection . parentNode ) . not . toHaveClass ( "zeroMarginBottom" ) ;
224+ expect ( markdown2Subsection . parentNode ) . not . toHaveClass ( "zeroMarginBottom" ) ;
225+ expect ( markdown3Subsection . parentNode ) . toHaveClass ( "zeroMarginBottom" ) ;
226+ } ) ;
196227 } ) ;
197228
198229 describe ( "getStyledContentForVaccine" , ( ) => {
@@ -237,7 +268,7 @@ describe("ContentStylingService", () => {
237268 const expectedRsvHowToGetSection = "<div><p>para1</p><p>para2</p></div>" ;
238269 const expectedRsvPregnancyHowToGetSection = `<div><div><p>para3</p><p>para4</p></div></div>` ;
239270 const expectedGenericVaccineHowToGetSection =
240- "<div><h3>How To Get Headline</h3><p>para</p><h3>If you're aged 75 to 79</h3><p>para1</p><p>para2</p><h3>If you're pregnant</h3><p>para3</p><p>para4</p></div>" ;
271+ "<div class=\"zeroMarginBottom\" ><h3>How To Get Headline</h3><p>para</p><h3>If you're aged 75 to 79</h3><p>para1</p><p>para2</p><h3>If you're pregnant</h3><p>para3</p><p>para4</p></div>" ;
241272 const { container } = render ( styledVaccineContent . howToGetVaccine . component ) ;
242273 if ( vaccine === VaccineType . RSV ) {
243274 expect ( container ) . toContainHTML ( expectedRsvHowToGetSection ) ;
0 commit comments