Fix message broadcast action
This commit is contained in:
parent
4dd9671e87
commit
750ffef4c2
File diff suppressed because one or more lines are too long
29
client/src/js/__tests__/reducer-messages.test.js
Normal file
29
client/src/js/__tests__/reducer-messages.test.js
Normal 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');
|
||||
});
|
||||
});
|
@ -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)))
|
||||
);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user