From 42ea16bde7a2bae502e6d8555111b24579cfdcf6 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 20 Nov 2018 07:56:03 -0800 Subject: [PATCH] Fixing opening a GM with the channel switcher. (#2047) --- components/quick_switch_modal/index.js | 4 ++-- components/quick_switch_modal/quick_switch_modal.jsx | 4 ++-- .../quick_switch_modal/quick_switch_modal.test.jsx | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/quick_switch_modal/index.js b/components/quick_switch_modal/index.js index d44581674e23..2c3fba120352 100644 --- a/components/quick_switch_modal/index.js +++ b/components/quick_switch_modal/index.js @@ -4,7 +4,7 @@ import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; -import {switchToChannel} from 'actions/views/channel'; +import {switchToChannelById} from 'actions/views/channel'; import QuickSwitchModal from './quick_switch_modal.jsx'; @@ -17,7 +17,7 @@ function mapStateToProps() { function mapDispatchToProps(dispatch) { return { actions: bindActionCreators({ - switchToChannel, + switchToChannelById, }, dispatch), }; } diff --git a/components/quick_switch_modal/quick_switch_modal.jsx b/components/quick_switch_modal/quick_switch_modal.jsx index 880a50e48b22..56a9933e3099 100644 --- a/components/quick_switch_modal/quick_switch_modal.jsx +++ b/components/quick_switch_modal/quick_switch_modal.jsx @@ -43,7 +43,7 @@ export default class QuickSwitchModal extends React.PureComponent { showTeamSwitcher: PropTypes.bool, actions: PropTypes.shape({ - switchToChannel: PropTypes.func.isRequired, + switchToChannelById: PropTypes.func.isRequired, }).isRequired, } @@ -131,7 +131,7 @@ export default class QuickSwitchModal extends React.PureComponent { if (this.state.mode === CHANNEL_MODE) { const selectedChannel = selected.channel; - this.props.actions.switchToChannel(selectedChannel).then((result) => { + this.props.actions.switchToChannelById(selectedChannel.id).then((result) => { if (result.data) { this.onHide(); } diff --git a/components/quick_switch_modal/quick_switch_modal.test.jsx b/components/quick_switch_modal/quick_switch_modal.test.jsx index 174785148abd..4783b3d5d547 100644 --- a/components/quick_switch_modal/quick_switch_modal.test.jsx +++ b/components/quick_switch_modal/quick_switch_modal.test.jsx @@ -15,7 +15,7 @@ describe('components/QuickSwitchModal', () => { onHide: jest.fn(), showTeamSwitcher: false, actions: { - switchToChannel: jest.fn().mockImplementation(() => { + switchToChannelById: jest.fn().mockImplementation(() => { const error = { message: 'Failed', }; @@ -42,7 +42,7 @@ describe('components/QuickSwitchModal', () => { wrapper.instance().handleSubmit(); expect(baseProps.onHide).not.toBeCalled(); - expect(props.actions.switchToChannel).not.toBeCalled(); + expect(props.actions.switchToChannelById).not.toBeCalled(); }); it('should fail to switch to a channel', (done) => { @@ -52,7 +52,7 @@ describe('components/QuickSwitchModal', () => { const channel = {id: 'channel_id', userId: 'user_id', type: Constants.DM_CHANNEL}; wrapper.instance().handleSubmit({channel}); - expect(baseProps.actions.switchToChannel).toBeCalledWith(channel); + expect(baseProps.actions.switchToChannelById).toBeCalledWith(channel.id); process.nextTick(() => { expect(baseProps.onHide).not.toBeCalled(); done(); @@ -63,7 +63,7 @@ describe('components/QuickSwitchModal', () => { const props = { ...baseProps, actions: { - switchToChannel: jest.fn().mockImplementation(() => { + switchToChannelById: jest.fn().mockImplementation(() => { const data = true; return Promise.resolve({data}); }), @@ -76,7 +76,7 @@ describe('components/QuickSwitchModal', () => { const channel = {id: 'channel_id', userId: 'user_id', type: Constants.DM_CHANNEL}; wrapper.instance().handleSubmit({channel}); - expect(props.actions.switchToChannel).toBeCalledWith(channel); + expect(props.actions.switchToChannelById).toBeCalledWith(channel.id); process.nextTick(() => { expect(baseProps.onHide).toBeCalled(); done();