From a4a4588ae6078cf4a2fa16236a08b229611f1196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ken-H=C3=A5vard=20Lieng?= Date: Thu, 6 Jul 2017 07:01:14 +0200 Subject: [PATCH] Add compareUsers test --- .../state/__tests__/reducer-channels.test.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/client/src/js/state/__tests__/reducer-channels.test.js b/client/src/js/state/__tests__/reducer-channels.test.js index 4f6b91cc..28ec3b3e 100644 --- a/client/src/js/state/__tests__/reducer-channels.test.js +++ b/client/src/js/state/__tests__/reducer-channels.test.js @@ -291,3 +291,28 @@ function socket_mode(server, channel, user, add, remove) { server, channel, user, add, remove }; } + +describe('compareUsers()', () => { + it('compares users correctly', () => { + const compareUsers = reducer.__get__('compareUsers'); + expect([ + { renderName: 'user5' }, + { renderName: '@user2' }, + { renderName: 'user3' }, + { renderName: 'user2' }, + { renderName: '+user1' }, + { renderName: '~bob' }, + { renderName: '%apples' }, + { renderName: '&cake' } + ].sort(compareUsers)).toEqual([ + { renderName: '~bob' }, + { renderName: '&cake' }, + { renderName: '@user2' }, + { renderName: '%apples' }, + { renderName: '+user1' }, + { renderName: 'user2' }, + { renderName: 'user3' }, + { renderName: 'user5' } + ]); + }); +});