Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
MM-17890 Properly dispatch handleChannelUpdatedEvent (#3478)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmhealey authored and saturninoabril committed Aug 22, 2019
1 parent e33ab57 commit 62213e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions actions/websocket_actions.jsx
Expand Up @@ -249,7 +249,7 @@ function handleClose(failCount) {
]));
}

function handleEvent(msg) {
export function handleEvent(msg) {
switch (msg.event) {
case SocketEvents.POSTED:
case SocketEvents.EPHEMERAL_MESSAGE:
Expand Down Expand Up @@ -321,7 +321,7 @@ function handleEvent(msg) {
break;

case SocketEvents.CHANNEL_UPDATED:
handleChannelUpdatedEvent(msg);
dispatch(handleChannelUpdatedEvent(msg));
break;

case SocketEvents.CHANNEL_MEMBER_UPDATED:
Expand Down
13 changes: 12 additions & 1 deletion actions/websocket_actions.test.jsx
Expand Up @@ -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,
Expand Down Expand Up @@ -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":{}}';
Expand Down

0 comments on commit 62213e8

Please sign in to comment.