mattermost-mobile/app/screens/user_profile/user_profile.test.js
Saturnino Abril 3c99672af5
Update unit test: use default theme, snapshot on wrapped elements and removal of unnecessary adapter (#2171)
* use default theme when unit testing the component

* update snapshots by getting wrapped elements only

* fix merge conflicts
2018-10-01 15:11:00 +08:00

53 lines
1.4 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 'mattermost-redux/constants/preferences';
import UserProfile from './user_profile.js';
jest.mock('react-intl');
jest.mock('app/utils/theme', () => {
const original = require.requireActual('app/utils/theme');
return {
...original,
changeOpacity: jest.fn(),
};
});
describe('user_profile', () => {
const actions = {
setChannelDisplayName: jest.fn(),
makeDirectChannel: jest.fn(),
};
const baseProps = {
actions,
config: {
ShowEmailAddress: true,
},
teammateNameDisplay: 'username',
navigator: {
resetTo: jest.fn(),
},
teams: [],
theme: Preferences.THEMES.default,
enableTimezone: false,
user: {
email: 'test@test.com',
first_name: 'test',
id: '4hzdnk6mg7gepe7yze6m3domnc',
last_name: 'fake',
nickname: 'nick',
},
militaryTime: false,
};
test('should match snapshot', async () => {
const wrapper = shallow(
<UserProfile {...baseProps}/>,
{context: {intl: {formatMessage: jest.fn()}}},
);
expect(wrapper.getElement()).toMatchSnapshot();
});
});