forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Expensify#45324 from dominictb/fix/43845-mention-list
- Loading branch information
Showing
2 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import {compareUserInList} from '@pages/home/report/ReportActionCompose/SuggestionMention'; | ||
|
||
describe('compareUserInList', () => { | ||
it('Should compare the weight if the weight is different', () => { | ||
const first = {login: 'John Doe', weight: 1, accountID: 1}; | ||
const second = {login: 'Jane Doe', weight: 2, accountID: 2}; | ||
expect(compareUserInList(first, second)).toBe(-1); | ||
expect(compareUserInList(second, first)).toBe(1); | ||
}); | ||
|
||
it('Should compare the displayName if the weight is the same', () => { | ||
const first = {login: 'águero', weight: 2, accountID: 3}; | ||
const second = {login: 'Bronn', weight: 2, accountID: 4}; | ||
const third = {login: 'Carol', weight: 2, accountID: 5}; | ||
expect(compareUserInList(first, second)).toBe(-1); | ||
expect(compareUserInList(first, third)).toBe(-1); | ||
expect(compareUserInList(second, third)).toBe(-1); | ||
|
||
expect(compareUserInList(second, first)).toBe(1); | ||
expect(compareUserInList(third, first)).toBe(1); | ||
expect(compareUserInList(third, second)).toBe(1); | ||
}); | ||
|
||
it('Should compare the accountID if both the weight and displayName are the same', () => { | ||
const first = {login: 'águero', weight: 2, accountID: 6}; | ||
const second = {login: 'aguero', weight: 2, accountID: 7}; | ||
expect(compareUserInList(first, second)).toBe(-1); | ||
expect(compareUserInList(second, first)).toBe(1); | ||
}); | ||
}); |