File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,6 +87,15 @@ describe('CardHeader', () => {
8787 ) . toBeInTheDocument ( ) ;
8888 } ) ;
8989
90+ it ( 'falls back to default heading when cmsHeadline is null (Strapi unset field)' , ( ) => {
91+ renderWithLocalizationProvider (
92+ < CardHeader headingText = { MOCK_HEADING } cmsHeadline = { null } />
93+ ) ;
94+ expect (
95+ screen . getByRole ( 'heading' , { name : MOCK_HEADING } )
96+ ) . toBeInTheDocument ( ) ;
97+ } ) ;
98+
9099 it ( 'falls back to default heading when only description is provided (no headline)' , ( ) => {
91100 renderWithLocalizationProvider (
92101 < CardHeader
@@ -113,7 +122,9 @@ describe('CardHeader', () => {
113122 expect (
114123 screen . getByRole ( 'heading' , { name : MOCK_HEADING } )
115124 ) . toBeInTheDocument ( ) ;
116- expect ( screen . queryByAltText ( MOCK_CMS_LOGO_ALT_TEXT ) ) . not . toBeInTheDocument ( ) ;
125+ expect (
126+ screen . queryByAltText ( MOCK_CMS_LOGO_ALT_TEXT )
127+ ) . not . toBeInTheDocument ( ) ;
117128 } ) ;
118129
119130 it ( 'renders CMS header with default font size' , ( ) => {
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ interface CardHeaderBasicWithDefaultSubheadingProps
5151interface CardHeaderCmsProps extends CardHeaderRequiredProps {
5252 cmsLogoUrl ?: string ;
5353 cmsLogoAltText ?: string ;
54- cmsHeadline ?: string ;
54+ cmsHeadline ?: string | null ;
5555 cmsDescription ?: string ;
5656 cmsHeadlineFontSize ?: HeadlineFontSize | string | null ;
5757 cmsHeadlineTextColor ?: string | null ;
@@ -111,7 +111,7 @@ function isDefaultService(
111111}
112112
113113function isCmsHeader ( props : CardHeaderProps ) : props is CardHeaderCmsProps {
114- return ( props as CardHeaderCmsProps ) . cmsHeadline !== undefined ;
114+ return ! ! ( props as CardHeaderCmsProps ) . cmsHeadline ;
115115}
116116
117117function isBasicWithCustomSubheading (
@@ -215,9 +215,7 @@ const CardHeader = (props: CardHeaderProps) => {
215215 >
216216 { cmsHeadline }
217217 </ h1 >
218- { cmsDescription && (
219- < p className = "card-subheader" > { cmsDescription } </ p >
220- ) }
218+ { cmsDescription && < p className = "card-subheader" > { cmsDescription } </ p > }
221219 </ >
222220 ) ;
223221 }
You can’t perform that action at this time.
0 commit comments