Commit 8cffd0f4 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Ensure proper handling of missing subtitle in content info banner

parent 384d3adc
...@@ -25,9 +25,10 @@ import { ...@@ -25,9 +25,10 @@ import {
*/ */
export default function ContentInfoBanner({ info }) { export default function ContentInfoBanner({ info }) {
// Format item title to show subtitle // Format item title to show subtitle
const itemTitle = `${info.item.title}${info.item.subtitle && ': '}${ let itemTitle = info.item.title;
info.item.subtitle if (info.item.subtitle) {
}`; itemTitle += `: ${info.item.subtitle}`;
}
return ( return (
<div <div
className={classnames( className={classnames(
......
...@@ -51,6 +51,15 @@ describe('ContentInfoBanner', () => { ...@@ -51,6 +51,15 @@ describe('ContentInfoBanner', () => {
assert.equal(link.prop('target'), '_blank'); assert.equal(link.prop('target'), '_blank');
}); });
it('handles missing subtitle', () => {
delete contentInfo.item.subtitle;
const wrapper = createComponent();
const link = wrapper.find('LinkUnstyled[data-testid="content-item-link"]');
assert.equal(link.text(), 'Chapter 2');
});
it('provides disclosure of long titles through title attributes', () => { it('provides disclosure of long titles through title attributes', () => {
const wrapper = createComponent(); const wrapper = createComponent();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment