Skip to content

Commit

Permalink
Merge pull request #680 from Financial-Times/fix-null-byline-case
Browse files Browse the repository at this point in the history
fix: handle live blog posts without a byline
  • Loading branch information
adgad authored Nov 9, 2022
2 parents 6249431 + 6d5a03e commit 71f6774
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion components/x-live-blog-post/src/LiveBlogPost.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const LiveBlogPost = ({
/>
)
}
if (typeof byline === 'object' && 'tree' in byline) {
if (byline && typeof byline === 'object' && 'tree' in byline) {
postByline = (
<p className="x-live-blog-post__byline">
<RichText structuredContent={byline} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ describe('x-live-blog-post', () => {
expect(liveBlogPost.html()).toContain('class="x-live-blog-post__body')
expect(liveBlogPost.html()).toContain('<p>structured live blog body</p>')
})

it('handles posts without bylines', () => {
const postWithoutByline = { ...regularPostContentPipeline, byline: null }
const liveBlogPost = mount(<LiveBlogPost {...postWithoutByline} />)
expect(liveBlogPost.html()).toContain('class="x-live-blog-post__body')
expect(liveBlogPost.html()).toContain('<p>structured live blog body</p>')
})
})

it('adds a data-x-component attribute', () => {
Expand Down

0 comments on commit 71f6774

Please sign in to comment.