diff --git a/app/screens/channel_info/__snapshots__/channel_info_header.test.js.snap b/app/screens/channel_info/__snapshots__/channel_info_header.test.js.snap new file mode 100644 index 000000000..cb023a6ae --- /dev/null +++ b/app/screens/channel_info/__snapshots__/channel_info_header.test.js.snap @@ -0,0 +1,2181 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`channel_info_header should match snapshot 1`] = ` + + + + + + Channel name + + + + + + + + + + + + + + + + + + + + + + + + +`; + +exports[`channel_info_header should match snapshot when DM and hasGuests 1`] = ` + + + + + + Channel name + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +`; + +exports[`channel_info_header should match snapshot when GM and hasGuests 1`] = ` + + + + + + Channel name + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +`; + +exports[`channel_info_header should match snapshot when is group constrained 1`] = ` + + + + + + Channel name + + + + + + + + + + + + + + + + + + + + + + + + + + + +`; + +exports[`channel_info_header should match snapshot when public channel and hasGuests 1`] = ` + + + + + + Channel name + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +`; diff --git a/app/screens/channel_info/channel_info_header.js b/app/screens/channel_info/channel_info_header.js index 44831040c..7a52023c5 100644 --- a/app/screens/channel_info/channel_info_header.js +++ b/app/screens/channel_info/channel_info_header.js @@ -68,11 +68,13 @@ export default class ChannelInfoHeader extends React.PureComponent { } return ( - + + + ); } diff --git a/app/screens/channel_info/channel_info_header.test.js b/app/screens/channel_info/channel_info_header.test.js new file mode 100644 index 000000000..82456fa30 --- /dev/null +++ b/app/screens/channel_info/channel_info_header.test.js @@ -0,0 +1,102 @@ +// 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 {General} from 'mattermost-redux/constants'; + +import ChannelInfoHeader from './channel_info_header.js'; + +jest.mock('app/utils/theme', () => { + const original = require.requireActual('app/utils/theme'); + return { + ...original, + changeOpacity: jest.fn(), + }; +}); + +describe('channel_info_header', () => { + const intlMock = { + formatMessage: jest.fn(), + formatDate: jest.fn(), + formatTime: jest.fn(), + formatRelative: jest.fn(), + formatNumber: jest.fn(), + formatPlural: jest.fn(), + formatHTMLMessage: jest.fn(), + now: jest.fn(), + }; + const baseProps = { + createAt: 123, + creator: 'Creator', + memberCount: 3, + displayName: 'Channel name', + header: 'Header string', + onPermalinkPress: jest.fn(), + purpose: 'Purpose string', + status: 'status', + theme: Preferences.THEMES.default, + type: General.OPEN_CHANNEL, + isArchived: false, + isBot: false, + hasGuests: false, + isGroupConstrained: false, + }; + + test('should match snapshot', async () => { + const wrapper = shallow( + , + {context: {intl: intlMock}}, + ); + expect(wrapper.getElement()).toMatchSnapshot(); + }); + + test('should match snapshot when is group constrained', async () => { + const wrapper = shallow( + , + {context: {intl: intlMock}}, + ); + expect(wrapper.getElement()).toMatchSnapshot(); + }); + + test('should match snapshot when public channel and hasGuests', async () => { + const wrapper = shallow( + , + {context: {intl: intlMock}}, + ); + expect(wrapper.getElement()).toMatchSnapshot(); + }); + + test('should match snapshot when DM and hasGuests', async () => { + const wrapper = shallow( + , + {context: {intl: intlMock}}, + ); + expect(wrapper.getElement()).toMatchSnapshot(); + }); + + test('should match snapshot when GM and hasGuests', async () => { + const wrapper = shallow( + , + {context: {intl: intlMock}}, + ); + expect(wrapper.getElement()).toMatchSnapshot(); + }); +});