From 2464780eca1b4ccb2b3526463e2ed8f145ccfd0e Mon Sep 17 00:00:00 2001 From: Miguel Alatzar Date: Wed, 5 Feb 2020 17:18:59 -0700 Subject: [PATCH] [MM-22300] Use dismissModal to close ChannelInfo screen (#3890) * Use dismissModal to close ChannelInfo screen * Missing semicolon --- app/screens/channel_info/channel_info.js | 4 ++-- app/screens/channel_info/channel_info.test.js | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/app/screens/channel_info/channel_info.js b/app/screens/channel_info/channel_info.js index 40f312c1f..47b081137 100644 --- a/app/screens/channel_info/channel_info.js +++ b/app/screens/channel_info/channel_info.js @@ -18,7 +18,7 @@ import {preventDoubleTap} from 'app/utils/tap'; import {alertErrorWithFallback} from 'app/utils/general'; import {changeOpacity, makeStyleSheetFromTheme, setNavigatorStyles} from 'app/utils/theme'; import {t} from 'app/utils/i18n'; -import {dismissModal, goToScreen, popTopScreen, showModalOverCurrentContext} from 'app/actions/navigation'; +import {dismissModal, goToScreen, showModalOverCurrentContext} from 'app/actions/navigation'; import pinIcon from 'assets/images/channel_info/pin.png'; @@ -127,7 +127,7 @@ export default class ChannelInfo extends PureComponent { actions.setChannelDisplayName(''); } - popTopScreen(); + dismissModal(); }; goToChannelAddMembers = preventDoubleTap(() => { diff --git a/app/screens/channel_info/channel_info.test.js b/app/screens/channel_info/channel_info.test.js index 9e431bc52..42dc7d8b5 100644 --- a/app/screens/channel_info/channel_info.test.js +++ b/app/screens/channel_info/channel_info.test.js @@ -6,6 +6,8 @@ import {shallow} from 'enzyme'; import Preferences from 'mattermost-redux/constants/preferences'; import {General} from 'mattermost-redux/constants'; +import * as NavigationActions from 'app/actions/navigation'; + import ChannelInfo from './channel_info'; // ChannelInfoRow expects to receive the pinIcon as a number @@ -149,4 +151,19 @@ describe('channel_info', () => { const render = instance.renderConvertToPrivateRow(); expect(render).toBeFalsy(); }); + + test('should dismiss modal on close', () => { + const dismissModal = jest.spyOn(NavigationActions, 'dismissModal'); + const wrapper = shallow( + , + {context: {intl: intlMock}}, + ); + + const instance = wrapper.instance(); + expect(dismissModal).not.toHaveBeenCalled(); + instance.close(); + expect(dismissModal).toHaveBeenCalled(); + }); });