mattermost-mobile/app/screens/channel_info/channel_info_header.test.js
Miguel Alatzar 2d81b497cf [MM-23520] Port mattermost-redux (#4088)
* Remove mattermost-redux

* Move mm-redux files into app/redux

* Add @redux path to tsconfig.json

* Fix imports

* Install missing dependencies

* Fix tsc errors

* Fix i18n_utils test

* Fix more imports

* Remove redux websocket

* Fix tests

* Rename @redux

* Apply changes from mattermost-redux PR 1103

* Remove mattermost-redux mention in template

* Add missing imports

* Rename app/redux/ to app/mm-redux/

* Remove test file

* Fix fetching Sidebar GM profiles

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
2020-04-17 21:12:09 -07:00

118 lines
3.5 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 '@mm-redux/constants/preferences';
import {General} from '@mm-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,
isTeammateGuest: false,
hasGuests: false,
isGroupConstrained: false,
isLandscape: false,
};
test('should match snapshot', async () => {
const wrapper = shallow(
<ChannelInfoHeader
{...baseProps}
/>,
{context: {intl: intlMock}},
);
expect(wrapper.getElement()).toMatchSnapshot();
});
test('should match snapshot when is group constrained', async () => {
const wrapper = shallow(
<ChannelInfoHeader
{...baseProps}
isGroupConstrained={true}
/>,
{context: {intl: intlMock}},
);
expect(wrapper.getElement()).toMatchSnapshot();
});
test('should match snapshot when public channel and hasGuests', async () => {
const wrapper = shallow(
<ChannelInfoHeader
{...baseProps}
hasGuests={true}
/>,
{context: {intl: intlMock}},
);
expect(wrapper.getElement()).toMatchSnapshot();
});
test('should match snapshot when DM and hasGuests but its me and not the teammate', async () => {
const wrapper = shallow(
<ChannelInfoHeader
{...baseProps}
type={General.DM_CHANNEL}
hasGuests={true}
isTeammateGuest={false}
/>,
{context: {intl: intlMock}},
);
expect(wrapper.getElement()).toMatchSnapshot();
});
test('should match snapshot when DM and hasGuests and is the teammate', async () => {
const wrapper = shallow(
<ChannelInfoHeader
{...baseProps}
type={General.DM_CHANNEL}
hasGuests={true}
isTeammateGuest={true}
/>,
{context: {intl: intlMock}},
);
expect(wrapper.getElement()).toMatchSnapshot();
});
test('should match snapshot when GM and hasGuests', async () => {
const wrapper = shallow(
<ChannelInfoHeader
{...baseProps}
type={General.GM_CHANNEL}
hasGuests={true}
/>,
{context: {intl: intlMock}},
);
expect(wrapper.getElement()).toMatchSnapshot();
});
});