diff --git a/app/screens/post_options/post_options.js b/app/screens/post_options/post_options.js index 375943758..ce2a9ec77 100644 --- a/app/screens/post_options/post_options.js +++ b/app/screens/post_options/post_options.js @@ -363,7 +363,7 @@ export default class PostOptions extends PureComponent { handlePostDelete = () => { const {formatMessage} = this.context.intl; - const {actions, isMyPost, post} = this.props; + const {actions, post} = this.props; Alert.alert( formatMessage({id: 'mobile.post.delete_title', defaultMessage: 'Delete Post'}), @@ -379,9 +379,7 @@ export default class PostOptions extends PureComponent { style: 'destructive', onPress: () => { actions.deletePost(post); - if (isMyPost) { - actions.removePost(post); - } + actions.removePost(post); this.closeWithAnimation(); }, }] diff --git a/app/screens/post_options/post_options.test.js b/app/screens/post_options/post_options.test.js index 2cad038d2..b46989bfd 100644 --- a/app/screens/post_options/post_options.test.js +++ b/app/screens/post_options/post_options.test.js @@ -2,6 +2,7 @@ // 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'; @@ -10,6 +11,12 @@ import PostOptions from './post_options'; jest.mock('react-intl'); +jest.mock('Alert', () => { + return { + alert: jest.fn(), + }; +}); + describe('PostOptions', () => { const navigator = { showModal: jest.fn(), @@ -99,4 +106,17 @@ describe('PostOptions', () => { 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(); + }); });