mattermost-mobile/app/components/user_list/index.test.tsx
Daniel Espino García a8ee3a1b5a
Fix and unify channel and user list items (#7175)
* Fix channel and user list items

* Fixes on members and create a dm lists

* Fix tutorial and ipad

* Fix test

* Address feedback

* Several fixes on Android

* Fix tests

* Address feedback

* Add more non breaking strings

---------

Co-authored-by: Daniel Espino <danielespino@MacBook-Pro-de-Daniel.local>
2023-04-19 10:13:14 +02:00

165 lines
4.4 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import {renderWithEverything} from '@test/intl-test-helper';
import TestHelper from '@test/test_helper';
import UserList from '.';
import type Database from '@nozbe/watermelondb/Database';
describe('components/channel_list_row', () => {
let database: Database;
const user: UserProfile = {
id: '1',
create_at: 1111,
update_at: 1111,
delete_at: 0,
username: 'johndoe',
auth_service: '',
email: 'john@doe.com',
nickname: '',
first_name: '',
last_name: '',
position: '',
roles: '',
locale: '',
notify_props: {
channel: 'true',
comments: 'never',
desktop: 'mention',
desktop_sound: 'true',
email: 'true',
first_name: 'true',
mention_keys: '',
push: 'mention',
push_status: 'away',
},
};
const user2: UserProfile = {
id: '2',
create_at: 1111,
update_at: 1111,
delete_at: 0,
username: 'rocky',
auth_service: '',
email: 'rocky@doe.com',
nickname: '',
first_name: '',
last_name: '',
position: '',
roles: '',
locale: '',
notify_props: {
channel: 'true',
comments: 'never',
desktop: 'mention',
desktop_sound: 'true',
email: 'true',
first_name: 'true',
mention_keys: '',
push: 'mention',
push_status: 'away',
},
};
beforeAll(async () => {
const server = await TestHelper.setupServerDatabase();
database = server.database;
});
it('should show no results', () => {
const wrapper = renderWithEverything(
<UserList
profiles={[user]}
testID='UserListRow'
currentUserId={'1'}
handleSelectProfile={() => {
// noop
}}
fetchMore={() => {
// noop
}}
loading={true}
selectedIds={{}}
showNoResults={true}
tutorialWatched={true}
/>,
{database},
);
expect(wrapper.toJSON()).toMatchSnapshot();
});
it('should show results no tutorial', () => {
const wrapper = renderWithEverything(
<UserList
profiles={[user]}
testID='UserListRow'
currentUserId={'1'}
handleSelectProfile={() => {
// noop
}}
fetchMore={() => {
// noop
}}
loading={true}
selectedIds={{}}
showNoResults={true}
tutorialWatched={true}
/>,
{database},
);
expect(wrapper.toJSON()).toMatchSnapshot();
});
it('should show results no tutorial 2 users', () => {
const wrapper = renderWithEverything(
<UserList
profiles={[user, user2]}
testID='UserListRow'
currentUserId={'1'}
handleSelectProfile={() => {
// noop
}}
fetchMore={() => {
// noop
}}
loading={true}
selectedIds={{}}
showNoResults={true}
tutorialWatched={true}
/>,
{database},
);
expect(wrapper.toJSON()).toMatchSnapshot();
});
it('should show results and tutorial', () => {
const wrapper = renderWithEverything(
<UserList
profiles={[user]}
testID='UserListRow'
currentUserId={'1'}
handleSelectProfile={() => {
// noop
}}
fetchMore={() => {
// noop
}}
loading={true}
selectedIds={{}}
showNoResults={false}
tutorialWatched={false}
/>,
{database},
);
expect(wrapper.toJSON()).toMatchSnapshot();
});
});