mattermost-mobile/app/components/post_header/post_header.test.js
Mattermost Build db63b59299 Automated cherry pick of #3445 (#3484)
* MM-19308 Fixed date wrapping

Updated the displayName to check for the reply button and bot tag. If seen the displayName container is set from 60% to 55% to allow for the extra space.

* MM-19308 Updated logic and added tests

Updated logic based on feedback.
Added Jest/Snapshots

* MM-19308 Apply change to other sections

Applied the change to autoresponder/webhook section.
2019-10-30 20:07:48 -04:00

98 lines
No EOL
2.8 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {shallow} from 'enzyme';
import Preferences from 'mattermost-redux/constants/preferences';
import PostHeader from './post_header';
describe('PostHeader', () => {
const baseProps = {
commentCount: 0,
commentedOnDisplayName: '',
createAt: 0,
displayName: 'John Smith',
enablePostUsernameOverride: false,
fromWebHook: false,
isPendingOrFailedPost: false,
isSearchResult: false,
isSystemMessage: false,
fromAutoResponder: false,
militaryTime: false,
overrideUsername: '',
renderReplies: false,
shouldRenderReplyButton: false,
showFullDate: false,
theme: Preferences.THEMES.default,
username: 'JohnSmith',
isBot: false,
isGuest: false,
userTimezone: '',
enableTimezone: false,
previousPostExists: false,
post: {id: 'post'},
beforePrevPostUserId: '0',
onPress: jest.fn(),
};
test('should match snapshot when just a base post', () => {
const wrapper = shallow(
<PostHeader {...baseProps}/>
);
expect(wrapper.getElement()).toMatchSnapshot();
expect(wrapper.find('#ReplyIcon').exists()).toEqual(false);
});
test('should match snapshot when post isBot and shouldRenderReplyButton', () => {
const props = {
...baseProps,
shouldRenderReplyButton: true,
isBot: true,
};
const wrapper = shallow(
<PostHeader {...props}/>
);
expect(wrapper.getElement()).toMatchSnapshot();
});
test('should match snapshot when post should display reply button', () => {
const props = {
...baseProps,
shouldRenderReplyButton: true,
};
const wrapper = shallow(
<PostHeader {...props}/>
);
expect(wrapper.getElement()).toMatchSnapshot();
});
test('should match snapshot when post is autoresponder', () => {
const props = {
...baseProps,
fromAutoResponder: true,
};
const wrapper = shallow(
<PostHeader {...props}/>
);
expect(wrapper.getElement()).toMatchSnapshot();
expect(wrapper.find('#ReplyIcon').exists()).toEqual(false);
});
test('should match snapshot when post is from system message', () => {
const props = {
...baseProps,
isSystemMessage: true,
};
const wrapper = shallow(
<PostHeader {...props}/>
);
expect(wrapper.getElement()).toMatchSnapshot();
expect(wrapper.find('#ReplyIcon').exists()).toEqual(false);
});
});