Skip to content

Commit

Permalink
Make backToTop a Wrapper level prop for live blogs
Browse files Browse the repository at this point in the history
  • Loading branch information
magsallen committed Jun 30, 2023
1 parent ce9cca7 commit b4c402a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -261,6 +262,12 @@ 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('renders back to top link', () => {
const liveBlogPost = mount(<LiveBlogPost {...regularPostContentPipeline} />)
expect(liveBlogPost.html()).toContain('Back to top')
expect(liveBlogPost.html()).toContain('</a>')
})
})

it('adds a data-x-component attribute', () => {
Expand Down
2 changes: 2 additions & 0 deletions components/x-live-blog-wrapper/src/LiveBlogWrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -146,6 +147,7 @@ class BaseLiveBlogWrapper extends Component {
showShareButtons={showShareButtons}
ad={ads[index]}
renderRichText={this.props.renderRichText}
backToTop={this.props.backToTop}
/>
))

Expand Down

0 comments on commit b4c402a

Please sign in to comment.