Fix delete the root post on a thread to properly close the thread screen (#3116)

* Fix delete the root post on a thread to properly close the thread screen

* Fix unit test
This commit is contained in:
Elias Nahum 2019-08-14 09:54:12 -04:00 committed by Saturnino Abril
parent d924fb1c96
commit e09ce13f65
2 changed files with 10 additions and 3 deletions

View file

@ -360,9 +360,10 @@ export default class PostOptions extends PureComponent {
text: formatMessage({id: 'post_info.del', defaultMessage: 'Delete'}),
style: 'destructive',
onPress: () => {
actions.deletePost(post);
actions.removePost(post);
this.closeWithAnimation();
this.closeWithAnimation(() => {
actions.deletePost(post);
actions.removePost(post);
});
},
}]
);

View file

@ -111,8 +111,14 @@ describe('PostOptions', () => {
expect(Alert.alert).toBeCalled();
// Trigger on press of Delete in the Alert
const closeWithAnimation = jest.spyOn(wrapper.instance(), 'closeWithAnimation');
Alert.alert.mock.calls[0][2][1].onPress();
expect(closeWithAnimation).toBeCalled();
// get the callback that gets called by closeWithAnimation
const callback = closeWithAnimation.mock.calls[0][0];
callback();
expect(actions.deletePost).toBeCalled();
expect(actions.removePost).toBeCalled();
});