Skip to content
Closed
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
21 changes: 21 additions & 0 deletions apps/meteor/app/emoji-native/lib/generateEmojiData.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,24 @@ describe('native emoji shortcodes', () => {
expect(stale).toEqual([]);
});
});

describe('emojione shortcodes dropped by the migration', () => {
it.each([
[':red_haired:', '🦰'],
[':curly_haired:', '🦱'],
[':bald:', '🦲'],
[':white_haired:', '🦳'],
])('still converts the hair-style shortcode %s', (shortcode, unicode) => {
expect(shortnameToUnicode(shortcode)).toBe(unicode);
});

it('still converts :iphone: (emojibase alias shadowed by the joypixels-only lookup)', () => {
expect(shortnameToUnicode(':iphone:')).toBe('📱');
});
});

describe('shortnameToUnicode adjacent to timestamp-like text', () => {
it('converts a shortcode that directly follows an unknown :token:', () => {
expect(shortnameToUnicode('12:30:fire:')).toBe('12:30🔥');
});
});
8 changes: 8 additions & 0 deletions apps/meteor/app/emoji-native/lib/getEmojiConfig.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ describe('native emoji render', () => {
expect(render('©\u{FE0F}')).toBe('<span class="emoji" title=":copyright:">©\u{FE0F}</span>');
});

it('renders bare (unqualified) pictographic emojis without VS16', () => {
const { render } = getEmojiConfig(buildEmojiPackages(false));

// unlike the ©/™ symbols above, pictographs pasted without VS16 rendered as emojis before the migration
expect(render('❤')).toBe('<span class="emoji" title=":heart:">❤</span>');
expect(render('☺')).toBe('<span class="emoji" title=":relaxed:">☺</span>');
});

it('renders shortcodes contested with emojibase using their emojione meaning', () => {
const { render } = getEmojiConfig(buildEmojiPackages(false));

Expand Down
38 changes: 37 additions & 1 deletion apps/meteor/tests/unit/app/emoji/helpers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { expect } from 'chai';
import { describe, it, beforeEach, before } from 'mocha';

import { getEmojisBySearchTerm, updateRecent, removeFromRecent, replaceEmojiInRecent } from '../../../../app/emoji/client/helpers';
import {
createEmojiList,
getEmojisBySearchTerm,
updateRecent,
removeFromRecent,
replaceEmojiInRecent,
} from '../../../../app/emoji/client/helpers';
import { emoji } from '../../../../app/emoji/client/lib';
import { getEmojiConfig } from '../../../../app/emoji-native/lib/getEmojiConfig';
import { legacyEmojioneMap } from '../../../../app/emoji-native/lib/legacyEmojioneMap';

const registerNativeEmojis = () => {
const config = getEmojiConfig(emoji);
Expand Down Expand Up @@ -94,6 +101,35 @@ describe('Emoji Client Helpers', () => {
});
});

describe('createEmojiList', () => {
before(registerNativeEmojis);

const listNames = (category: string, recentEmojis: string[]) =>
createEmojiList(90, category, 0, recentEmojis, () => undefined).flatMap((row) =>
Array.isArray(row) ? row.map((item) => item.emoji) : [],
);

it('renders legacy emojione-only shortcodes registered in emoji.list', () => {
for (const [shortcode, unicode] of Object.entries(legacyEmojioneMap)) {
const key = `:${shortcode}:`;
if (emoji.list[key]) continue;
emoji.list[key] = {
uc_base: '',
uc_output: '',
uc_match: '',
uc_greedy: '',
shortnames: [],
category: '',
emojiPackage: 'native',
unicode,
} as any;
}

emoji.packages.base.emojisByCategory.recent = ['digit_one'];
expect(listNames('recent', emoji.packages.base.emojisByCategory.recent)).to.include('digit_one');
});
});

describe('updateRecent', () => {
it('should update recent emojis with the provided emojis', () => {
const recentEmojis = ['emoji1', 'emoji2'];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
import { unicodeToShortname } from './emoji';

// The app emoji list is joypixels-first since #41587; the transcript must emit the same
// vocabulary users see in-app (pre-migration, emoji-toolkit produced these names too)
describe('unicodeToShortname', () => {
it('converts emoji without variation selector to shortname', () => {
expect(unicodeToShortname('\u{1F44D}')).toBe(':+1:');
expect(unicodeToShortname('\u{1F44D}')).toBe(':thumbsup:');
});

it('converts emoji with variation selector to shortname', () => {
expect(unicodeToShortname('\u{1F44D}\u{FE0F}')).toBe(':+1:');
expect(unicodeToShortname('\u{1F44D}\u{FE0F}')).toBe(':thumbsup:');
});

it('converts skin tone emoji to shortname', () => {
expect(unicodeToShortname('\u{1F44D}\u{1F3FD}')).toBe(':+1_tone3:');
expect(unicodeToShortname('\u{1F44D}\u{1F3FD}')).toBe(':thumbsup_tone3:');
});

it('uses the app vocabulary where emojibase primaries diverge', () => {
expect(unicodeToShortname('😃')).toBe(':smiley:');
});

it('returns the input unchanged when no shortname exists', () => {
Expand Down
Loading