Files
mattermost-mobile/app/components/channel_item/channel_item.test.tsx
Christopher Poile 5bb240dec8 MM-43300: Calls v2 first cut (#6475)
* Android and iOS requirements

* external types

* babel config for calls, package.json for calls dependencies

* state in rxJS; tests

* actions, client/rest, websocket events, constants

* webrtc connection logic

* calls components / screens

* handle peer destroyed gracefully

* PR comments

* remove ViewPropTypes from mocks; no need to ignore error in LogBox

* calls.d.ts -> calls.ts; i18-extract

* @app/products/calls -> @calls

* PR comments; test cleanup

* Revert "remove ViewPropTypes from mocks; no need to ignore error in LogBox"

This reverts commit f9bd171a54.

* working on typing withServerUrl

* added exportedForInternalUse instead of commenting "internal export"

* better switchToThread in call_screen

* i18n

* typed withServerUrl
2022-07-22 15:57:12 -04:00

94 lines
3.2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Database, Q} from '@nozbe/watermelondb';
import React from 'react';
import {MM_TABLES} from '@constants/database';
import {renderWithIntlAndTheme} from '@test/intl-test-helper';
import TestHelper from '@test/test_helper';
import ChannelItem from './channel_item';
import type ChannelModel from '@typings/database/models/servers/channel';
import type MyChannelModel from '@typings/database/models/servers/my_channel';
describe('components/channel_list/categories/body/channel_item', () => {
let database: Database;
let myChannel: MyChannelModel;
beforeAll(async () => {
const server = await TestHelper.setupServerDatabase();
database = server.database;
const myChannels = await database.get<MyChannelModel>(MM_TABLES.SERVER.MY_CHANNEL).query(
Q.take(1),
).fetch();
myChannel = myChannels[0];
});
it('should match snapshot', () => {
const wrapper = renderWithIntlAndTheme(
<ChannelItem
channel={{displayName: 'Hello!', type: 'O', shared: false, name: 'hello', deleteAt: 0} as ChannelModel}
hasDraft={false}
isActive={false}
membersCount={0}
isMuted={false}
currentUserId={'id'}
testID='channel_item'
onPress={() => undefined}
isUnread={myChannel.isUnread}
mentionsCount={myChannel.mentionsCount}
hasMember={Boolean(myChannel)}
hasCall={false}
/>,
);
expect(wrapper.toJSON()).toMatchSnapshot();
});
it('should match snapshot when it has a draft', () => {
const wrapper = renderWithIntlAndTheme(
<ChannelItem
channel={{displayName: 'Hello!', type: 'G', shared: false, name: 'hello', deleteAt: 0} as ChannelModel}
hasDraft={true}
isActive={false}
membersCount={3}
isMuted={false}
currentUserId={'id'}
testID='channel_item'
onPress={() => undefined}
isUnread={myChannel.isUnread}
mentionsCount={myChannel.mentionsCount}
hasMember={Boolean(myChannel)}
hasCall={false}
/>,
);
expect(wrapper.toJSON()).toMatchSnapshot();
});
it('should match snapshot when it has a call', () => {
const wrapper = renderWithIntlAndTheme(
<ChannelItem
channel={{displayName: 'Hello!', type: 'G', shared: false, name: 'hello', deleteAt: 0} as ChannelModel}
hasDraft={true}
isActive={false}
membersCount={3}
isMuted={false}
currentUserId={'id'}
testID='channel_item'
onPress={() => undefined}
isUnread={myChannel.isUnread}
mentionsCount={myChannel.mentionsCount}
hasMember={Boolean(myChannel)}
hasCall={true}
/>,
);
expect(wrapper.toJSON()).toMatchSnapshot();
});
});