From 62213e802d9bd0d0c091817e1a4f25784123ff2b Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Thu, 22 Aug 2019 05:25:34 -0400 Subject: [PATCH] MM-17890 Properly dispatch handleChannelUpdatedEvent (#3478) --- actions/websocket_actions.jsx | 4 ++-- actions/websocket_actions.test.jsx | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/actions/websocket_actions.jsx b/actions/websocket_actions.jsx index 741687fff125..ae936fde442c 100644 --- a/actions/websocket_actions.jsx +++ b/actions/websocket_actions.jsx @@ -249,7 +249,7 @@ function handleClose(failCount) { ])); } -function handleEvent(msg) { +export function handleEvent(msg) { switch (msg.event) { case SocketEvents.POSTED: case SocketEvents.EPHEMERAL_MESSAGE: @@ -321,7 +321,7 @@ function handleEvent(msg) { break; case SocketEvents.CHANNEL_UPDATED: - handleChannelUpdatedEvent(msg); + dispatch(handleChannelUpdatedEvent(msg)); break; case SocketEvents.CHANNEL_MEMBER_UPDATED: diff --git a/actions/websocket_actions.test.jsx b/actions/websocket_actions.test.jsx index 34979df6f281..5d0f7b423fb7 100644 --- a/actions/websocket_actions.test.jsx +++ b/actions/websocket_actions.test.jsx @@ -22,10 +22,11 @@ import store from 'stores/redux_store.jsx'; import configureStore from 'tests/test_store'; import {browserHistory} from 'utils/browser_history'; -import Constants, {UserStatuses} from 'utils/constants'; +import Constants, {SocketEvents, UserStatuses} from 'utils/constants'; import { handleChannelUpdatedEvent, + handleEvent, handleNewPostEvent, handleNewPostEvents, handlePostEditEvent, @@ -120,6 +121,16 @@ jest.mock('actions/views/rhs', () => ({ }), })); +describe('handleEvent', () => { + test('should dispatch channel updated event properly', () => { + const msg = {event: SocketEvents.CHANNEL_UPDATED}; + + handleEvent(msg); + + expect(store.dispatch).toHaveBeenCalled(); + }); +}); + describe('handlePostEditEvent', () => { test('post edited', async () => { const post = '{"id":"test","create_at":123,"update_at":123,"user_id":"user","channel_id":"12345","root_id":"","message":"asd","pending_post_id":"2345","metadata":{}}';