Add getMessageTab test
This commit is contained in:
parent
54462b8a1b
commit
0dcfcbbafd
@ -1,5 +1,5 @@
|
||||
import { Map, fromJS } from 'immutable';
|
||||
import reducer, { broadcast } from '../messages';
|
||||
import reducer, { broadcast, getMessageTab } from '../messages';
|
||||
import * as actions from '../actions';
|
||||
import appReducer from '../app';
|
||||
|
||||
@ -176,3 +176,21 @@ describe('message reducer', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getMessageTab()', () => {
|
||||
it('returns the correct tab', () => {
|
||||
const srv = 'chat.freenode.net';
|
||||
[
|
||||
['#cake', '#cake'],
|
||||
['#apple.pie', '#apple.pie'],
|
||||
['bob', 'bob'],
|
||||
[undefined, srv],
|
||||
[null, srv],
|
||||
['*', srv],
|
||||
[srv, srv],
|
||||
['beans.freenode.net', srv]
|
||||
].forEach(([target, expected]) =>
|
||||
expect(getMessageTab(srv, target)).toBe(expected)
|
||||
);
|
||||
});
|
||||
});
|
||||
|
@ -117,7 +117,7 @@ function initMessage(message, tab, state) {
|
||||
return message;
|
||||
}
|
||||
|
||||
function getMessageTab(server, to) {
|
||||
export function getMessageTab(server, to) {
|
||||
if (!to || to === '*' || (!isChannel(to) && to.indexOf('.') !== -1)) {
|
||||
return server;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user