Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TMisiukiewicz committed Apr 10, 2024
1 parent 7620b35 commit 5b42f38
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/libs/OptionsListUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2262,20 +2262,17 @@ function filterOptions(options: Options, searchInputValue: string): Options {
if (item.alternateText) {
values.push(item.alternateText);
}
values = values.concat(getParticipantsLoginsArray(item));
} else if (!!item.isChatRoom || !!item.isPolicyExpenseChat) {
if (item.subtitle) {
values.push(item.subtitle);
}
values = values.concat(getParticipantsLoginsArray(item));
} else {
values = values.concat(getParticipantsLoginsArray(item));
}
values = values.concat(getParticipantsLoginsArray(item));

return uniqFast(values);
});
const personalDetails = filterArrayByMatch(items.personalDetails, term, (item) =>
uniqFast([item.participantsList?.[0]?.displayName ?? '', item.login?.replace(emailRegex, '') ?? '']),
uniqFast([item.participantsList?.[0]?.displayName ?? '', item.login ?? '', item.login?.replace(emailRegex, '') ?? '']),
);

return {
Expand Down
2 changes: 1 addition & 1 deletion src/libs/filterArrayByMatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function filterArrayByMatch<T = string>(items: readonly T[], searchValue: string
}
}

if (itemRank >= MATCH_RANK.MATCHES) {
if (itemRank >= MATCH_RANK.MATCHES + 1) {
filteredItems.push(item);
}
}
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/OptionsListUtilsTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2609,11 +2609,12 @@ describe('OptionsListUtils', () => {
const options = OptionsListUtils.getSearchOptions(OPTIONS, '', [CONST.BETAS.ALL]);

const filteredOptions = OptionsListUtils.filterOptions(options, searchText);
expect(filteredOptions.recentReports.length).toBe(4);
expect(filteredOptions.recentReports.length).toBe(5);
expect(filteredOptions.recentReports[0].text).toBe('Invisible Woman');
expect(filteredOptions.recentReports[1].text).toBe('Spider-Man');
expect(filteredOptions.recentReports[2].text).toBe('Black Widow');
expect(filteredOptions.recentReports[3].text).toBe('Mister Fantastic');
expect(filteredOptions.recentReports[4].text).toBe("SHIELD's workspace (archived)");
});

it('should filter users by email', () => {
Expand Down

0 comments on commit 5b42f38

Please sign in to comment.