From b4c402a63df422e4690debeb38511ddc52911e39 Mon Sep 17 00:00:00 2001 From: Mags Allen Date: Thu, 22 Jun 2023 06:34:17 +0100 Subject: [PATCH] Make backToTop a Wrapper level prop for live blogs --- .../x-live-blog-post/src/__tests__/LiveBlogPost.test.jsx | 9 ++++++++- components/x-live-blog-wrapper/src/LiveBlogWrapper.jsx | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) 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 7cbb70324..8eae0e230 100644 --- a/components/x-live-blog-post/src/__tests__/LiveBlogPost.test.jsx +++ b/components/x-live-blog-post/src/__tests__/LiveBlogPost.test.jsx @@ -97,7 +97,8 @@ const regularPostContentPipeline = { publishedDate: new Date().toISOString(), articleUrl: 'Https://www.ft.com', showShareButtons: true, - renderRichText: RichText + renderRichText: RichText, + backToTop: 'Back to top' } const backToTopPostSpark = { @@ -261,6 +262,12 @@ describe('x-live-blog-post', () => { expect(liveBlogPost.html()).toContain('class="x-live-blog-post__body') expect(liveBlogPost.html()).toContain('

structured live blog body

') }) + + it('renders back to top link', () => { + const liveBlogPost = mount() + expect(liveBlogPost.html()).toContain('Back to top') + expect(liveBlogPost.html()).toContain('') + }) }) it('adds a data-x-component attribute', () => { diff --git a/components/x-live-blog-wrapper/src/LiveBlogWrapper.jsx b/components/x-live-blog-wrapper/src/LiveBlogWrapper.jsx index 873526863..ee2909bd1 100644 --- a/components/x-live-blog-wrapper/src/LiveBlogWrapper.jsx +++ b/components/x-live-blog-wrapper/src/LiveBlogWrapper.jsx @@ -40,6 +40,7 @@ class BaseLiveBlogWrapper extends Component { * @param {string} props.id - The id of the liveblog package * @param {*} props.liveBlogWrapperElementRef * @param {PostTrackerConfig} props.postTrackerConfig - Optional config for tracking post + * @param {string | Function} props.backToTop */ constructor(props) { super(props) @@ -146,6 +147,7 @@ class BaseLiveBlogWrapper extends Component { showShareButtons={showShareButtons} ad={ads[index]} renderRichText={this.props.renderRichText} + backToTop={this.props.backToTop} /> ))