expect(emojiIndex.search('apple').map(trimEmojis)).toEqual(expected);
});
- it('erases custom emoji if not passed again', () => {
+ it('can include/exclude categories', () => {
+ expect(search('flag', { include: ['people'] })).toEqual([]);
+ expect(emojiIndex.search('flag', { include: ['people'] })).toEqual([]);
+ });
+
+ it('(different behavior from emoji-mart) do not erases custom emoji if not passed again', () => {
const custom = [
{
id: 'mastodon',
search('', { custom });
emojiIndex.search('', { custom });
const expected = [];
- expect(search('masto').map(trimEmojis)).toEqual(expected);
+ const lightExpected = [
+ {
+ id: 'mastodon',
+ custom: true,
+ },
+ ];
+ expect(search('masto').map(trimEmojis)).toEqual(lightExpected);
+ expect(emojiIndex.search('masto').map(trimEmojis)).toEqual(expected);
+ });
+
+ it('(different behavior from emoji-mart) erases custom emoji if another is passed', () => {
+ const custom = [
+ {
+ id: 'mastodon',
+ name: 'mastodon',
+ short_names: ['mastodon'],
+ text: '',
+ emoticons: [],
+ keywords: ['mastodon'],
+ imageUrl: 'http://example.com',
+ custom: true,
+ },
+ ];
+ search('', { custom });
+ emojiIndex.search('', { custom });
+ const expected = [];
+ expect(search('masto', { custom: [] }).map(trimEmojis)).toEqual(expected);
expect(emojiIndex.search('masto').map(trimEmojis)).toEqual(expected);
});
.not.toContain('pineapple');
});
- it('can include/exclude categories', () => {
- expect(search('flag', { include: ['people'] })).toEqual([]);
- expect(emojiIndex.search('flag', { include: ['people'] })).toEqual([]);
- });
-
it('does an emoji whose unified name is irregular', () => {
const expected = [
{
index = {};
}
-function search(value, { emojisToShowFilter, maxResults, include, exclude, custom = [] } = {}) {
- if (customEmojisList !== custom)
- addCustomToPool(custom, originalPool);
+function search(value, { emojisToShowFilter, maxResults, include, exclude, custom } = {}) {
+ if (custom !== undefined) {
+ if (customEmojisList !== custom)
+ addCustomToPool(custom, originalPool);
+ } else {
+ custom = [];
+ }
maxResults = maxResults || 75;
include = include || [];