Skip to content

Commit

Permalink
user [nfc]: Cut long-disused function sortAlphabetically
Browse files Browse the repository at this point in the history
This hasn't been used since b1bd9c7, in 2017.
  • Loading branch information
gnprice committed Mar 17, 2022
1 parent 0fca8ef commit 0c114b7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 21 deletions.
17 changes: 0 additions & 17 deletions src/users/__tests__/userHelpers-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
filterUserList,
getAutocompleteSuggestion,
getAutocompleteUserGroupSuggestions,
sortAlphabetically,
filterUserStartWith,
filterUserThatContains,
filterUserMatchesEmail,
Expand Down Expand Up @@ -209,22 +208,6 @@ describe('sortUserList', () => {
});
});

describe('sortAlphabetically', () => {
test('alphabetically sort user list by full_name', () => {
const user1 = eg.makeUser({ full_name: 'zoe' });
const user2 = eg.makeUser({ full_name: 'Ring' });
const user3 = eg.makeUser({ full_name: 'watch' });
const user4 = eg.makeUser({ full_name: 'mobile' });
const user5 = eg.makeUser({ full_name: 'Ring' });
const user6 = eg.makeUser({ full_name: 'hardware' });
const user7 = eg.makeUser({ full_name: 'Bob' });
const users = deepFreeze([user1, user2, user3, user4, user5, user6, user7]);

const expectedUsers = [user7, user6, user4, user2, user5, user3, user1];
expect(sortAlphabetically(users)).toEqual(expectedUsers);
});
});

describe('filterUserStartWith', () => {
test('returns users whose name starts with filter excluding self', () => {
const user1 = eg.makeUser({ full_name: 'Apple' });
Expand Down
4 changes: 0 additions & 4 deletions src/users/userHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as typeahead from '@zulip/shared/js/typeahead';
import type {
MutedUsersState,
UserPresence,
User,
UserId,
UserGroup,
PresenceState,
Expand Down Expand Up @@ -78,9 +77,6 @@ export const filterUserList = (
|| user.email.toLowerCase().includes(filter.toLowerCase()),
);

export const sortAlphabetically = (users: $ReadOnlyArray<User>): $ReadOnlyArray<User> =>
[...users].sort((x1, x2) => x1.full_name.toLowerCase().localeCompare(x2.full_name.toLowerCase()));

export const filterUserStartWith = (
users: $ReadOnlyArray<AutocompleteOption>,
filter: string = '',
Expand Down

0 comments on commit 0c114b7

Please sign in to comment.