11import { MoreInformation } from "@src/app/_components/content/MoreInformation" ;
22import { VaccineType } from "@src/models/vaccine" ;
3+ import { Campaigns } from "@src/utils/campaigns/types" ;
4+ import config from "@src/utils/config" ;
5+ import { ConfigMock , configBuilder } from "@test-data/config/builders" ;
36import { mockStyledContent , mockStyledContentWithoutWhatSection } from "@test-data/content-api/data" ;
47import { render , screen } from "@testing-library/react" ;
5- import React from "react" ;
8+
9+ jest . mock ( "sanitize-data" , ( ) => ( { sanitize : jest . fn ( ) } ) ) ;
10+ jest . mock ( "@src/utils/config" ) ;
611
712describe ( "MoreInformation component " , ( ) => {
13+ const mockedConfig = config as ConfigMock ;
14+
15+ beforeEach ( ( ) => {
16+ const defaultConfig = configBuilder ( )
17+ . withCampaigns (
18+ Campaigns . fromJson (
19+ JSON . stringify ( {
20+ COVID_19 : [
21+ { start : "2025-11-01T09:00:00Z" , end : "2026-01-31T09:00:00Z" } ,
22+ { start : "2026-11-01T09:00:00Z" , end : "2027-01-31T09:00:00Z" } ,
23+ ] ,
24+ } ) ,
25+ ) ! ,
26+ )
27+ . build ( ) ;
28+ Object . assign ( mockedConfig , defaultConfig ) ;
29+ } ) ;
30+
831 describe ( "moreInformationHeadersFromContentApi false" , ( ) => {
932 it ( "should display whatItIsFor expander block" , async ( ) => {
1033 const vaccineType = VaccineType . RSV ;
11- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
34+ render ( await MoreInformation ( { styledVaccineContent : mockStyledContent , vaccineType : vaccineType } ) ) ;
1235
1336 expectExpanderBlockToBePresent ( "What the vaccine is for" , "What Section styled component" ) ;
1437 } ) ;
1538
1639 it ( "should display whoVaccineIsFor expander block" , async ( ) => {
1740 const vaccineType = VaccineType . RSV ;
18- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
41+ render ( await MoreInformation ( { styledVaccineContent : mockStyledContent , vaccineType : vaccineType } ) ) ;
1942
2043 expectExpanderBlockToBePresent ( "Who should have the vaccine" , "Who Section styled component" ) ;
2144 } ) ;
2245
2346 it ( "should display howToGet expander block" , async ( ) => {
2447 const vaccineType = VaccineType . TD_IPV_3_IN_1 ;
25- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
48+ render ( await MoreInformation ( { styledVaccineContent : mockStyledContent , vaccineType : vaccineType } ) ) ;
2649
2750 expectExpanderBlockToBePresent ( "How to get the vaccine" , "How Section styled component" ) ;
2851 } ) ;
2952
3053 it ( "should display vaccineSideEffects expander block" , async ( ) => {
3154 const vaccineType = VaccineType . RSV ;
32- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
55+ render ( await MoreInformation ( { styledVaccineContent : mockStyledContent , vaccineType : vaccineType } ) ) ;
3356
3457 expectExpanderBlockToBePresent ( "Side effects of the vaccine" , "Side effects section styled component" ) ;
3558 } ) ;
@@ -38,36 +61,36 @@ describe("MoreInformation component ", () => {
3861 describe ( "moreInformationHeadersFromContentApi true" , ( ) => {
3962 it ( "should display whatItIsFor expander block" , async ( ) => {
4063 const vaccineType = VaccineType . FLU_IN_PREGNANCY ;
41- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
64+ render ( await MoreInformation ( { styledVaccineContent : mockStyledContent , vaccineType : vaccineType } ) ) ;
4265
4366 expectExpanderBlockToBePresent ( "what-heading" , "What Section styled component" ) ;
4467 } ) ;
4568
4669 it ( "should display whoVaccineIsFor expander block" , async ( ) => {
4770 const vaccineType = VaccineType . FLU_IN_PREGNANCY ;
48- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
71+ render ( await MoreInformation ( { styledVaccineContent : mockStyledContent , vaccineType : vaccineType } ) ) ;
4972
5073 expectExpanderBlockToBePresent ( "who-heading" , "Who Section styled component" ) ;
5174 } ) ;
5275
5376 it ( "should display howToGet expander block" , async ( ) => {
5477 const vaccineType = VaccineType . FLU_IN_PREGNANCY ;
55- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
78+ render ( await MoreInformation ( { styledVaccineContent : mockStyledContent , vaccineType : vaccineType } ) ) ;
5679
5780 expectExpanderBlockToBePresent ( "how-heading" , "How Section styled component" ) ;
5881 } ) ;
5982
6083 it ( "should display vaccineSideEffects expander block" , async ( ) => {
6184 const vaccineType = VaccineType . FLU_IN_PREGNANCY ;
62- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
85+ render ( await MoreInformation ( { styledVaccineContent : mockStyledContent , vaccineType : vaccineType } ) ) ;
6386
6487 expectExpanderBlockToBePresent ( "side-effects-heading" , "Side effects section styled component" ) ;
6588 } ) ;
6689 } ) ;
6790
6891 it ( "should not include 'how to get' section for RSV_PREGNANCY " , async ( ) => {
6992 const vaccineType = VaccineType . RSV_PREGNANCY ;
70- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
93+ render ( await MoreInformation ( { styledVaccineContent : mockStyledContent , vaccineType : vaccineType } ) ) ;
7194
7295 const heading : HTMLElement | null = screen . queryByText ( "How to get the vaccine" ) ;
7396
@@ -76,7 +99,7 @@ describe("MoreInformation component ", () => {
7699
77100 it ( "should not include 'how to get' section for RSV " , async ( ) => {
78101 const vaccineType = VaccineType . RSV ;
79- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
102+ render ( await MoreInformation ( { styledVaccineContent : mockStyledContent , vaccineType : vaccineType } ) ) ;
80103
81104 const heading : HTMLElement | null = screen . queryByText ( "How to get the vaccine" ) ;
82105
@@ -85,7 +108,7 @@ describe("MoreInformation component ", () => {
85108
86109 it ( "should display webpage link to more information about vaccine" , async ( ) => {
87110 const vaccineType = VaccineType . RSV ;
88- render ( < MoreInformation styledVaccineContent = { mockStyledContent } vaccineType = { vaccineType } /> ) ;
111+ render ( await MoreInformation ( { styledVaccineContent : mockStyledContent , vaccineType : vaccineType } ) ) ;
89112
90113 const webpageLink : HTMLElement = screen . getByRole ( "link" , {
91114 name : "Find out more about the RSV vaccine" ,
@@ -98,7 +121,9 @@ describe("MoreInformation component ", () => {
98121
99122 it ( "should not display whatItIsFor section if undefined in content" , async ( ) => {
100123 const vaccineType = VaccineType . RSV ;
101- render ( < MoreInformation styledVaccineContent = { mockStyledContentWithoutWhatSection } vaccineType = { vaccineType } /> ) ;
124+ render (
125+ await MoreInformation ( { styledVaccineContent : mockStyledContentWithoutWhatSection , vaccineType : vaccineType } ) ,
126+ ) ;
102127
103128 const whatItIsForHeading : HTMLElement | null = screen . queryByText ( "What the vaccine is for" ) ;
104129 const whatItIsForContent : HTMLElement | null = screen . queryByText ( "What Section styled component" ) ;
@@ -109,7 +134,9 @@ describe("MoreInformation component ", () => {
109134
110135 it ( "should display whoVaccineIsFor section even if whatItIsFor is undefined in content" , async ( ) => {
111136 const vaccineType = VaccineType . RSV ;
112- render ( < MoreInformation styledVaccineContent = { mockStyledContentWithoutWhatSection } vaccineType = { vaccineType } /> ) ;
137+ render (
138+ await MoreInformation ( { styledVaccineContent : mockStyledContentWithoutWhatSection , vaccineType : vaccineType } ) ,
139+ ) ;
113140
114141 expectExpanderBlockToBePresent ( "Who should have the vaccine" , "Who Section styled component" ) ;
115142 } ) ;
0 commit comments