forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post_type.test.jsx
48 lines (39 loc) · 1.4 KB
/
post_type.test.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {shallow, mount} from 'enzyme';
import PostMessageView from 'components/post_view/post_message_view/post_message_view.jsx';
class PostTypePlugin extends React.PureComponent {
render() {
return <span id='pluginId'>{'PostTypePlugin'}</span>;
}
}
describe('plugins/PostMessageView', () => {
const post = {type: 'testtype', message: 'this is some text', id: 'post_id'};
const pluginPostTypes = {
testtype: {component: PostTypePlugin},
};
const requiredProps = {
post,
pluginPostTypes,
currentUser: {username: 'username'},
team: {name: 'team_name'},
emojis: {name: 'smile'},
theme: {id: 'theme_id'},
enableFormatting: true,
};
test('should match snapshot with extended post type', () => {
const wrapper = mount(
<PostMessageView {...requiredProps}/>
);
expect(wrapper).toMatchSnapshot();
expect(wrapper.find('#pluginId').text()).toBe('PostTypePlugin');
});
test('should match snapshot with no extended post type', () => {
const props = {...requiredProps, pluginPostTypes: {}};
const wrapper = shallow(
<PostMessageView {...props}/>
);
expect(wrapper).toMatchSnapshot();
});
});