diff --git a/app/components/post_list/post/body/content/message_attachments/__snapshots__/attachment_author.test.tsx.snap b/app/components/post_list/post/body/content/message_attachments/__snapshots__/attachment_author.test.tsx.snap new file mode 100644 index 000000000..bd52a11b9 --- /dev/null +++ b/app/components/post_list/post/body/content/message_attachments/__snapshots__/attachment_author.test.tsx.snap @@ -0,0 +1,135 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`AttachmentAuthor it matches snapshot when both name and icon are provided 1`] = ` + + + + + + jhondoe + + +`; + +exports[`AttachmentAuthor it matches snapshot when only icon is provided 1`] = ` + + + + + +`; + +exports[`AttachmentAuthor it matches snapshot when only name is provided 1`] = ` + + + jhondoe + + +`; diff --git a/app/components/post_list/post/body/content/message_attachments/attachment_author.test.tsx b/app/components/post_list/post/body/content/message_attachments/attachment_author.test.tsx new file mode 100644 index 000000000..98f49ca5f --- /dev/null +++ b/app/components/post_list/post/body/content/message_attachments/attachment_author.test.tsx @@ -0,0 +1,43 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import React from 'react'; + +import Preferences from '@constants/preferences'; +import {renderWithIntl} from '@test/intl-test-helper'; + +import AttachmentAuthor from './attachment_author'; + +describe('AttachmentAuthor', () => { + const baseProps = { + link: 'http://linktoatachment.com', + name: 'jhondoe', + icon: 'https://images.com/image.png', + theme: Preferences.THEMES.denim, + }; + + test('it matches snapshot when both name and icon are provided', () => { + const wrapper = renderWithIntl(); + expect(wrapper.toJSON()).toMatchSnapshot(); + }); + + test('it matches snapshot when only name is provided', () => { + const props = { + ...baseProps, + icon: undefined, + }; + + const wrapper = renderWithIntl(); + expect(wrapper.toJSON()).toMatchSnapshot(); + }); + + test('it matches snapshot when only icon is provided', () => { + const props = { + ...baseProps, + name: undefined, + }; + + const wrapper = renderWithIntl(); + expect(wrapper.toJSON()).toMatchSnapshot(); + }); +}); diff --git a/app/components/post_list/post/body/content/message_attachments/message_attachment.tsx b/app/components/post_list/post/body/content/message_attachments/message_attachment.tsx index 7b00e6268..ed557d6df 100644 --- a/app/components/post_list/post/body/content/message_attachments/message_attachment.tsx +++ b/app/components/post_list/post/body/content/message_attachments/message_attachment.tsx @@ -80,7 +80,7 @@ export default function MessageAttachment({attachment, channelId, layoutWidth, l value={attachment.pretext} /> - {Boolean(attachment.author_icon && attachment.author_name) && + {Boolean(attachment.author_icon || attachment.author_name) &&