Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions tests/unit/EmojiCodeTest.js

This file was deleted.

23 changes: 22 additions & 1 deletion tests/unit/EmojiRegexTest.js → tests/unit/EmojiTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'underscore';
import Emoji from '../../assets/emojis';
import * as EmojiUtils from '../../src/libs/EmojiUtils';

describe('EmojiRegexTest', () => {
describe('EmojiTest', () => {
it('matches all the emojis in the list', () => {
// Given the set of Emojis available in the application
const emojiMatched = _.every(Emoji, (emoji) => {
Expand Down Expand Up @@ -59,4 +59,25 @@ describe('EmojiRegexTest', () => {
expect(EmojiUtils.isSingleEmoji('🇮🇳')).toBe(true);
expect(EmojiUtils.isSingleEmoji('🇺🇦️')).toBe(true);
});

it('replaces emoji codes with emojis inside a text', () => {
const text = 'Hi :smile::wave:';
expect(EmojiUtils.replaceEmojis(text)).toBe('Hi 😄👋');
});

it('suggests emojis when typing emojis prefix after colon', () => {
const text = 'Hi :happy';
expect(EmojiUtils.suggestEmojis(text)).toEqual([{code: '🙋', name: 'raising_hand'}]);
});

it('suggests a limited number of matching emojis', () => {
const text = 'Hi :face';
const limit = 3;
expect(EmojiUtils.suggestEmojis(text, limit).length).toBe(limit);
});

it('correct suggests emojis accounting for keywords', () => {
const text = ':thumb';
expect(EmojiUtils.suggestEmojis(text)).toEqual([{code: '👍', name: '+1'}, {code: '👎', name: '-1'}]);
});
});