mattermost-mobile/app/components/profile_picture_button.test.js
Dean Whillier fb8238ab0b
[MM-37553] Update default themes (#5648)
* new themes and theme type updates

* update theme processing

port newer functionality from webapp

* update theme UI

including new svg-based thumbnail

* lint fixes

* update snapshots and tests

* update theme tile border approach

* remove unused path component

* remove old variable typo

* remove old variable type from theme type

* lint and snapshot updates

* update snapshots
2021-09-03 10:50:24 -04:00

56 lines
1.9 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {shallow} from 'enzyme';
import React from 'react';
import {Client4} from '@client/rest';
import Preferences from '@mm-redux/constants/preferences';
import ProfilePictureButton from './profile_picture_button.js';
describe('profile_picture_button', () => {
const baseProps = {
theme: Preferences.THEMES.denim,
currentUser: {
first_name: 'Dwight',
last_name: 'Schrute',
username: 'ieatbeets',
email: 'dwight@schrutefarms.com',
nickname: 'Dragon',
position: 'position',
},
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]);
});
});