@@ -9,23 +9,43 @@ describe("Vaccination Hub Page", () => {
99 render ( < VaccinationsHub /> ) ;
1010 } ) ;
1111
12- it ( "renders heading" , async ( ) => {
12+ it ( "renders main heading" , async ( ) => {
1313 expectHeadingToBeRendered ( ) ;
1414 } ) ;
1515
16- it ( "renders vaccines for all ages button" , async ( ) => {
17- const button = screen . getByRole ( "link" , { name : "View vaccines for all ages" } ) ;
18- expect ( button ) . toBeVisible ( ) ;
19- expect ( button ) . toHaveAttribute ( "href" , "/vaccines-for-all-ages" ) ;
16+ it ( "renders subheading about pregnancy" , ( ) => {
17+ const subheading : HTMLElement = getHeading ( "Vaccines if you are pregnant" , 2 ) ;
18+ expect ( subheading ) . toBeVisible ( ) ;
19+ } ) ;
20+
21+ it ( "renders subtext about pregnancy" , ( ) => {
22+ const subtext : HTMLElement = screen . getByText (
23+ "Some vaccines are recommended during pregnancy to protect the health of you and your baby." ,
24+ ) ;
25+ expect ( subtext ) . toBeVisible ( ) ;
26+ } ) ;
27+
28+ it ( "renders vaccines during pregnancy card link" , async ( ) => {
29+ expectLinkToBeRendered ( "Vaccines during pregnancy" , "/vaccines-during-pregnancy" ) ;
30+ } ) ;
31+
32+ it ( "renders vaccines for all ages button" , async ( ) => {
33+ expectLinkToBeRendered ( "View vaccines for all ages" , "/vaccines-for-all-ages" ) ;
2034 } ) ;
2135} ) ;
2236
2337const expectHeadingToBeRendered = ( ) => {
24- expect ( queryHeading ( SERVICE_HEADING , 1 ) ) . toBeVisible ( ) ;
38+ expect ( getHeading ( SERVICE_HEADING , 1 ) ) . toBeVisible ( ) ;
39+ } ;
40+
41+ const expectLinkToBeRendered = ( text : string , href : string ) => {
42+ const link : HTMLElement = screen . getByRole ( "link" , { name : text } ) ;
43+ expect ( link ) . toBeVisible ( ) ;
44+ expect ( link ) . toHaveAttribute ( "href" , href ) ;
2545} ;
2646
27- const queryHeading = ( text : string , level : number ) : HTMLElement | null => {
28- return screen . queryByRole ( "heading" , {
47+ const getHeading = ( text : string , level : number ) : HTMLElement => {
48+ return screen . getByRole ( "heading" , {
2949 name : text ,
3050 level : level ,
3151 } ) ;
0 commit comments