Fix message broadcast action

This commit is contained in:
Ken-Håvard Lieng 2017-05-10 02:57:54 +02:00
parent 4dd9671e87
commit 750ffef4c2
3 changed files with 49 additions and 20 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,29 @@
import { Map } from 'immutable';
import reducer from '../reducers/messages';
import * as actions from '../actions';
import { broadcast } from '../actions/message';
describe('reducers/messages', () => {
it('adds messages to the correct tabs when broadcasting', () => {
let state = {
environment: Map({
charWidth: 0,
wrapWidth: 0
})
};
const thunk = broadcast('test', 'srv', ['#chan1', '#chan3']);
thunk(
action => { state.messages = reducer(undefined, action); },
() => state
);
const messages = state.messages.toJS();
expect(messages.srv).not.toHaveProperty('srv');
expect(messages.srv['#chan1']).toHaveLength(1);
expect(messages.srv['#chan1'][0].content).toBe('test');
expect(messages.srv['#chan3']).toHaveLength(1);
expect(messages.srv['#chan3'][0].content).toBe('test');
});
});

View File

@ -42,7 +42,7 @@ export default createReducer(Map(), {
}
} else {
messages.forEach(message =>
s.updateIn([server, tab], List(), list => list.push(new Message(message)))
s.updateIn([server, message.tab || tab], List(), list => list.push(new Message(message)))
);
}
});