* Adding base button functionality Moving file upload previews to be under textbox * Ensuring textbox is scrollable when in landscape mode * Updated image picker to use mixed camera option * Added unit tests, fixed other tests affected by dependency update * Updated patch for react-native-image-picker to 1.1.0 * Fixing incorrect import of DocumentPicker * MM-20989: Ensuring keyboard doesn't dismiss while submitting post (#3758) * Ensuring keyboard doesn't dismiss while submitting post * Update snapshot * Preventing the @ icon from being repeatedly tappable (#3777) * Fix snapshot from merge * MM-21736 Select/Take images and videos for Android * MM-21737 Fix attachment error message position on iOS * Remove FileUploadPreview from the iOS Thread screen * Fix android camera permissions * Fix post input box sizing and disable scrollview * Fix iOS photo gallery videos Co-authored-by: Andre Vasconcelos <andre.onogoro@gmail.com> Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
62 lines
2 KiB
JavaScript
62 lines
2 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 ProfilePictureButton from './profile_picture_button.js';
|
|
|
|
import {Client4} from 'mattermost-redux/client';
|
|
|
|
jest.mock('react-native-image-picker', () => ({
|
|
launchCamera: jest.fn(),
|
|
}));
|
|
|
|
describe('profile_picture_button', () => {
|
|
const baseProps = {
|
|
theme: Preferences.THEMES.default,
|
|
currentUser: {
|
|
first_name: 'Dwight',
|
|
last_name: 'Schrute',
|
|
username: 'ieatbeets',
|
|
email: 'dwight@schrutefarms.com',
|
|
nickname: 'Dragon',
|
|
position: 'position',
|
|
},
|
|
blurTextBox: jest.fn(),
|
|
maxFileSize: 20 * 1024 * 1024,
|
|
uploadFiles: jest.fn(),
|
|
};
|
|
|
|
test('should match snapshot', async () => {
|
|
const wrapper = shallow(
|
|
<ProfilePictureButton {...baseProps}/>,
|
|
);
|
|
expect(wrapper.getElement()).toMatchSnapshot();
|
|
});
|
|
|
|
test('should NOT return option to remove when profile picture is default', () => {
|
|
Client4.getProfilePictureUrl = jest.fn(() => 'image.png');
|
|
const wrapper = shallow(
|
|
<ProfilePictureButton {...baseProps}/>,
|
|
);
|
|
const instance = wrapper.instance();
|
|
|
|
// test default image (WITHOUT query param)
|
|
instance.getRemoveProfileImageOption();
|
|
expect(wrapper.state('extraOptions')).toEqual([null]);
|
|
});
|
|
|
|
test('should return option to remove profile picture if customized', () => {
|
|
Client4.getProfilePictureUrl = jest.fn(() => 'image.png?query');
|
|
const wrapper = shallow(
|
|
<ProfilePictureButton {...baseProps}/>,
|
|
);
|
|
const instance = wrapper.instance();
|
|
|
|
// test custom image (WITH query param)
|
|
instance.getRemoveProfileImageOption();
|
|
expect(wrapper.state('extraOptions')).not.toEqual([null]);
|
|
});
|
|
});
|