Skip to content

Commit

Permalink
fix: handle live blog posts without a byline
Browse files Browse the repository at this point in the history
  • Loading branch information
adgad committed Nov 9, 2022
1 parent 6249431 commit 6d5a03e
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 6d5a03e

Please sign in to comment.