* MM-10193 for landscape Feature Commit for MM-10193 to the landscape feature with latest pull. This is the initial commit with SafeAreaView in place, but should not be merged into master as this is step one and not suitable for production. Another commit will be following with adjustments to allow SafeAreaView to display correctly for users. * MM-10193 for landscape Feature Commit for MM-10193 to the landscape feature with latest pull. This is the initial commit with SafeAreaView in place, but should not be merged into master as this is step one and not suitable for production. Another commit will be following with adjustments to allow SafeAreaView to display correctly for users. * MM-10193 Extend design elements for iPhoneX SafeAreaViews This is the second portion of the MM-10193 changes for the landscape feature. This item was to extend the design elements for the application into the SafeAreaView so the application looks uniform on the iPhoneX. * MM-10193 Patch for Snapshot tests and eslint * MM-10193 Re-Patch These chanbes mistakenly got reverted from last Patch * MM-10193 Updates for PR Fixed the 4 screens from the text box that were missed. Updated the padding to run from a method. * Revert "MM-10193 Updates for PR" This reverts commit fe8d650ce3ca2828d8c94e4af470649aa2582ec1. * MM-10193 Updates for PR This reverts commit 4966d83d5401720d26ca22a55cf8f92f1657b7e2. Applied Updated Snapshots * MM-10193 Updated Modifier for iphone_x_spacing Updated Modifier for iphone_x_spacing * MM-10193 Updates for Review Review changes for Post Textbox and a few states that were unavailable. * MM-10193 Fix Longpress padding Fixed longpress padding for Channel Info and Edit Post views. * MM-10193 Update isLandscape Updated isLandscape to pull directly from dimensions. Updated padding for Recent Mentions and Flagged Posts. * MM-10193 Updates for review longpost Updated for longpost padding. Fixed issue with notifications not padding right correctly. * MM-10193 Update with Cleanup Reverted Cocoapods back to 1.5.3. Cleaned up spacing in two files. * MM-10193 Merge Conflict Updates Updates to resolve merge conflicts
119 lines
3.3 KiB
JavaScript
119 lines
3.3 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React from 'react';
|
|
import {Alert} from 'react-native';
|
|
import {shallow} from 'enzyme';
|
|
|
|
import Preferences from 'mattermost-redux/constants/preferences';
|
|
|
|
import PostOptions from './post_options';
|
|
|
|
jest.mock('react-intl');
|
|
|
|
jest.mock('Alert', () => {
|
|
return {
|
|
alert: jest.fn(),
|
|
};
|
|
});
|
|
|
|
describe('PostOptions', () => {
|
|
const actions = {
|
|
addReaction: jest.fn(),
|
|
deletePost: jest.fn(),
|
|
flagPost: jest.fn(),
|
|
pinPost: jest.fn(),
|
|
removePost: jest.fn(),
|
|
unflagPost: jest.fn(),
|
|
unpinPost: jest.fn(),
|
|
dismissModal: jest.fn(),
|
|
showModal: jest.fn(),
|
|
};
|
|
|
|
const post = {
|
|
root_id: 'root_id',
|
|
id: 'post_id',
|
|
message: 'message',
|
|
is_pinned: false,
|
|
channel_id: 'channel_id',
|
|
};
|
|
|
|
const baseProps = {
|
|
actions,
|
|
canAddReaction: true,
|
|
canReply: true,
|
|
canDelete: true,
|
|
canPin: true,
|
|
canEdit: true,
|
|
canEditUntil: -1,
|
|
channelIsReadOnly: false,
|
|
currentTeamUrl: 'http://localhost:8065/team-name',
|
|
deviceHeight: 600,
|
|
hasBeenDeleted: false,
|
|
isFlagged: false,
|
|
isMyPost: true,
|
|
isSystemMessage: false,
|
|
managedConfig: {},
|
|
post,
|
|
showAddReaction: true,
|
|
theme: Preferences.THEMES.default,
|
|
isLandscape: false,
|
|
};
|
|
|
|
function getWrapper(props = {}) {
|
|
return shallow(
|
|
<PostOptions
|
|
{...baseProps}
|
|
{...props}
|
|
/>,
|
|
{context: {intl: {formatMessage: ({defaultMessage}) => defaultMessage}}}
|
|
);
|
|
}
|
|
|
|
test('should match snapshot, showing all possible options', () => {
|
|
const wrapper = getWrapper();
|
|
|
|
expect(wrapper.getElement()).toMatchSnapshot();
|
|
});
|
|
|
|
test('should match snapshot, showing Delete option only for system message to user who has permission to delete', () => {
|
|
const wrapper = getWrapper({isSystemMessage: true});
|
|
|
|
expect(wrapper.getElement()).toMatchSnapshot();
|
|
});
|
|
|
|
test('should match snapshot, no option for system message to user who doesn\'t have the permission to delete', () => {
|
|
const wrapper = getWrapper({isSystemMessage: true, canDelete: false});
|
|
|
|
expect(wrapper.getElement()).toMatchSnapshot();
|
|
});
|
|
|
|
test('should load thread', () => {
|
|
const wrapper = getWrapper();
|
|
const instance = wrapper.instance();
|
|
|
|
instance.closeWithAnimation = jest.fn();
|
|
|
|
wrapper.findWhere((node) => node.key() === 'reply').simulate('press');
|
|
expect(instance.closeWithAnimation).toBeCalled();
|
|
});
|
|
|
|
test('should not show reply option', () => {
|
|
const wrapper = getWrapper({canReply: false});
|
|
|
|
expect(wrapper.findWhere((node) => node.key() === 'reply')).toMatchObject({});
|
|
});
|
|
|
|
test('should remove post after delete', () => {
|
|
const wrapper = getWrapper();
|
|
|
|
wrapper.findWhere((node) => node.key() === 'delete').simulate('press');
|
|
expect(Alert.alert).toBeCalled();
|
|
|
|
// Trigger on press of Delete in the Alert
|
|
Alert.alert.mock.calls[0][2][1].onPress();
|
|
|
|
expect(actions.deletePost).toBeCalled();
|
|
expect(actions.removePost).toBeCalled();
|
|
});
|
|
});
|