From 6d5a03e64f8b1d8e937bb8713ec0150c689d25d4 Mon Sep 17 00:00:00 2001 From: Arjun Gadhia Date: Wed, 9 Nov 2022 14:18:53 +0000 Subject: [PATCH] fix: handle live blog posts without a byline --- components/x-live-blog-post/src/LiveBlogPost.jsx | 2 +- .../x-live-blog-post/src/__tests__/LiveBlogPost.test.jsx | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/components/x-live-blog-post/src/LiveBlogPost.jsx b/components/x-live-blog-post/src/LiveBlogPost.jsx index 73b402136..6eb960f77 100644 --- a/components/x-live-blog-post/src/LiveBlogPost.jsx +++ b/components/x-live-blog-post/src/LiveBlogPost.jsx @@ -70,7 +70,7 @@ const LiveBlogPost = ({ /> ) } - if (typeof byline === 'object' && 'tree' in byline) { + if (byline && typeof byline === 'object' && 'tree' in byline) { postByline = (

diff --git a/components/x-live-blog-post/src/__tests__/LiveBlogPost.test.jsx b/components/x-live-blog-post/src/__tests__/LiveBlogPost.test.jsx index a37066eca..40700f084 100644 --- a/components/x-live-blog-post/src/__tests__/LiveBlogPost.test.jsx +++ b/components/x-live-blog-post/src/__tests__/LiveBlogPost.test.jsx @@ -252,6 +252,13 @@ describe('x-live-blog-post', () => { expect(liveBlogPost.html()).toContain('class="x-live-blog-post__body') expect(liveBlogPost.html()).toContain('

structured live blog body

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

structured live blog body

') + }) }) it('adds a data-x-component attribute', () => {