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
/
emoji.test.jsx
65 lines (49 loc) · 1.78 KB
/
emoji.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
57
58
59
60
61
62
63
64
65
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {compareEmojis} from 'utils/emoji_utils.jsx';
describe('Emoji', () => {
describe('compareEmojis', () => {
test('should sort an array of emojis alphabetically', () => {
const goatEmoji = {
name: 'goat',
};
const dashEmoji = {
name: 'dash',
};
const smileEmoji = {
name: 'smile',
};
const emojiArray = [goatEmoji, dashEmoji, smileEmoji];
emojiArray.sort((a, b) => compareEmojis(a, b));
expect(emojiArray).toEqual([dashEmoji, goatEmoji, smileEmoji]);
});
test('should have partiall matched emoji first', () => {
const goatEmoji = {
name: 'goat',
};
const dashEmoji = {
name: 'dash',
};
const smileEmoji = {
name: 'smile',
};
const emojiArray = [goatEmoji, dashEmoji, smileEmoji];
emojiArray.sort((a, b) => compareEmojis(a, b, 'smi'));
expect(emojiArray).toEqual([smileEmoji, dashEmoji, goatEmoji]);
});
test('should be able to sort on aliases', () => {
const goatEmoji = {
aliases: [':goat:'],
};
const dashEmoji = {
aliases: [':dash:'],
};
const smileEmoji = {
aliases: [':smile:'],
};
const emojiArray = [goatEmoji, dashEmoji, smileEmoji];
emojiArray.sort((a, b) => compareEmojis(a, b));
expect(emojiArray).toEqual([dashEmoji, goatEmoji, smileEmoji]);
});
});
});