This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
channel_utils.test.jsx
56 lines (43 loc) · 2.22 KB
/
channel_utils.test.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import * as Utils from 'utils/channel_utils.jsx';
describe('Channel Utils', () => {
describe('findNextUnreadChannelId', () => {
test('no channels are unread', () => {
const curChannelId = '3';
const allChannelIds = ['1', '2', '3', '4', '5'];
const unreadChannelIds = [];
expect(Utils.findNextUnreadChannelId(curChannelId, allChannelIds, unreadChannelIds, 1)).toEqual(-1);
});
test('only current channel is unread', () => {
const curChannelId = '3';
const allChannelIds = ['1', '2', '3', '4', '5'];
const unreadChannelIds = ['3'];
expect(Utils.findNextUnreadChannelId(curChannelId, allChannelIds, unreadChannelIds, 1)).toEqual(-1);
});
test('going forward to unread channels', () => {
const curChannelId = '3';
const allChannelIds = ['1', '2', '3', '4', '5'];
const unreadChannelIds = ['1', '4', '5'];
expect(Utils.findNextUnreadChannelId(curChannelId, allChannelIds, unreadChannelIds, 1)).toEqual(3);
});
test('going forward to unread channels with wrapping', () => {
const curChannelId = '3';
const allChannelIds = ['1', '2', '3', '4', '5'];
const unreadChannelIds = ['1', '2'];
expect(Utils.findNextUnreadChannelId(curChannelId, allChannelIds, unreadChannelIds, 1)).toEqual(0);
});
test('going backwards to unread channels', () => {
const curChannelId = '3';
const allChannelIds = ['1', '2', '3', '4', '5'];
const unreadChannelIds = ['1', '4', '5'];
expect(Utils.findNextUnreadChannelId(curChannelId, allChannelIds, unreadChannelIds, -1)).toEqual(0);
});
test('going backwards to unread channels with wrapping', () => {
const curChannelId = '3';
const allChannelIds = ['1', '2', '3', '4', '5'];
const unreadChannelIds = ['3', '4', '5'];
expect(Utils.findNextUnreadChannelId(curChannelId, allChannelIds, unreadChannelIds, -1)).toEqual(4);
});
});
});