@@ -2,10 +2,39 @@ import { MoreInformation } from "@src/app/_components/content/MoreInformation";
22import { VaccineType } from "@src/models/vaccine" ;
33import { mockStyledContent , mockStyledContentWithoutWhatSection } from "@test-data/content-api/data" ;
44import { render , screen } from "@testing-library/react" ;
5- import React from "react" ;
5+
6+ describe ( "MoreInformation component for COVID" , ( ) => {
7+ const covid19VaccineType : VaccineType = VaccineType . COVID_19 ;
8+
9+ it ( "should not show how-to-get expander section when campaign is active" , async ( ) => {
10+ render (
11+ < MoreInformation
12+ styledVaccineContent = { mockStyledContent }
13+ vaccineType = { covid19VaccineType }
14+ isCampaignActive = { true }
15+ /> ,
16+ ) ;
17+
18+ // COVID-19 vaccine content (active campaign)
19+ expectExpanderBlockToNotBePresent ( "How to get the vaccine" , "How Section styled component" ) ;
20+ } ) ;
21+
22+ it ( "should show how-to-get expander section when campaign is inactive" , async ( ) => {
23+ render (
24+ < MoreInformation
25+ styledVaccineContent = { mockStyledContent }
26+ vaccineType = { covid19VaccineType }
27+ isCampaignActive = { false }
28+ /> ,
29+ ) ;
30+
31+ // COVID-19 vaccine content (closed campaign)
32+ expectExpanderBlockToBePresent ( "How to get the vaccine" , "How Section styled component" ) ;
33+ } ) ;
34+ } ) ;
635
736describe ( "MoreInformation component " , ( ) => {
8- describe ( "moreInformationHeadersFromContentApi false" , ( ) => {
37+ describe ( "When vaccineInfo.moreInformationHeadersFromContentApi= false" , ( ) => {
938 it ( "should display whatItIsFor expander block" , async ( ) => {
1039 const vaccineType = VaccineType . RSV ;
1140 render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
@@ -35,7 +64,7 @@ describe("MoreInformation component ", () => {
3564 } ) ;
3665 } ) ;
3766
38- describe ( "moreInformationHeadersFromContentApi true" , ( ) => {
67+ describe ( "When vaccineInfo.moreInformationHeadersFromContentApi= true" , ( ) => {
3968 it ( "should display whatItIsFor expander block" , async ( ) => {
4069 const vaccineType = VaccineType . FLU_IN_PREGNANCY ;
4170 render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
@@ -65,53 +94,55 @@ describe("MoreInformation component ", () => {
6594 } ) ;
6695 } ) ;
6796
68- it ( "should not include 'how to get' section for RSV_PREGNANCY " , async ( ) => {
69- const vaccineType = VaccineType . RSV_PREGNANCY ;
70- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
97+ describe ( "For RSV and RSV in pregnancy" , ( ) => {
98+ it ( "should not include 'how to get' section for RSV_PREGNANCY " , async ( ) => {
99+ const vaccineType = VaccineType . RSV_PREGNANCY ;
100+ render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
71101
72- const heading : HTMLElement | null = screen . queryByText ( "How to get the vaccine" ) ;
102+ const heading : HTMLElement | null = screen . queryByText ( "How to get the vaccine" ) ;
73103
74- expect ( heading ) . not . toBeInTheDocument ( ) ;
75- } ) ;
104+ expect ( heading ) . not . toBeInTheDocument ( ) ;
105+ } ) ;
76106
77- it ( "should not include 'how to get' section for RSV " , async ( ) => {
78- const vaccineType = VaccineType . RSV ;
79- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
107+ it ( "should not include 'how to get' section for RSV " , async ( ) => {
108+ const vaccineType = VaccineType . RSV ;
109+ render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
80110
81- const heading : HTMLElement | null = screen . queryByText ( "How to get the vaccine" ) ;
111+ const heading : HTMLElement | null = screen . queryByText ( "How to get the vaccine" ) ;
82112
83- expect ( heading ) . not . toBeInTheDocument ( ) ;
84- } ) ;
113+ expect ( heading ) . not . toBeInTheDocument ( ) ;
114+ } ) ;
85115
86- it ( "should display webpage link to more information about vaccine" , async ( ) => {
87- const vaccineType = VaccineType . RSV ;
88- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
116+ it ( "should display webpage link to more information about vaccine" , async ( ) => {
117+ const vaccineType = VaccineType . RSV ;
118+ render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
89119
90- const webpageLink : HTMLElement = screen . getByRole ( "link" , {
91- name : "Find out more about the RSV vaccine" ,
92- } ) ;
120+ const webpageLink : HTMLElement = screen . getByRole ( "link" , {
121+ name : "Find out more about the RSV vaccine" ,
122+ } ) ;
93123
94- expect ( webpageLink ) . toBeInTheDocument ( ) ;
95- expect ( webpageLink ) . toHaveAttribute ( "href" , "https://test.example.com/" ) ;
96- expect ( webpageLink ) . toHaveAttribute ( "target" , "_blank" ) ;
97- } ) ;
124+ expect ( webpageLink ) . toBeInTheDocument ( ) ;
125+ expect ( webpageLink ) . toHaveAttribute ( "href" , "https://test.example.com/" ) ;
126+ expect ( webpageLink ) . toHaveAttribute ( "target" , "_blank" ) ;
127+ } ) ;
98128
99- it ( "should not display whatItIsFor section if undefined in content" , async ( ) => {
100- const vaccineType = VaccineType . RSV ;
101- render ( < MoreInformation styledVaccineContent = { mockStyledContentWithoutWhatSection } vaccineType = { vaccineType } /> ) ;
129+ it ( "should not display whatItIsFor section if undefined in content" , async ( ) => {
130+ const vaccineType = VaccineType . RSV ;
131+ render ( < MoreInformation styledVaccineContent = { mockStyledContentWithoutWhatSection } vaccineType = { vaccineType } /> ) ;
102132
103- const whatItIsForHeading : HTMLElement | null = screen . queryByText ( "What the vaccine is for" ) ;
104- const whatItIsForContent : HTMLElement | null = screen . queryByText ( "What Section styled component" ) ;
133+ const whatItIsForHeading : HTMLElement | null = screen . queryByText ( "What the vaccine is for" ) ;
134+ const whatItIsForContent : HTMLElement | null = screen . queryByText ( "What Section styled component" ) ;
105135
106- expect ( whatItIsForHeading ) . not . toBeInTheDocument ( ) ;
107- expect ( whatItIsForContent ) . not . toBeInTheDocument ( ) ;
108- } ) ;
136+ expect ( whatItIsForHeading ) . not . toBeInTheDocument ( ) ;
137+ expect ( whatItIsForContent ) . not . toBeInTheDocument ( ) ;
138+ } ) ;
109139
110- it ( "should display whoVaccineIsFor section even if whatItIsFor is undefined in content" , async ( ) => {
111- const vaccineType = VaccineType . RSV ;
112- render ( < MoreInformation styledVaccineContent = { mockStyledContentWithoutWhatSection } vaccineType = { vaccineType } /> ) ;
140+ it ( "should display whoVaccineIsFor section even if whatItIsFor is undefined in content" , async ( ) => {
141+ const vaccineType = VaccineType . RSV ;
142+ render ( < MoreInformation styledVaccineContent = { mockStyledContentWithoutWhatSection } vaccineType = { vaccineType } /> ) ;
113143
114- expectExpanderBlockToBePresent ( "Who should have the vaccine" , "Who Section styled component" ) ;
144+ expectExpanderBlockToBePresent ( "Who should have the vaccine" , "Who Section styled component" ) ;
145+ } ) ;
115146 } ) ;
116147} ) ;
117148
@@ -122,3 +153,8 @@ const expectExpanderBlockToBePresent = (expanderHeading: string, expanderContent
122153 expect ( heading ) . toBeInTheDocument ( ) ;
123154 expect ( content ) . toBeInTheDocument ( ) ;
124155} ;
156+
157+ const expectExpanderBlockToNotBePresent = ( expanderHeading : string , expanderContent : string ) => {
158+ expect ( screen . queryByText ( expanderHeading ) ) . toBeNull ( ) ;
159+ expect ( screen . queryByText ( expanderContent ) ) . toBeNull ( ) ;
160+ } ;
0 commit comments