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
/
team_utils.test.jsx
29 lines (25 loc) · 1.53 KB
/
team_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
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {General} from 'mattermost-redux/constants';
import * as TeamUtils from 'utils/team_utils.jsx';
describe('TeamUtils.filterAndSortTeamsByDisplayName', () => {
const teamA = {id: 'team_id_a', name: 'team-a', display_name: 'Team A', delete_at: 0};
const teamB = {id: 'team_id_b', name: 'team-b', display_name: 'Team A', delete_at: 0};
const teamC = {id: 'team_id_c', name: 'team-c', display_name: 'Team C', delete_at: null};
const teamD = {id: 'team_id_d', name: 'team-d', display_name: 'Team D'};
const teamE = {id: 'team_id_e', name: 'team-e', display_name: 'Team E', delete_at: 1};
const teamF = {id: 'team_id_i', name: 'team-f', display_name: null};
const teamG = null;
test('should return correct sorted teams', () => {
for (const data of [
{teams: [teamG], result: []},
{teams: [teamF, teamG], result: []},
{teams: [teamA, teamB, teamC, teamD, teamE], result: [teamA, teamB, teamC, teamD]},
{teams: [teamE, teamD, teamC, teamB, teamA], result: [teamA, teamB, teamC, teamD]},
{teams: [teamA, teamB, teamC, teamD, teamE, teamF, teamG], result: [teamA, teamB, teamC, teamD]},
{teams: [teamG, teamF, teamE, teamD, teamC, teamB, teamA], result: [teamA, teamB, teamC, teamD]},
]) {
expect(TeamUtils.filterAndSortTeamsByDisplayName(data.teams, General.DEFAULT_LOCALE)).toEqual(data.result);
}
});
});