2019-03-07 04:33:03 -05:00
|
|
|
|
import MockAdapter from 'axios-mock-adapter';
|
|
|
|
|
import axios from '~/lib/utils/axios_utils';
|
|
|
|
|
import { initEmojiMap, glEmojiTag, EMOJI_VERSION } from '~/emoji';
|
2017-06-23 16:25:21 -04:00
|
|
|
|
import isEmojiUnicodeSupported, {
|
2017-03-07 16:25:27 -05:00
|
|
|
|
isFlagEmoji,
|
2017-11-14 16:59:23 -05:00
|
|
|
|
isRainbowFlagEmoji,
|
2017-03-07 16:25:27 -05:00
|
|
|
|
isKeycapEmoji,
|
|
|
|
|
isSkinToneComboEmoji,
|
|
|
|
|
isHorceRacingSkinToneComboEmoji,
|
|
|
|
|
isPersonZwjEmoji,
|
2017-06-27 01:10:17 -04:00
|
|
|
|
} from '~/emoji/support/is_emoji_unicode_supported';
|
2019-03-07 04:33:03 -05:00
|
|
|
|
import installGlEmojiElement from '~/behaviors/gl_emoji';
|
2017-02-27 23:44:34 -05:00
|
|
|
|
|
|
|
|
|
const emptySupportMap = {
|
|
|
|
|
personZwj: false,
|
|
|
|
|
horseRacing: false,
|
|
|
|
|
flag: false,
|
|
|
|
|
skinToneModifier: false,
|
|
|
|
|
'9.0': false,
|
|
|
|
|
'8.0': false,
|
|
|
|
|
'7.0': false,
|
|
|
|
|
6.1: false,
|
|
|
|
|
'6.0': false,
|
|
|
|
|
5.2: false,
|
|
|
|
|
5.1: false,
|
|
|
|
|
4.1: false,
|
|
|
|
|
'4.0': false,
|
|
|
|
|
3.2: false,
|
|
|
|
|
'3.0': false,
|
|
|
|
|
1.1: false,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const emojiFixtureMap = {
|
|
|
|
|
bomb: {
|
|
|
|
|
name: 'bomb',
|
|
|
|
|
moji: '💣',
|
2019-03-07 04:33:03 -05:00
|
|
|
|
uni: '6.0',
|
2017-02-27 23:44:34 -05:00
|
|
|
|
},
|
|
|
|
|
construction_worker_tone5: {
|
|
|
|
|
name: 'construction_worker_tone5',
|
|
|
|
|
moji: '👷🏿',
|
2019-03-07 04:33:03 -05:00
|
|
|
|
uni: '8.0',
|
2017-02-27 23:44:34 -05:00
|
|
|
|
},
|
|
|
|
|
five: {
|
|
|
|
|
name: 'five',
|
|
|
|
|
moji: '5️⃣',
|
2019-03-07 04:33:03 -05:00
|
|
|
|
uni: '3.0',
|
2017-02-27 23:44:34 -05:00
|
|
|
|
},
|
2017-03-16 15:37:25 -04:00
|
|
|
|
grey_question: {
|
|
|
|
|
name: 'grey_question',
|
|
|
|
|
moji: '❔',
|
2019-03-07 04:33:03 -05:00
|
|
|
|
uni: '6.0',
|
2017-03-16 15:37:25 -04:00
|
|
|
|
},
|
2017-02-27 23:44:34 -05:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function markupToDomElement(markup) {
|
|
|
|
|
const div = document.createElement('div');
|
|
|
|
|
div.innerHTML = markup;
|
2019-03-07 04:33:03 -05:00
|
|
|
|
document.body.appendChild(div);
|
2017-02-27 23:44:34 -05:00
|
|
|
|
return div.firstElementChild;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-07 04:33:03 -05:00
|
|
|
|
function testGlEmojiImageFallback(element, name) {
|
2017-02-27 23:44:34 -05:00
|
|
|
|
expect(element.tagName.toLowerCase()).toBe('img');
|
2019-03-07 04:33:03 -05:00
|
|
|
|
expect(element.getAttribute('src')).toBe(`/-/emojis/${EMOJI_VERSION}/${name}.png`);
|
2017-02-27 23:44:34 -05:00
|
|
|
|
expect(element.getAttribute('title')).toBe(`:${name}:`);
|
|
|
|
|
expect(element.getAttribute('alt')).toBe(`:${name}:`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const defaults = {
|
|
|
|
|
forceFallback: false,
|
|
|
|
|
sprite: false,
|
|
|
|
|
};
|
|
|
|
|
|
2019-03-07 04:33:03 -05:00
|
|
|
|
function testGlEmojiElement(element, name, uni, unicodeMoji, options = {}) {
|
2017-02-27 23:44:34 -05:00
|
|
|
|
const opts = Object.assign({}, defaults, options);
|
|
|
|
|
expect(element.tagName.toLowerCase()).toBe('gl-emoji');
|
|
|
|
|
expect(element.dataset.name).toBe(name);
|
2019-03-07 04:33:03 -05:00
|
|
|
|
expect(element.dataset.uni).toBe(uni);
|
2017-02-27 23:44:34 -05:00
|
|
|
|
|
|
|
|
|
const fallbackSpriteClass = `emoji-${name}`;
|
|
|
|
|
if (opts.sprite) {
|
|
|
|
|
expect(element.dataset.fallbackSpriteClass).toBe(fallbackSpriteClass);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opts.forceFallback && opts.sprite) {
|
|
|
|
|
expect(element.getAttribute('class')).toBe(`emoji-icon ${fallbackSpriteClass}`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opts.forceFallback && !opts.sprite) {
|
|
|
|
|
// Check for image fallback
|
2019-03-07 04:33:03 -05:00
|
|
|
|
testGlEmojiImageFallback(element.firstElementChild, name);
|
2017-02-27 23:44:34 -05:00
|
|
|
|
} else {
|
|
|
|
|
// Otherwise make sure things are still unicode text
|
|
|
|
|
expect(element.textContent.trim()).toBe(unicodeMoji);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('gl_emoji', () => {
|
2019-03-07 04:33:03 -05:00
|
|
|
|
beforeAll(() => {
|
|
|
|
|
installGlEmojiElement();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let mock;
|
|
|
|
|
const emojiData = getJSONFixture('emojis/emojis.json');
|
|
|
|
|
|
|
|
|
|
beforeEach(function(done) {
|
|
|
|
|
mock = new MockAdapter(axios);
|
|
|
|
|
mock.onGet(`/-/emojis/${EMOJI_VERSION}/emojis.json`).reply(200, emojiData);
|
|
|
|
|
|
|
|
|
|
initEmojiMap()
|
|
|
|
|
.then(() => {
|
|
|
|
|
done();
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
done();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
afterEach(function() {
|
|
|
|
|
mock.restore();
|
|
|
|
|
});
|
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
describe('glEmojiTag', () => {
|
2019-03-07 04:33:03 -05:00
|
|
|
|
it('bomb emoji', done => {
|
2017-02-27 23:44:34 -05:00
|
|
|
|
const emojiKey = 'bomb';
|
|
|
|
|
const markup = glEmojiTag(emojiFixtureMap[emojiKey].name);
|
|
|
|
|
const glEmojiElement = markupToDomElement(markup);
|
2019-03-07 04:33:03 -05:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
testGlEmojiElement(
|
|
|
|
|
glEmojiElement,
|
|
|
|
|
emojiFixtureMap[emojiKey].name,
|
|
|
|
|
emojiFixtureMap[emojiKey].uni,
|
|
|
|
|
emojiFixtureMap[emojiKey].moji,
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
});
|
2017-02-27 23:44:34 -05:00
|
|
|
|
});
|
|
|
|
|
|
2019-03-07 04:33:03 -05:00
|
|
|
|
it('bomb emoji with image fallback', done => {
|
2017-02-27 23:44:34 -05:00
|
|
|
|
const emojiKey = 'bomb';
|
|
|
|
|
const markup = glEmojiTag(emojiFixtureMap[emojiKey].name, {
|
|
|
|
|
forceFallback: true,
|
|
|
|
|
});
|
|
|
|
|
const glEmojiElement = markupToDomElement(markup);
|
2019-03-07 04:33:03 -05:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
testGlEmojiElement(
|
|
|
|
|
glEmojiElement,
|
|
|
|
|
emojiFixtureMap[emojiKey].name,
|
|
|
|
|
emojiFixtureMap[emojiKey].uni,
|
|
|
|
|
emojiFixtureMap[emojiKey].moji,
|
|
|
|
|
{
|
|
|
|
|
forceFallback: true,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
});
|
2017-02-27 23:44:34 -05:00
|
|
|
|
});
|
|
|
|
|
|
2019-03-07 04:33:03 -05:00
|
|
|
|
it('bomb emoji with sprite fallback readiness', done => {
|
2017-02-27 23:44:34 -05:00
|
|
|
|
const emojiKey = 'bomb';
|
|
|
|
|
const markup = glEmojiTag(emojiFixtureMap[emojiKey].name, {
|
|
|
|
|
sprite: true,
|
|
|
|
|
});
|
|
|
|
|
const glEmojiElement = markupToDomElement(markup);
|
2019-03-07 04:33:03 -05:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
testGlEmojiElement(
|
|
|
|
|
glEmojiElement,
|
|
|
|
|
emojiFixtureMap[emojiKey].name,
|
|
|
|
|
emojiFixtureMap[emojiKey].uni,
|
|
|
|
|
emojiFixtureMap[emojiKey].moji,
|
|
|
|
|
{
|
|
|
|
|
sprite: true,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
});
|
2017-02-27 23:44:34 -05:00
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2019-03-07 04:33:03 -05:00
|
|
|
|
it('bomb emoji with sprite fallback', done => {
|
2017-02-27 23:44:34 -05:00
|
|
|
|
const emojiKey = 'bomb';
|
|
|
|
|
const markup = glEmojiTag(emojiFixtureMap[emojiKey].name, {
|
|
|
|
|
forceFallback: true,
|
|
|
|
|
sprite: true,
|
|
|
|
|
});
|
|
|
|
|
const glEmojiElement = markupToDomElement(markup);
|
2019-03-07 04:33:03 -05:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
testGlEmojiElement(
|
|
|
|
|
glEmojiElement,
|
|
|
|
|
emojiFixtureMap[emojiKey].name,
|
|
|
|
|
emojiFixtureMap[emojiKey].uni,
|
|
|
|
|
emojiFixtureMap[emojiKey].moji,
|
|
|
|
|
{
|
|
|
|
|
forceFallback: true,
|
|
|
|
|
sprite: true,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
});
|
2017-02-27 23:44:34 -05:00
|
|
|
|
});
|
2017-03-16 15:37:25 -04:00
|
|
|
|
|
2019-03-07 04:33:03 -05:00
|
|
|
|
it('question mark when invalid emoji name given', done => {
|
2017-03-16 15:37:25 -04:00
|
|
|
|
const name = 'invalid_emoji';
|
|
|
|
|
const emojiKey = 'grey_question';
|
|
|
|
|
const markup = glEmojiTag(name);
|
|
|
|
|
const glEmojiElement = markupToDomElement(markup);
|
2019-03-07 04:33:03 -05:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
testGlEmojiElement(
|
|
|
|
|
glEmojiElement,
|
|
|
|
|
emojiFixtureMap[emojiKey].name,
|
|
|
|
|
emojiFixtureMap[emojiKey].uni,
|
|
|
|
|
emojiFixtureMap[emojiKey].moji,
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
});
|
2017-03-16 15:37:25 -04:00
|
|
|
|
});
|
|
|
|
|
|
2019-03-07 04:33:03 -05:00
|
|
|
|
it('question mark with image fallback when invalid emoji name given', done => {
|
2017-03-16 15:37:25 -04:00
|
|
|
|
const name = 'invalid_emoji';
|
|
|
|
|
const emojiKey = 'grey_question';
|
|
|
|
|
const markup = glEmojiTag(name, {
|
|
|
|
|
forceFallback: true,
|
|
|
|
|
});
|
|
|
|
|
const glEmojiElement = markupToDomElement(markup);
|
2019-03-07 04:33:03 -05:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
testGlEmojiElement(
|
|
|
|
|
glEmojiElement,
|
|
|
|
|
emojiFixtureMap[emojiKey].name,
|
|
|
|
|
emojiFixtureMap[emojiKey].uni,
|
|
|
|
|
emojiFixtureMap[emojiKey].moji,
|
|
|
|
|
{
|
|
|
|
|
forceFallback: true,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
done();
|
|
|
|
|
});
|
2017-03-16 15:37:25 -04:00
|
|
|
|
});
|
2017-02-27 23:44:34 -05:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('isFlagEmoji', () => {
|
2017-06-02 04:52:27 -04:00
|
|
|
|
it('should gracefully handle empty string', () => {
|
|
|
|
|
expect(isFlagEmoji('')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect flag_ac', () => {
|
|
|
|
|
expect(isFlagEmoji('🇦🇨')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect flag_us', () => {
|
|
|
|
|
expect(isFlagEmoji('🇺🇸')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect flag_zw', () => {
|
|
|
|
|
expect(isFlagEmoji('🇿🇼')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect flags', () => {
|
|
|
|
|
expect(isFlagEmoji('🎏')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect triangular_flag_on_post', () => {
|
|
|
|
|
expect(isFlagEmoji('🚩')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect single letter', () => {
|
|
|
|
|
expect(isFlagEmoji('🇦')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect >2 letters', () => {
|
|
|
|
|
expect(isFlagEmoji('🇦🇧🇨')).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2017-11-14 16:59:23 -05:00
|
|
|
|
describe('isRainbowFlagEmoji', () => {
|
|
|
|
|
it('should gracefully handle empty string', () => {
|
|
|
|
|
expect(isRainbowFlagEmoji('')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-11-14 16:59:23 -05:00
|
|
|
|
it('should detect rainbow_flag', () => {
|
|
|
|
|
expect(isRainbowFlagEmoji('🏳🌈')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
|
it("should not detect flag_white on its' own", () => {
|
2017-11-14 16:59:23 -05:00
|
|
|
|
expect(isRainbowFlagEmoji('🏳')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2018-10-17 03:13:26 -04:00
|
|
|
|
it("should not detect rainbow on its' own", () => {
|
2017-11-14 16:59:23 -05:00
|
|
|
|
expect(isRainbowFlagEmoji('🌈')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-11-14 16:59:23 -05:00
|
|
|
|
it('should not detect flag_white with something else', () => {
|
|
|
|
|
expect(isRainbowFlagEmoji('🏳🔵')).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
describe('isKeycapEmoji', () => {
|
2017-06-02 04:52:27 -04:00
|
|
|
|
it('should gracefully handle empty string', () => {
|
|
|
|
|
expect(isKeycapEmoji('')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect one(keycap)', () => {
|
|
|
|
|
expect(isKeycapEmoji('1️⃣')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect nine(keycap)', () => {
|
|
|
|
|
expect(isKeycapEmoji('9️⃣')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect ten(keycap)', () => {
|
|
|
|
|
expect(isKeycapEmoji('🔟')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect hash(keycap)', () => {
|
|
|
|
|
expect(isKeycapEmoji('#⃣')).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('isSkinToneComboEmoji', () => {
|
2017-06-02 04:52:27 -04:00
|
|
|
|
it('should gracefully handle empty string', () => {
|
|
|
|
|
expect(isSkinToneComboEmoji('')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect hand_splayed_tone5', () => {
|
|
|
|
|
expect(isSkinToneComboEmoji('🖐🏿')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect hand_splayed', () => {
|
|
|
|
|
expect(isSkinToneComboEmoji('🖐')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect lifter_tone1', () => {
|
|
|
|
|
expect(isSkinToneComboEmoji('🏋🏻')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect lifter', () => {
|
|
|
|
|
expect(isSkinToneComboEmoji('🏋')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect rowboat_tone4', () => {
|
|
|
|
|
expect(isSkinToneComboEmoji('🚣🏾')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect rowboat', () => {
|
|
|
|
|
expect(isSkinToneComboEmoji('🚣')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect individual tone emoji', () => {
|
|
|
|
|
expect(isSkinToneComboEmoji('🏻')).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('isHorceRacingSkinToneComboEmoji', () => {
|
2017-06-02 04:52:27 -04:00
|
|
|
|
it('should gracefully handle empty string', () => {
|
|
|
|
|
expect(isHorceRacingSkinToneComboEmoji('')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect horse_racing_tone2', () => {
|
|
|
|
|
expect(isHorceRacingSkinToneComboEmoji('🏇🏼')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect horse_racing', () => {
|
|
|
|
|
expect(isHorceRacingSkinToneComboEmoji('🏇')).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('isPersonZwjEmoji', () => {
|
2017-06-02 04:52:27 -04:00
|
|
|
|
it('should gracefully handle empty string', () => {
|
|
|
|
|
expect(isPersonZwjEmoji('')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect couple_mm', () => {
|
|
|
|
|
expect(isPersonZwjEmoji('👨❤️👨')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect couple_with_heart', () => {
|
|
|
|
|
expect(isPersonZwjEmoji('💑')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect couplekiss', () => {
|
|
|
|
|
expect(isPersonZwjEmoji('💏')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect family_mmb', () => {
|
|
|
|
|
expect(isPersonZwjEmoji('👨👨👦')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect family_mwgb', () => {
|
|
|
|
|
expect(isPersonZwjEmoji('👨👩👧👦')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect family', () => {
|
|
|
|
|
expect(isPersonZwjEmoji('👪')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should detect kiss_ww', () => {
|
|
|
|
|
expect(isPersonZwjEmoji('👩❤️💋👩')).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect girl', () => {
|
|
|
|
|
expect(isPersonZwjEmoji('👧')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect girl_tone5', () => {
|
|
|
|
|
expect(isPersonZwjEmoji('👧🏿')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect man', () => {
|
|
|
|
|
expect(isPersonZwjEmoji('👨')).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('should not detect woman', () => {
|
|
|
|
|
expect(isPersonZwjEmoji('👩')).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('isEmojiUnicodeSupported', () => {
|
2017-06-02 04:52:27 -04:00
|
|
|
|
it('should gracefully handle empty string with unicode support', () => {
|
2018-10-17 03:13:26 -04:00
|
|
|
|
const isSupported = isEmojiUnicodeSupported({ '1.0': true }, '', '1.0');
|
2018-10-09 14:03:09 -04:00
|
|
|
|
|
2017-06-02 04:52:27 -04:00
|
|
|
|
expect(isSupported).toBeTruthy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-06-02 04:52:27 -04:00
|
|
|
|
it('should gracefully handle empty string without unicode support', () => {
|
2018-10-17 03:13:26 -04:00
|
|
|
|
const isSupported = isEmojiUnicodeSupported({}, '', '1.0');
|
2018-10-09 14:03:09 -04:00
|
|
|
|
|
2017-06-02 04:52:27 -04:00
|
|
|
|
expect(isSupported).toBeFalsy();
|
|
|
|
|
});
|
2018-10-09 13:01:49 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
it('bomb(6.0) with 6.0 support', () => {
|
|
|
|
|
const emojiKey = 'bomb';
|
|
|
|
|
const unicodeSupportMap = Object.assign({}, emptySupportMap, {
|
|
|
|
|
'6.0': true,
|
|
|
|
|
});
|
|
|
|
|
const isSupported = isEmojiUnicodeSupported(
|
|
|
|
|
unicodeSupportMap,
|
|
|
|
|
emojiFixtureMap[emojiKey].moji,
|
2019-03-07 04:33:03 -05:00
|
|
|
|
emojiFixtureMap[emojiKey].uni,
|
2017-02-27 23:44:34 -05:00
|
|
|
|
);
|
2018-10-09 14:03:09 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
expect(isSupported).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('bomb(6.0) without 6.0 support', () => {
|
|
|
|
|
const emojiKey = 'bomb';
|
|
|
|
|
const unicodeSupportMap = emptySupportMap;
|
|
|
|
|
const isSupported = isEmojiUnicodeSupported(
|
|
|
|
|
unicodeSupportMap,
|
|
|
|
|
emojiFixtureMap[emojiKey].moji,
|
2019-03-07 04:33:03 -05:00
|
|
|
|
emojiFixtureMap[emojiKey].uni,
|
2017-02-27 23:44:34 -05:00
|
|
|
|
);
|
2018-10-09 14:03:09 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
expect(isSupported).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('bomb(6.0) without 6.0 but with 9.0 support', () => {
|
|
|
|
|
const emojiKey = 'bomb';
|
|
|
|
|
const unicodeSupportMap = Object.assign({}, emptySupportMap, {
|
|
|
|
|
'9.0': true,
|
|
|
|
|
});
|
|
|
|
|
const isSupported = isEmojiUnicodeSupported(
|
|
|
|
|
unicodeSupportMap,
|
|
|
|
|
emojiFixtureMap[emojiKey].moji,
|
2019-03-07 04:33:03 -05:00
|
|
|
|
emojiFixtureMap[emojiKey].uni,
|
2017-02-27 23:44:34 -05:00
|
|
|
|
);
|
2018-10-09 14:03:09 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
expect(isSupported).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('construction_worker_tone5(8.0) without skin tone modifier support', () => {
|
|
|
|
|
const emojiKey = 'construction_worker_tone5';
|
|
|
|
|
const unicodeSupportMap = Object.assign({}, emptySupportMap, {
|
|
|
|
|
skinToneModifier: false,
|
|
|
|
|
'9.0': true,
|
|
|
|
|
'8.0': true,
|
|
|
|
|
'7.0': true,
|
|
|
|
|
6.1: true,
|
|
|
|
|
'6.0': true,
|
|
|
|
|
5.2: true,
|
|
|
|
|
5.1: true,
|
|
|
|
|
4.1: true,
|
|
|
|
|
'4.0': true,
|
|
|
|
|
3.2: true,
|
|
|
|
|
'3.0': true,
|
|
|
|
|
1.1: true,
|
|
|
|
|
});
|
|
|
|
|
const isSupported = isEmojiUnicodeSupported(
|
|
|
|
|
unicodeSupportMap,
|
|
|
|
|
emojiFixtureMap[emojiKey].moji,
|
2019-03-07 04:33:03 -05:00
|
|
|
|
emojiFixtureMap[emojiKey].uni,
|
2017-02-27 23:44:34 -05:00
|
|
|
|
);
|
2018-10-09 14:03:09 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
expect(isSupported).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('use native keycap on >=57 chrome', () => {
|
|
|
|
|
const emojiKey = 'five';
|
|
|
|
|
const unicodeSupportMap = Object.assign({}, emptySupportMap, {
|
|
|
|
|
'3.0': true,
|
|
|
|
|
meta: {
|
|
|
|
|
isChrome: true,
|
|
|
|
|
chromeVersion: 57,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
const isSupported = isEmojiUnicodeSupported(
|
|
|
|
|
unicodeSupportMap,
|
|
|
|
|
emojiFixtureMap[emojiKey].moji,
|
2019-03-07 04:33:03 -05:00
|
|
|
|
emojiFixtureMap[emojiKey].uni,
|
2017-02-27 23:44:34 -05:00
|
|
|
|
);
|
2018-10-09 14:03:09 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
expect(isSupported).toBeTruthy();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('fallback keycap on <57 chrome', () => {
|
|
|
|
|
const emojiKey = 'five';
|
|
|
|
|
const unicodeSupportMap = Object.assign({}, emptySupportMap, {
|
|
|
|
|
'3.0': true,
|
|
|
|
|
meta: {
|
|
|
|
|
isChrome: true,
|
|
|
|
|
chromeVersion: 50,
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
const isSupported = isEmojiUnicodeSupported(
|
|
|
|
|
unicodeSupportMap,
|
|
|
|
|
emojiFixtureMap[emojiKey].moji,
|
2019-03-07 04:33:03 -05:00
|
|
|
|
emojiFixtureMap[emojiKey].uni,
|
2017-02-27 23:44:34 -05:00
|
|
|
|
);
|
2018-10-09 14:03:09 -04:00
|
|
|
|
|
2017-02-27 23:44:34 -05:00
|
|
|
|
expect(isSupported).toBeFalsy();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|